| 3474 | } |
| 3475 | |
| 3476 | static void ImFontAtlasBuildUpdateBasicTexData(ImFontAtlas* atlas) |
| 3477 | { |
| 3478 | // Pack and store identifier so we can refresh UV coordinates on texture resize. |
| 3479 | // FIXME-NEWATLAS: User/custom rects where user code wants to store UV coordinates will need to do the same thing. |
| 3480 | ImFontAtlasBuilder* builder = atlas->Builder; |
| 3481 | ImVec2i pack_size = (atlas->Flags & ImFontAtlasFlags_NoMouseCursors) ? ImVec2i(2, 2) : ImVec2i(FONT_ATLAS_DEFAULT_TEX_DATA_W * 2 + 1, FONT_ATLAS_DEFAULT_TEX_DATA_H); |
| 3482 | |
| 3483 | ImFontAtlasRect r; |
| 3484 | bool add_and_draw = (atlas->GetCustomRect(builder->PackIdMouseCursors, &r) == false); |
| 3485 | if (add_and_draw) |
| 3486 | { |
| 3487 | builder->PackIdMouseCursors = atlas->AddCustomRect(pack_size.x, pack_size.y, &r); |
| 3488 | IM_ASSERT(builder->PackIdMouseCursors != ImFontAtlasRectId_Invalid); |
| 3489 | |
| 3490 | // Draw to texture |
| 3491 | if (atlas->Flags & ImFontAtlasFlags_NoMouseCursors) |
| 3492 | { |
| 3493 | // 2x2 white pixels |
| 3494 | ImFontAtlasBuildRenderBitmapFromString(atlas, r.x, r.y, 2, 2, "XX" "XX", 'X'); |
| 3495 | } |
| 3496 | else |
| 3497 | { |
| 3498 | // 2x2 white pixels + mouse cursors |
| 3499 | const int x_for_white = r.x; |
| 3500 | const int x_for_black = r.x + FONT_ATLAS_DEFAULT_TEX_DATA_W + 1; |
| 3501 | ImFontAtlasBuildRenderBitmapFromString(atlas, x_for_white, r.y, FONT_ATLAS_DEFAULT_TEX_DATA_W, FONT_ATLAS_DEFAULT_TEX_DATA_H, FONT_ATLAS_DEFAULT_TEX_DATA_PIXELS, '.'); |
| 3502 | ImFontAtlasBuildRenderBitmapFromString(atlas, x_for_black, r.y, FONT_ATLAS_DEFAULT_TEX_DATA_W, FONT_ATLAS_DEFAULT_TEX_DATA_H, FONT_ATLAS_DEFAULT_TEX_DATA_PIXELS, 'X'); |
| 3503 | } |
| 3504 | } |
| 3505 | |
| 3506 | // Refresh UV coordinates |
| 3507 | atlas->TexUvWhitePixel = ImVec2((r.x + 0.5f) * atlas->TexUvScale.x, (r.y + 0.5f) * atlas->TexUvScale.y); |
| 3508 | } |
| 3509 | |
| 3510 | static void ImFontAtlasBuildUpdateLinesTexData(ImFontAtlas* atlas) |
| 3511 | { |
no test coverage detected