forked from zeux/microprofile
-
Notifications
You must be signed in to change notification settings - Fork 0
/
microprofiledraw.h
648 lines (542 loc) · 23.1 KB
/
microprofiledraw.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
// This is free and unencumbered software released into the public domain.
// Anyone is free to copy, modify, publish, use, compile, sell, or
// distribute this software, either in source code form or as a compiled
// binary, for any purpose, commercial or non-commercial, and by any
// means.
// In jurisdictions that recognize copyright laws, the author or authors
// of this software dedicate any and all copyright interest in the
// software to the public domain. We make this dedication for the benefit
// of the public at large and to the detriment of our heirs and
// successors. We intend this dedication to be an overt act of
// relinquishment in perpetuity of all present and future rights to this
// software under copyright law.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
// OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
// For more information, please refer to <http://unlicense.org/>
#ifndef MICROPROFILE_ENABLED
#error "microprofile.h must be included before including microprofiledraw.h"
#endif
#ifndef MICROPROFILEDRAW_ENABLED
#define MICROPROFILEDRAW_ENABLED MICROPROFILE_ENABLED
#endif
#ifndef MICROPROFILEDRAW_API
#define MICROPROFILEDRAW_API
#endif
#if MICROPROFILEDRAW_ENABLED
MICROPROFILEDRAW_API void MicroProfileDrawInitGL();
MICROPROFILEDRAW_API void MicroProfileRender(uint32_t nWidth, uint32_t nHeight, float fScale);
MICROPROFILEDRAW_API void MicroProfileBeginDraw(uint32_t nWidth, uint32_t nHeight, float* pfProjection);
MICROPROFILEDRAW_API void MicroProfileBeginDraw(uint32_t nWidth, uint32_t nHeight, float fScale);
MICROPROFILEDRAW_API void MicroProfileEndDraw();
#ifdef MICROPROFILEDRAW_IMPL
struct MicroProfileDrawVertex
{
float nX;
float nY;
uint32_t nColor;
float fU;
float fV;
};
struct MicroProfileDrawCommand
{
uint32_t nCommand;
uint32_t nNumVertices;
};
struct MicroProfileDrawContext
{
enum
{
MAX_COMMANDS = 32,
MAX_VERTICES = 16384,
};
bool bInitialized;
GLuint nVAO;
GLuint nVertexBuffer;
GLuint nProgram;
GLuint nTexture;
int nAttributePosition;
int nAttributeColor;
int nAttributeTexture;
int nUniformProjectionMatrix;
uint32_t nVertexPos;
uint32_t nCommandPos;
MicroProfileDrawVertex nVertices[MAX_VERTICES];
MicroProfileDrawCommand nCommands[MAX_COMMANDS];
};
MicroProfileDrawContext g_MicroProfileDraw;
#define Q0(d, member, v) d[0].member = v
#define Q1(d, member, v) d[1].member = v; d[3].member = v
#define Q2(d, member, v) d[4].member = v
#define Q3(d, member, v) d[2].member = v; d[5].member = v
#define FONT_TEX_X 1024
#define FONT_TEX_Y 9
#define FONT_SIZE (FONT_TEX_X*FONT_TEX_Y * 4)
namespace
{
extern const uint8_t g_MicroProfileFont[];
extern const uint16_t g_MicroProfileFontDescription[];
extern const char g_MicroProfileVertexShader_110[];
extern const char g_MicroProfileFragmentShader_110[];
extern const char g_MicroProfileVertexShader_150[];
extern const char g_MicroProfileFragmentShader_150[];
}
bool MicroProfileCompileShader(GLuint* pnHandle, int nType, const char* pShader)
{
*pnHandle = glCreateShader(nType);
glShaderSource(*pnHandle, 1, &pShader, 0);
glCompileShader(*pnHandle);
GLint compiled = 0;
glGetShaderiv(*pnHandle, GL_COMPILE_STATUS, &compiled);
if(!compiled)
{
char temp[4096];
glGetShaderInfoLog(*pnHandle, 4096, NULL, temp);
printf("SHADER FAILED TO COMPILE:\n%s\n", temp);
return false;
}
return true;
}
bool MicroProfileLinkProgram(GLuint* pnHandle, GLuint nVertexShader, GLuint nFragmentShader)
{
*pnHandle = glCreateProgram();
glAttachShader(*pnHandle, nVertexShader);
glAttachShader(*pnHandle, nFragmentShader);
glLinkProgram(*pnHandle);
GLint linked = 0;
glGetProgramiv(*pnHandle, GL_LINK_STATUS, &linked);
if(!linked)
{
char temp[4096];
glGetProgramInfoLog(*pnHandle, 4096, NULL, temp);
printf("PROGRAM FAILED TO LINK:\n%s\n", temp);
return false;
}
return true;
}
void MicroProfileDrawInitGL()
{
MicroProfileDrawContext& S = g_MicroProfileDraw;
MP_ASSERT(!S.bInitialized);
const GLubyte* pGLVersion = glGetString(GL_VERSION);
const GLubyte* pGLSLVersion = glGetString(GL_SHADING_LANGUAGE_VERSION);
int nGLVersion = (pGLVersion[0] - '0') * 10 + (pGLVersion[2] - '0');
int nGLSLVersion = (pGLSLVersion[0] - '0') * 100 + (pGLSLVersion[2] - '0') * 10 + (pGLSLVersion[3] - '0');
glGenBuffers(1, &S.nVertexBuffer);
glBindBuffer(GL_ARRAY_BUFFER, S.nVertexBuffer);
glBufferData(GL_ARRAY_BUFFER, sizeof(S.nVertices), 0, GL_STREAM_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
if (nGLVersion >= 3)
glGenVertexArrays(1, &S.nVAO);
else
S.nVAO = 0;
GLuint nVertexShader;
if(!MicroProfileCompileShader(&nVertexShader, GL_VERTEX_SHADER, nGLSLVersion >= 150 ? g_MicroProfileVertexShader_150 : g_MicroProfileVertexShader_110))
return;
GLuint nFragmentShader;
if(!MicroProfileCompileShader(&nFragmentShader, GL_FRAGMENT_SHADER, nGLSLVersion >= 150 ? g_MicroProfileFragmentShader_150 : g_MicroProfileFragmentShader_110))
return;
if(!MicroProfileLinkProgram(&S.nProgram, nVertexShader, nFragmentShader))
return;
S.nAttributePosition = glGetAttribLocation(S.nProgram, "VertexIn");
S.nAttributeColor = glGetAttribLocation(S.nProgram, "ColorIn");
S.nAttributeTexture = glGetAttribLocation(S.nProgram, "TCIn");
S.nUniformProjectionMatrix = glGetUniformLocation(S.nProgram, "ProjectionMatrix");
glUseProgram(S.nProgram);
glUniform1i(glGetUniformLocation(S.nProgram, "Texture"), 0);
glUniform1f(glGetUniformLocation(S.nProgram, "RcpFontHeight"), 1.f / FONT_TEX_Y);
glUseProgram(0);
uint32_t* pUnpacked = (uint32_t*)alloca(FONT_SIZE);
int idx = 0;
int end = FONT_TEX_X * FONT_TEX_Y / 8;
for(int i = 0; i < end; i++)
{
unsigned char pValue = g_MicroProfileFont[i];
for(int j = 0; j < 8; ++j)
{
pUnpacked[idx++] = pValue & 0x80 ? (uint32_t)-1 : 0;
pValue <<= 1;
}
}
pUnpacked[idx-1] = 0xffffffff;
uint32_t* p4 = &pUnpacked[0];
glGenTextures(1, &S.nTexture);
glBindTexture(GL_TEXTURE_2D, S.nTexture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, FONT_TEX_X, FONT_TEX_Y, 0, GL_RGBA, GL_UNSIGNED_BYTE, &p4[0]);
glBindTexture(GL_TEXTURE_2D, 0);
S.bInitialized = true;
}
void MicroProfileBeginDraw(uint32_t nWidth, uint32_t nHeight, float* pfProjection)
{
(void)nWidth;
(void)nHeight;
MicroProfileDrawContext& S = g_MicroProfileDraw;
if (!S.bInitialized)
return;
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDisable(GL_DEPTH_TEST);
glDisable(GL_CULL_FACE);
if (S.nVAO)
glBindVertexArray(S.nVAO);
glUseProgram(S.nProgram);
glUniformMatrix4fv(S.nUniformProjectionMatrix, 1, 0, pfProjection);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, S.nTexture);
glBindBuffer(GL_ARRAY_BUFFER, S.nVertexBuffer);
int nStride = sizeof(MicroProfileDrawVertex);
glVertexAttribPointer(S.nAttributePosition, 2, GL_FLOAT, 0, nStride, (void*)(offsetof(MicroProfileDrawVertex, nX)));
glVertexAttribPointer(S.nAttributeColor, 4, GL_UNSIGNED_BYTE, GL_TRUE, nStride, (void*)(offsetof(MicroProfileDrawVertex, nColor)));
glVertexAttribPointer(S.nAttributeTexture, 2, GL_FLOAT, 0, nStride, (void*)(offsetof(MicroProfileDrawVertex, fU)));
glEnableVertexAttribArray(S.nAttributePosition);
glEnableVertexAttribArray(S.nAttributeColor);
glEnableVertexAttribArray(S.nAttributeTexture);
S.nVertexPos = 0;
S.nCommandPos = 0;
}
void MicroProfileBeginDraw(uint32_t nWidth, uint32_t nHeight, float fScale)
{
MicroProfileDrawContext& S = g_MicroProfileDraw;
if (!S.bInitialized)
return;
float left = 0.f;
float right = nWidth / fScale;
float bottom = nHeight / fScale;
float top = 0.f;
float near_plane = -1.f;
float far_plane = 1.f;
float projection[16] = {};
projection[0] = 2.0f / (right - left);
projection[5] = 2.0f / (top - bottom);
projection[10] = -2.0f / (far_plane - near_plane);
projection[12] = - (right + left) / (right - left);
projection[13] = - (top + bottom) / (top - bottom);
projection[14] = - (far_plane + near_plane) / (far_plane - near_plane);
projection[15] = 1.f;
MicroProfileBeginDraw(nWidth, nHeight, projection);
}
void MicroProfileFlush()
{
MicroProfileDrawContext& S = g_MicroProfileDraw;
if(S.nVertexPos == 0)
return;
MICROPROFILE_SCOPEI("MicroProfile", "Flush", 0xffff3456);
glBufferSubData(GL_ARRAY_BUFFER, 0, S.nVertexPos * sizeof(MicroProfileDrawVertex), S.nVertices);
int nOffset = 0;
for(int i = 0; i < int(S.nCommandPos); ++i)
{
int nCount = S.nCommands[i].nNumVertices;
glDrawArrays(S.nCommands[i].nCommand, nOffset, nCount);
nOffset += nCount;
}
S.nVertexPos = 0;
S.nCommandPos = 0;
}
MicroProfileDrawVertex* MicroProfilePushVertices(uint32_t nCommand, int nCount)
{
MP_ASSERT(nCount <= MicroProfileDrawContext::MAX_VERTICES);
MicroProfileDrawContext& S = g_MicroProfileDraw;
if(S.nVertexPos + nCount > MicroProfileDrawContext::MAX_VERTICES)
MicroProfileFlush();
if(S.nCommandPos && S.nCommands[S.nCommandPos-1].nCommand == nCommand)
{
S.nCommands[S.nCommandPos-1].nNumVertices += nCount;
}
else
{
if (S.nCommandPos == MicroProfileDrawContext::MAX_COMMANDS)
MicroProfileFlush();
S.nCommands[S.nCommandPos].nCommand = nCommand;
S.nCommands[S.nCommandPos].nNumVertices = nCount;
S.nCommandPos++;
}
uint32_t nOut = S.nVertexPos;
S.nVertexPos += nCount;
return &S.nVertices[nOut];
}
void MicroProfileEndDraw()
{
MicroProfileDrawContext& S = g_MicroProfileDraw;
if (!S.bInitialized)
return;
MicroProfileFlush();
glDisableVertexAttribArray(S.nAttributePosition);
glDisableVertexAttribArray(S.nAttributeColor);
glDisableVertexAttribArray(S.nAttributeTexture);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glUseProgram(0);
if (S.nVAO)
glBindVertexArray(0);
glDisable(GL_BLEND);
}
void MicroProfileRender(uint32_t nWidth, uint32_t nHeight, float fScale)
{
MicroProfileBeginDraw(nWidth, nHeight, fScale);
MicroProfileDraw(nWidth, nHeight);
MicroProfileEndDraw();
}
void MicroProfileDrawText(int nX, int nY, uint32_t nColor, const char* pText, uint32_t nLen)
{
MICROPROFILE_SCOPEI("MicroProfile", "TextDraw", 0xff88ee);
const float fOffsetU = 5.f / 1024.f;
MP_ASSERT(nLen <= strlen(pText));
float fX = (float)nX;
float fY = (float)nY;
float fY2 = fY + (MICROPROFILE_TEXT_HEIGHT+1);
MicroProfileDrawVertex* pVertex = MicroProfilePushVertices(GL_TRIANGLES, 6 * nLen);
if (!pVertex) return;
const char* pStr = pText;
nColor = 0xff000000|((nColor&0xff)<<16)|(nColor&0xff00)|((nColor>>16)&0xff);
for(uint32_t j = 0; j < nLen; ++j)
{
int16_t nOffset = g_MicroProfileFontDescription[uint8_t(*pStr++)];
float fOffset = nOffset / 1024.f;
Q0(pVertex,nX, fX);
Q0(pVertex,nY, fY);
Q0(pVertex,nColor, nColor);
Q0(pVertex,fU, fOffset);
Q0(pVertex,fV, 0.f);
Q1(pVertex, nX, fX+MICROPROFILE_TEXT_WIDTH);
Q1(pVertex, nY, fY);
Q1(pVertex, nColor, nColor);
Q1(pVertex, fU, fOffset+fOffsetU);
Q1(pVertex, fV, 0.f);
Q2(pVertex, nX, fX+MICROPROFILE_TEXT_WIDTH);
Q2(pVertex, nY, fY2);
Q2(pVertex, nColor, nColor);
Q2(pVertex, fU, fOffset+fOffsetU);
Q2(pVertex, fV, 1.f);
Q3(pVertex, nX, fX);
Q3(pVertex, nY, fY2);
Q3(pVertex, nColor, nColor);
Q3(pVertex, fU, fOffset);
Q3(pVertex, fV, 1.f);
fX += MICROPROFILE_TEXT_WIDTH+1;
pVertex += 6;
}
}
void MicroProfileDrawBox(int nX0, int nY0, int nX1, int nY1, uint32_t nColor, MicroProfileBoxType Type)
{
MicroProfileDrawVertex* pVertex = MicroProfilePushVertices(GL_TRIANGLES, 6);
if (!pVertex) return;
if(Type == MicroProfileBoxTypeFlat)
{
nColor = ((nColor&0xff)<<16)|((nColor>>16)&0xff)|(0xff00ff00&nColor);
Q0(pVertex, nX, (float)nX0);
Q0(pVertex, nY, (float)nY0);
Q0(pVertex, nColor, nColor);
Q0(pVertex, fU, 2.f);
Q0(pVertex, fV, 2.f);
Q1(pVertex, nX, (float)nX1);
Q1(pVertex, nY, (float)nY0);
Q1(pVertex, nColor, nColor);
Q1(pVertex, fU, 2.f);
Q1(pVertex, fV, 2.f);
Q2(pVertex, nX, (float)nX1);
Q2(pVertex, nY, (float)nY1);
Q2(pVertex, nColor, nColor);
Q2(pVertex, fU, 2.f);
Q2(pVertex, fV, 2.f);
Q3(pVertex, nX, (float)nX0);
Q3(pVertex, nY, (float)nY1);
Q3(pVertex, nColor, nColor);
Q3(pVertex, fU, 2.f);
Q3(pVertex, fV, 2.f);
}
else
{
uint32_t r = 0xff & (nColor>>16);
uint32_t g = 0xff & (nColor>>8);
uint32_t b = 0xff & nColor;
uint32_t nMax = MicroProfileMax(MicroProfileMax(MicroProfileMax(r, g), b), 30u);
uint32_t nMin = MicroProfileMin(MicroProfileMin(MicroProfileMin(r, g), b), 180u);
uint32_t r0 = 0xff & ((r + nMax)/2);
uint32_t g0 = 0xff & ((g + nMax)/2);
uint32_t b0 = 0xff & ((b + nMax)/2);
uint32_t r1 = 0xff & ((r+nMin)/2);
uint32_t g1 = 0xff & ((g+nMin)/2);
uint32_t b1 = 0xff & ((b+nMin)/2);
uint32_t nColor0 = (r0<<0)|(g0<<8)|(b0<<16)|(0xff000000&nColor);
uint32_t nColor1 = (r1<<0)|(g1<<8)|(b1<<16)|(0xff000000&nColor);
Q0(pVertex, nX, (float)nX0);
Q0(pVertex, nY, (float)nY0);
Q0(pVertex, nColor, nColor0);
Q0(pVertex, fU, 2.f);
Q0(pVertex, fV, 2.f);
Q1(pVertex, nX, (float)nX1);
Q1(pVertex, nY, (float)nY0);
Q1(pVertex, nColor, nColor0);
Q1(pVertex, fU, 3.f);
Q1(pVertex, fV, 2.f);
Q2(pVertex, nX, (float)nX1);
Q2(pVertex, nY, (float)nY1);
Q2(pVertex, nColor, nColor1);
Q2(pVertex, fU, 3.f);
Q2(pVertex, fV, 3.f);
Q3(pVertex, nX, (float)nX0);
Q3(pVertex, nY, (float)nY1);
Q3(pVertex, nColor, nColor1);
Q3(pVertex, fU, 2.f);
Q3(pVertex, fV, 3.f);
}
}
void MicroProfileDrawLine2D(uint32_t nVertices, float* pVertices, uint32_t nColor)
{
if(!nVertices) return;
MicroProfileDrawVertex* pVertex = MicroProfilePushVertices(GL_LINES, 2*(nVertices-1));
nColor = ((nColor&0xff)<<16)|(nColor&0xff00ff00)|((nColor>>16)&0xff);
for(uint32_t i = 0; i < nVertices-1; ++i)
{
pVertex[0].nX = pVertices[i*2];
pVertex[0].nY = pVertices[i*2+1] ;
pVertex[0].nColor = nColor;
pVertex[0].fU = 2.f;
pVertex[0].fV = 2.f;
pVertex[1].nX = pVertices[(i+1)*2];
pVertex[1].nY = pVertices[(i+1)*2+1] ;
pVertex[1].nColor = nColor;
pVertex[1].fU = 2.f;
pVertex[1].fV = 2.f;
pVertex += 2;
}
}
namespace
{
const char g_MicroProfileVertexShader_110[] =
"#version 110\n\
uniform mat4 ProjectionMatrix; \
attribute vec3 VertexIn; attribute vec4 ColorIn; attribute vec2 TCIn; \
varying vec2 TC; varying vec4 Color; \
void main() { Color = ColorIn; TC = TCIn; gl_Position = ProjectionMatrix * vec4(VertexIn, 1.0); }";
const char g_MicroProfileVertexShader_150[] =
"#version 150\n\
uniform mat4 ProjectionMatrix; \
in vec3 VertexIn; in vec4 ColorIn; in vec2 TCIn; \
out vec2 TC; out vec4 Color; \
void main() { Color = ColorIn; TC = TCIn; gl_Position = ProjectionMatrix * vec4(VertexIn, 1.0); }";
const char g_MicroProfileFragmentShader_110[] =
"#version 110\n\
uniform sampler2D Texture; uniform float RcpFontHeight; \
varying vec2 TC; varying vec4 Color; \
void main() { \
vec4 c0 = texture2D(Texture, TC.xy); \
vec4 c1 = texture2D(Texture, TC.xy + vec2(0.0, RcpFontHeight)); \
gl_FragColor = c0.w < 0.5 ? vec4(0, 0, 0, c1.w) : c0 * Color; \
} \
";
const char g_MicroProfileFragmentShader_150[] =
"#version 150\n\
uniform sampler2D Texture; uniform float RcpFontHeight; \
in vec2 TC; in vec4 Color; \
out vec4 result; \
void main() { \
vec4 c0 = texture(Texture, TC.xy); \
vec4 c1 = texture(Texture, TC.xy + vec2(0.0, RcpFontHeight)); \
result = c0.w < 0.5 ? vec4(0, 0, 0, c1.w) : c0 * Color; \
} \
";
const uint16_t g_MicroProfileFontDescription[] =
{
0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,
0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,
0x0ce,0x201,0x209,0x211,0x219,0x221,0x229,0x231,0x239,0x241,0x249,0x251,0x259,0x261,0x269,0x271,
0x1b1,0x1b9,0x1c1,0x1c9,0x1d1,0x1d9,0x1e1,0x1e9,0x1f1,0x1f9,0x279,0x281,0x289,0x291,0x299,0x2a1,
0x2a9,0x001,0x009,0x011,0x019,0x021,0x029,0x031,0x039,0x041,0x049,0x051,0x059,0x061,0x069,0x071,
0x079,0x081,0x089,0x091,0x099,0x0a1,0x0a9,0x0b1,0x0b9,0x0c1,0x0c9,0x2b1,0x2b9,0x2c1,0x2c9,0x2d1,
0x0ce,0x0d9,0x0e1,0x0e9,0x0f1,0x0f9,0x101,0x109,0x111,0x119,0x121,0x129,0x131,0x139,0x141,0x149,
0x151,0x159,0x161,0x169,0x171,0x179,0x181,0x189,0x191,0x199,0x1a1,0x2d9,0x2e1,0x2e9,0x2f1,0x0ce,
0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,
0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,
0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,
0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,
0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,
0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,
0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,
0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,0x0ce,
};
const uint8_t g_MicroProfileFont[] =
{
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x10,0x78,0x38,0x78,0x7c,0x7c,0x3c,0x44,0x38,0x04,0x44,0x40,0x44,0x44,0x38,0x78,
0x38,0x78,0x38,0x7c,0x44,0x44,0x44,0x44,0x44,0x7c,0x00,0x00,0x40,0x00,0x04,0x00,
0x18,0x00,0x40,0x10,0x08,0x40,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x10,0x38,0x7c,0x08,0x7c,0x1c,0x7c,0x38,0x38,
0x10,0x28,0x28,0x10,0x00,0x20,0x10,0x08,0x10,0x10,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x04,0x00,0x20,0x38,0x38,0x70,0x00,0x1c,0x10,0x00,0x1c,0x10,0x70,0x30,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x28,0x44,0x44,0x44,0x40,0x40,0x40,0x44,0x10,0x04,0x48,0x40,0x6c,0x44,0x44,0x44,
0x44,0x44,0x44,0x10,0x44,0x44,0x44,0x44,0x44,0x04,0x00,0x00,0x40,0x00,0x04,0x00,
0x24,0x00,0x40,0x00,0x00,0x40,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x44,0x30,0x44,0x04,0x18,0x40,0x20,0x04,0x44,0x44,
0x10,0x28,0x28,0x3c,0x44,0x50,0x10,0x10,0x08,0x54,0x10,0x00,0x00,0x00,0x04,0x00,
0x00,0x08,0x00,0x10,0x44,0x44,0x40,0x40,0x04,0x28,0x00,0x30,0x10,0x18,0x58,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x44,0x44,0x40,0x44,0x40,0x40,0x40,0x44,0x10,0x04,0x50,0x40,0x54,0x64,0x44,0x44,
0x44,0x44,0x40,0x10,0x44,0x44,0x44,0x28,0x28,0x08,0x00,0x38,0x78,0x3c,0x3c,0x38,
0x20,0x38,0x78,0x30,0x18,0x44,0x10,0x6c,0x78,0x38,0x78,0x3c,0x5c,0x3c,0x3c,0x44,
0x44,0x44,0x44,0x44,0x7c,0x00,0x4c,0x10,0x04,0x08,0x28,0x78,0x40,0x08,0x44,0x44,
0x10,0x00,0x7c,0x50,0x08,0x50,0x00,0x20,0x04,0x38,0x10,0x00,0x00,0x00,0x08,0x10,
0x10,0x10,0x7c,0x08,0x08,0x54,0x40,0x20,0x04,0x44,0x00,0x30,0x10,0x18,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x44,0x78,0x40,0x44,0x78,0x78,0x40,0x7c,0x10,0x04,0x60,0x40,0x54,0x54,0x44,0x78,
0x44,0x78,0x38,0x10,0x44,0x44,0x54,0x10,0x10,0x10,0x00,0x04,0x44,0x40,0x44,0x44,
0x78,0x44,0x44,0x10,0x08,0x48,0x10,0x54,0x44,0x44,0x44,0x44,0x60,0x40,0x10,0x44,
0x44,0x44,0x28,0x44,0x08,0x00,0x54,0x10,0x18,0x18,0x48,0x04,0x78,0x10,0x38,0x3c,
0x10,0x00,0x28,0x38,0x10,0x20,0x00,0x20,0x04,0x10,0x7c,0x00,0x7c,0x00,0x10,0x00,
0x00,0x20,0x00,0x04,0x10,0x5c,0x40,0x10,0x04,0x00,0x00,0x60,0x10,0x0c,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x7c,0x44,0x40,0x44,0x40,0x40,0x4c,0x44,0x10,0x04,0x50,0x40,0x44,0x4c,0x44,0x40,
0x54,0x50,0x04,0x10,0x44,0x44,0x54,0x28,0x10,0x20,0x00,0x3c,0x44,0x40,0x44,0x7c,
0x20,0x44,0x44,0x10,0x08,0x70,0x10,0x54,0x44,0x44,0x44,0x44,0x40,0x38,0x10,0x44,
0x44,0x54,0x10,0x44,0x10,0x00,0x64,0x10,0x20,0x04,0x7c,0x04,0x44,0x20,0x44,0x04,
0x10,0x00,0x7c,0x14,0x20,0x54,0x00,0x20,0x04,0x38,0x10,0x10,0x00,0x00,0x20,0x10,
0x10,0x10,0x7c,0x08,0x10,0x58,0x40,0x08,0x04,0x00,0x00,0x30,0x10,0x18,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x44,0x44,0x44,0x44,0x40,0x40,0x44,0x44,0x10,0x44,0x48,0x40,0x44,0x44,0x44,0x40,
0x48,0x48,0x44,0x10,0x44,0x28,0x6c,0x44,0x10,0x40,0x00,0x44,0x44,0x40,0x44,0x40,
0x20,0x3c,0x44,0x10,0x08,0x48,0x10,0x54,0x44,0x44,0x44,0x44,0x40,0x04,0x12,0x4c,
0x28,0x54,0x28,0x3c,0x20,0x00,0x44,0x10,0x40,0x44,0x08,0x44,0x44,0x20,0x44,0x08,
0x00,0x00,0x28,0x78,0x44,0x48,0x00,0x10,0x08,0x54,0x10,0x10,0x00,0x00,0x40,0x00,
0x10,0x08,0x00,0x10,0x00,0x40,0x40,0x04,0x04,0x00,0x00,0x30,0x10,0x18,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x44,0x78,0x38,0x78,0x7c,0x40,0x3c,0x44,0x38,0x38,0x44,0x7c,0x44,0x44,0x38,0x40,
0x34,0x44,0x38,0x10,0x38,0x10,0x44,0x44,0x10,0x7c,0x00,0x3c,0x78,0x3c,0x3c,0x3c,
0x20,0x04,0x44,0x38,0x48,0x44,0x38,0x44,0x44,0x38,0x78,0x3c,0x40,0x78,0x0c,0x34,
0x10,0x6c,0x44,0x04,0x7c,0x00,0x38,0x38,0x7c,0x38,0x08,0x38,0x38,0x20,0x38,0x70,
0x10,0x00,0x28,0x10,0x00,0x34,0x00,0x08,0x10,0x10,0x00,0x20,0x00,0x10,0x00,0x00,
0x20,0x04,0x00,0x20,0x10,0x3c,0x70,0x00,0x1c,0x00,0x7c,0x1c,0x10,0x70,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x38,0x00,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x40,0x04,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
}
#endif
#endif