| 339 | } |
| 340 | |
| 341 | static void drawText(float x, float y, const char *text, int align, unsigned int col) |
| 342 | { |
| 343 | if (!text) return; |
| 344 | |
| 345 | if (align == IMGUI_ALIGN_CENTER) |
| 346 | x -= getTextLength(g_cdata, text) / 2; |
| 347 | else if (align == IMGUI_ALIGN_RIGHT) |
| 348 | x -= getTextLength(g_cdata, text); |
| 349 | |
| 350 | imguiGraphColor4ub(col & 0xff, (col >> 8) & 0xff, (col >> 16) & 0xff, (col >> 24) & 0xff); |
| 351 | |
| 352 | imguiGraphFontTextureEnable(); |
| 353 | |
| 354 | // assume orthographic projection with units = screen pixels, origin at top left |
| 355 | const float ox = x; |
| 356 | |
| 357 | while (*text) |
| 358 | { |
| 359 | int c = (unsigned char)*text; |
| 360 | if (c == '\t') |
| 361 | { |
| 362 | for (int i = 0; i < 4; ++i) |
| 363 | { |
| 364 | if (x < g_tabStops[i] + ox) |
| 365 | { |
| 366 | x = g_tabStops[i] + ox; |
| 367 | break; |
| 368 | } |
| 369 | } |
| 370 | } |
| 371 | else if (c >= 32 && c < 128) |
| 372 | { |
| 373 | stbtt_aligned_quad q; |
| 374 | getBakedQuad(g_cdata, 512, 512, c - 32, &x, &y, &q); |
| 375 | |
| 376 | imguiGraphTexCoord2f(q.s0, q.t0); |
| 377 | imguiGraphVertex2f(q.x0, q.y0); |
| 378 | imguiGraphTexCoord2f(q.s1, q.t1); |
| 379 | imguiGraphVertex2f(q.x1, q.y1); |
| 380 | imguiGraphTexCoord2f(q.s1, q.t0); |
| 381 | imguiGraphVertex2f(q.x1, q.y0); |
| 382 | |
| 383 | imguiGraphTexCoord2f(q.s0, q.t0); |
| 384 | imguiGraphVertex2f(q.x0, q.y0); |
| 385 | imguiGraphTexCoord2f(q.s0, q.t1); |
| 386 | imguiGraphVertex2f(q.x0, q.y1); |
| 387 | imguiGraphTexCoord2f(q.s1, q.t1); |
| 388 | imguiGraphVertex2f(q.x1, q.y1); |
| 389 | } |
| 390 | ++text; |
| 391 | } |
| 392 | |
| 393 | imguiGraphFontTextureDisable(); |
| 394 | } |
| 395 | |
| 396 | |
| 397 | void imguiGraphDraw() |
no test coverage detected