mirror of
https://github.com/Drezil/imgui.git
synced 2025-03-27 22:42:43 +00:00
Moved IMGUI_FONT_TEX_UV_FOR_WHITE define to a variable so font can be changed at runtime
This commit is contained in:
parent
88c33ecc29
commit
7adad71042
@ -105,7 +105,7 @@
|
|||||||
|
|
||||||
- if you want to use a different font than the default
|
- 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
|
- 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: 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.
|
- 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";
|
IniFilename = "imgui.ini";
|
||||||
LogFilename = "imgui_log.txt";
|
LogFilename = "imgui_log.txt";
|
||||||
Font = NULL;
|
Font = NULL;
|
||||||
|
FontTexUvForWhite = ImVec2(0.0f,0.0f);
|
||||||
FontAllowScaling = false;
|
FontAllowScaling = false;
|
||||||
PixelCenterOffset = 0.0f;
|
PixelCenterOffset = 0.0f;
|
||||||
MousePos = ImVec2(-1,-1);
|
MousePos = ImVec2(-1,-1);
|
||||||
@ -4812,7 +4813,7 @@ void ImDrawList::AddVtx(const ImVec2& pos, ImU32 col)
|
|||||||
{
|
{
|
||||||
vtx_write->pos = pos;
|
vtx_write->pos = pos;
|
||||||
vtx_write->col = col;
|
vtx_write->col = col;
|
||||||
vtx_write->uv = IMGUI_FONT_TEX_UV_FOR_WHITE;
|
vtx_write->uv = GImGui.IO.FontTexUvForWhite;
|
||||||
vtx_write++;
|
vtx_write++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
5
imgui.h
5
imgui.h
@ -390,6 +390,7 @@ struct ImGuiIO
|
|||||||
int KeyMap[ImGuiKey_COUNT]; // <unset> // Map of indices into the KeysDown[512] entries array
|
int KeyMap[ImGuiKey_COUNT]; // <unset> // Map of indices into the KeysDown[512] entries array
|
||||||
ImFont Font; // <auto> // Gets passed to text functions. Typedef ImFont to the type you want (ImBitmapFont* or your own font).
|
ImFont Font; // <auto> // Gets passed to text functions. Typedef ImFont to the type you want (ImBitmapFont* or your own font).
|
||||||
float FontHeight; // <auto> // Default font height, must be the vertical distance between two lines of text, aka == CalcTextSize(" ").y
|
float FontHeight; // <auto> // Default font height, must be the vertical distance between two lines of text, aka == CalcTextSize(" ").y
|
||||||
|
ImVec2 FontTexUvForWhite; // = (0.0f,0.0f) // Font texture must have a white pixel at this UV coordinate. Adjust if you are using custom texture.
|
||||||
bool FontAllowScaling; // = false // Set to allow scaling text with CTRL+Wheel.
|
bool FontAllowScaling; // = false // Set to allow scaling text with CTRL+Wheel.
|
||||||
float PixelCenterOffset; // = 0.0f // Try to set to 0.5f or 0.375f if rendering is blurry
|
float PixelCenterOffset; // = 0.0f // Try to set to 0.5f or 0.375f if rendering is blurry
|
||||||
|
|
||||||
@ -524,10 +525,6 @@ struct ImDrawCmd
|
|||||||
ImVec4 clip_rect;
|
ImVec4 clip_rect;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef IMGUI_FONT_TEX_UV_FOR_WHITE
|
|
||||||
#define IMGUI_FONT_TEX_UV_FOR_WHITE ImVec2(0.f,0.f)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// sizeof() == 20
|
// sizeof() == 20
|
||||||
struct ImDrawVert
|
struct ImDrawVert
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user