Fix Bug When Resizing ImGui
This commit is contained in:
parent
890bd537b2
commit
a740814354
@ -90,6 +90,7 @@ void Frame::setup_style(const float scale) {
|
|||||||
font_cfg.FontDataOwnedByAtlas = false;
|
font_cfg.FontDataOwnedByAtlas = false;
|
||||||
io.Fonts->AddFontFromMemoryTTF(Roboto_Medium_ttf, int(Roboto_Medium_ttf_len), std::floor(20.0f * scale), &font_cfg);
|
io.Fonts->AddFontFromMemoryTTF(Roboto_Medium_ttf, int(Roboto_Medium_ttf_len), std::floor(20.0f * scale), &font_cfg);
|
||||||
monospace = io.Fonts->AddFontFromMemoryTTF(Cousine_Regular_ttf, int(Cousine_Regular_ttf_len), std::floor(18.0f * scale), &font_cfg);
|
monospace = io.Fonts->AddFontFromMemoryTTF(Cousine_Regular_ttf, int(Cousine_Regular_ttf_len), std::floor(18.0f * scale), &font_cfg);
|
||||||
|
ImGui_ImplOpenGL2_DestroyFontsTexture();
|
||||||
// Style
|
// Style
|
||||||
ImGuiStyle &style = ImGui::GetStyle();
|
ImGuiStyle &style = ImGui::GetStyle();
|
||||||
style = ImGuiStyle();
|
style = ImGuiStyle();
|
||||||
|
@ -46,23 +46,37 @@ void cleanup_glfw(GLFWwindow *window) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Framebuffer Scaling
|
// Framebuffer Scaling
|
||||||
void get_glfw_scale(GLFWwindow *window, float *x_scale, float *y_scale) {
|
void get_glfw_scale(GLFWwindow *window, float *x_scale_ptr, float *y_scale_ptr) {
|
||||||
|
// Output
|
||||||
|
float x_scale;
|
||||||
|
float y_scale;
|
||||||
|
|
||||||
|
// Default
|
||||||
|
x_scale = y_scale = 1.0f;
|
||||||
|
|
||||||
|
// Detect Platform
|
||||||
|
if (glfwGetPlatform() == GLFW_PLATFORM_X11) {
|
||||||
|
// X11 Has No Scaling
|
||||||
|
} else {
|
||||||
// Get Window Size
|
// Get Window Size
|
||||||
int window_width;
|
int window_width;
|
||||||
int window_height;
|
int window_height;
|
||||||
glfwGetWindowSize(window, &window_width, &window_height);
|
glfwGetWindowSize(window, &window_width, &window_height);
|
||||||
if (window_width <= 0 || window_height <= 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// Get Framebuffer Size
|
// Get Framebuffer Size
|
||||||
int framebuffer_width;
|
int framebuffer_width;
|
||||||
int framebuffer_height;
|
int framebuffer_height;
|
||||||
glfwGetFramebufferSize(window, &framebuffer_width, &framebuffer_height);
|
glfwGetFramebufferSize(window, &framebuffer_width, &framebuffer_height);
|
||||||
// Calculate Scale
|
|
||||||
if (x_scale) {
|
// Calculate
|
||||||
*x_scale = float(framebuffer_width) / float(window_width);
|
if (window_width > 0 && window_height > 0) {
|
||||||
}
|
x_scale = float(framebuffer_width) / float(window_width);
|
||||||
if (y_scale) {
|
y_scale = float(framebuffer_height) / float(window_height);
|
||||||
*y_scale = float(framebuffer_height) / float(window_height);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return
|
||||||
|
#define ret(x) if (x##_ptr) *x##_ptr = x
|
||||||
|
ret(x_scale);
|
||||||
|
ret(y_scale);
|
||||||
|
#undef ret
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user