Moved IMGUI_FONT_TEX_UV_FOR_WHITE define to a variable so font can be changed at runtime

This commit is contained in:
ocornut
2014-08-28 14:53:41 +01:00
parent 88c33ecc29
commit 7adad71042
2 changed files with 4 additions and 6 deletions

View File

@ -105,7 +105,7 @@
- if you want to use a different font than the default
- create bitmap font data using BMFont. allocate ImGui::GetIO().Font and use ->LoadFromFile()/LoadFromMemory(), set ImGui::GetIO().FontHeight
- load your texture yourself. texture *MUST* have white pixel at UV coordinate 'IMGUI_FONT_TEX_UV_FOR_WHITE' (you can #define it in imconfig.h), this is used by solid objects.
- load your texture yourself. texture *MUST* have white pixel at UV coordinate Imgui::GetIO().FontTexUvForWhite. This is used to draw all solid shapes.
- tip: the construct 'if (IMGUI_ONCE_UPON_A_FRAME)' will evaluate to true only once a frame, you can use it to add custom UI in the middle of a deep nested inner loop in your code.
- tip: you can call Render() multiple times (e.g for VR renders), up to you to communicate the extra state to your RenderDrawListFn function.
@ -279,6 +279,7 @@ ImGuiIO::ImGuiIO()
IniFilename = "imgui.ini";
LogFilename = "imgui_log.txt";
Font = NULL;
FontTexUvForWhite = ImVec2(0.0f,0.0f);
FontAllowScaling = false;
PixelCenterOffset = 0.0f;
MousePos = ImVec2(-1,-1);
@ -4812,7 +4813,7 @@ void ImDrawList::AddVtx(const ImVec2& pos, ImU32 col)
{
vtx_write->pos = pos;
vtx_write->col = col;
vtx_write->uv = IMGUI_FONT_TEX_UV_FOR_WHITE;
vtx_write->uv = GImGui.IO.FontTexUvForWhite;
vtx_write++;
}