Fixed imgui font pixel center.
This commit is contained in:
parent
8155b139f6
commit
ce3eded6a3
12
3rdparty/ocornut-imgui/imgui.cpp
vendored
12
3rdparty/ocornut-imgui/imgui.cpp
vendored
@ -658,6 +658,7 @@ ImGuiIO::ImGuiIO()
|
||||
DisplaySize = ImVec2(-1.0f, -1.0f);
|
||||
DeltaTime = 1.0f/60.0f;
|
||||
IniSavingRate = 5.0f;
|
||||
PixelCenterOffset = 0.5f;
|
||||
IniFilename = "imgui.ini";
|
||||
LogFilename = "imgui_log.txt";
|
||||
Fonts = &GDefaultFontAtlas;
|
||||
@ -9180,6 +9181,9 @@ bool ImFontAtlas::Build()
|
||||
ImGui::MemFree(buf_rects);
|
||||
buf_rects = NULL;
|
||||
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
const float PixelCenterOffset = io.PixelCenterOffset;
|
||||
|
||||
// Third pass: setup ImFont and glyphs for runtime
|
||||
for (size_t input_i = 0; input_i < InputData.size(); input_i++)
|
||||
{
|
||||
@ -9213,10 +9217,10 @@ bool ImFontAtlas::Build()
|
||||
glyph.XOffset = (signed short)(pc.xoff);
|
||||
glyph.YOffset = (signed short)(pc.yoff + (int)(font_ascent * font_scale));
|
||||
glyph.XAdvance = (signed short)(pc.xadvance + character_spacing_x); // Bake spacing into XAdvance
|
||||
glyph.U0 = ((float)pc.x0 - 0.5f) * uv_scale_x;
|
||||
glyph.V0 = ((float)pc.y0 - 0.5f) * uv_scale_y;
|
||||
glyph.U1 = ((float)pc.x0 - 0.5f + glyph.Width) * uv_scale_x;
|
||||
glyph.V1 = ((float)pc.y0 - 0.5f + glyph.Height) * uv_scale_y;
|
||||
glyph.U0 = ((float)pc.x0 - PixelCenterOffset) * uv_scale_x;
|
||||
glyph.V0 = ((float)pc.y0 - PixelCenterOffset) * uv_scale_y;
|
||||
glyph.U1 = ((float)pc.x0 - PixelCenterOffset + glyph.Width) * uv_scale_x;
|
||||
glyph.V1 = ((float)pc.y0 - PixelCenterOffset + glyph.Height) * uv_scale_y;
|
||||
}
|
||||
}
|
||||
|
||||
|
1
3rdparty/ocornut-imgui/imgui.h
vendored
1
3rdparty/ocornut-imgui/imgui.h
vendored
@ -609,6 +609,7 @@ struct ImGuiIO
|
||||
ImVec2 DisplaySize; // <unset> // Display size, in pixels. For clamping windows positions.
|
||||
float DeltaTime; // = 1.0f/60.0f // Time elapsed since last frame, in seconds.
|
||||
float IniSavingRate; // = 5.0f // Maximum time between saving positions/sizes to .ini file, in seconds.
|
||||
float PixelCenterOffset; // = 0.5f; // Pixel center offset for font texture.
|
||||
const char* IniFilename; // = "imgui.ini" // Path to .ini file. NULL to disable .ini saving.
|
||||
const char* LogFilename; // = "imgui_log.txt" // Path to .log file (default parameter to ImGui::LogToFile when no file is specified).
|
||||
float MouseDoubleClickTime; // = 0.30f // Time for a double-click, in seconds.
|
||||
|
@ -108,7 +108,7 @@ struct OcornutImguiContext
|
||||
io.DisplaySize = ImVec2(1280.0f, 720.0f);
|
||||
io.DeltaTime = 1.0f / 60.0f;
|
||||
io.IniFilename = NULL;
|
||||
// io.PixelCenterOffset = bgfx::RendererType::Direct3D9 == bgfx::getRendererType() ? -0.5f : 0.0f;
|
||||
io.PixelCenterOffset = bgfx::RendererType::Direct3D9 == bgfx::getRendererType() ? 0.0f : 0.5f;
|
||||
|
||||
for (uint32_t ii = 0; ii < ImGuiKey_COUNT; ++ii)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user