mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-21 19:37:01 +00:00
Added PixelCenterOffset for OpenGL/DirectX compatibility.
This commit is contained in:
parent
680a5a9b54
commit
8ab2942716
@ -293,6 +293,7 @@ void InitImGui()
|
||||
io.KeyMap[ImGuiKey_X] = 'X';
|
||||
io.KeyMap[ImGuiKey_Y] = 'Y';
|
||||
io.KeyMap[ImGuiKey_Z] = 'Z';
|
||||
io.PixelCenterOffset = 0.0f;
|
||||
|
||||
io.RenderDrawListsFn = ImImpl_RenderDrawLists;
|
||||
io.SetClipboardTextFn = ImImpl_SetClipboardTextFn;
|
||||
|
@ -297,6 +297,7 @@ void InitImGui()
|
||||
io.KeyMap[ImGuiKey_X] = GLFW_KEY_X;
|
||||
io.KeyMap[ImGuiKey_Y] = GLFW_KEY_Y;
|
||||
io.KeyMap[ImGuiKey_Z] = GLFW_KEY_Z;
|
||||
io.PixelCenterOffset = 0.5f;
|
||||
|
||||
io.RenderDrawListsFn = ImImpl_RenderDrawLists;
|
||||
io.SetClipboardTextFn = ImImpl_SetClipboardTextFn;
|
||||
|
11
imgui.cpp
11
imgui.cpp
@ -262,6 +262,7 @@ ImGuiIO::ImGuiIO()
|
||||
LogFilename = "imgui_log.txt";
|
||||
Font = NULL;
|
||||
FontAllowScaling = false;
|
||||
PixelCenterOffset = 0.5f;
|
||||
MousePos = ImVec2(-1,-1);
|
||||
MousePosPrev = ImVec2(-1,-1);
|
||||
MouseDoubleClickTime = 0.30f;
|
||||
@ -5003,6 +5004,8 @@ void ImBitmapFont::RenderText(float size, ImVec2 pos, ImU32 col, const ImVec4& c
|
||||
float line_width = 0.0f;
|
||||
const ImVec4 clip_rect = clip_rect_ref;
|
||||
|
||||
const float uv_offset = GImGui.IO.PixelCenterOffset;
|
||||
|
||||
float x = pos.x;
|
||||
float y = pos.y;
|
||||
for (const char* s = text_begin; s < text_end; s++)
|
||||
@ -5039,10 +5042,10 @@ void ImBitmapFont::RenderText(float size, ImVec2 pos, ImU32 col, const ImVec4& c
|
||||
continue;
|
||||
}
|
||||
|
||||
const float s1 = (0.0f + glyph->X) * tex_scale_x;
|
||||
const float t1 = (0.0f + glyph->Y) * tex_scale_y;
|
||||
const float s2 = (0.0f + glyph->X + glyph->Width) * tex_scale_x;
|
||||
const float t2 = (0.0f + glyph->Y + glyph->Height) * tex_scale_y;
|
||||
const float s1 = (uv_offset + glyph->X) * tex_scale_x;
|
||||
const float t1 = (uv_offset + glyph->Y) * tex_scale_y;
|
||||
const float s2 = (uv_offset + glyph->X + glyph->Width) * tex_scale_x;
|
||||
const float t2 = (uv_offset + glyph->Y + glyph->Height) * tex_scale_y;
|
||||
|
||||
out_vertices[0].pos = ImVec2(x1, y1);
|
||||
out_vertices[0].uv = ImVec2(s1, t1);
|
||||
|
1
imgui.h
1
imgui.h
@ -373,6 +373,7 @@ struct ImGuiIO
|
||||
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
|
||||
bool FontAllowScaling; // = false // Set to allow scaling text with CTRL+Wheel.
|
||||
float PixelCenterOffset; // = 0.5f // Set to 0.0f for DirectX <= 9, 0.5f for Direct3D >= 10 and OpenGL.
|
||||
|
||||
// Settings - Functions (fill once)
|
||||
void (*RenderDrawListsFn)(ImDrawList** const draw_lists, int count); // Required
|
||||
|
Loading…
Reference in New Issue
Block a user