From e6c2c1fcfd31a53a0411b1a844a3016e701d1ab7 Mon Sep 17 00:00:00 2001 From: ocornut Date: Fri, 25 Mar 2016 22:25:20 +0100 Subject: [PATCH] Examples: SDL: Minor fixes to follow syntax of other examples (#495) --- examples/sdl_opengl3_example/imgui_impl_sdl_gl3.cpp | 7 +++---- examples/sdl_opengl_example/imgui_impl_sdl.cpp | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/examples/sdl_opengl3_example/imgui_impl_sdl_gl3.cpp b/examples/sdl_opengl3_example/imgui_impl_sdl_gl3.cpp index db76fb464..a5c4c9d06 100644 --- a/examples/sdl_opengl3_example/imgui_impl_sdl_gl3.cpp +++ b/examples/sdl_opengl3_example/imgui_impl_sdl_gl3.cpp @@ -350,12 +350,11 @@ void ImGui_ImplSdlGL3_NewFrame() // Setup display size (every frame to accommodate for window resizing) int w, h; + int display_w, display_h; SDL_GetWindowSize(g_Window, &w, &h); + SDL_GL_GetDrawableSize(g_Window, &display_w, &display_h); io.DisplaySize = ImVec2((float)w, (float)h); - - int glW, glH; - SDL_GL_GetDrawableSize(window, &glW, &glH); - io.DisplayFramebufferScale = ImVec2(glW / io.DisplaySize.x, glH / io.DisplaySize.y); + io.DisplayFramebufferScale = ImVec2(w > 0 ? ((float)display_w / w) : 0, h > 0 ? ((float)display_h / h) : 0); // Setup time step Uint32 time = SDL_GetTicks(); diff --git a/examples/sdl_opengl_example/imgui_impl_sdl.cpp b/examples/sdl_opengl_example/imgui_impl_sdl.cpp index 47dac65b2..b84f5014d 100644 --- a/examples/sdl_opengl_example/imgui_impl_sdl.cpp +++ b/examples/sdl_opengl_example/imgui_impl_sdl.cpp @@ -237,12 +237,11 @@ void ImGui_ImplSdl_NewFrame(SDL_Window *window) // Setup display size (every frame to accommodate for window resizing) int w, h; + int display_w, display_h; SDL_GetWindowSize(window, &w, &h); + SDL_GL_GetDrawableSize(window, &display_w, &display_h); io.DisplaySize = ImVec2((float)w, (float)h); - - int glW, glH; - SDL_GL_GetDrawableSize(window, &glW, &glH); - io.DisplayFramebufferScale = ImVec2(glW / io.DisplaySize.x, glH / io.DisplaySize.y); + io.DisplayFramebufferScale = ImVec2(w > 0 ? ((float)display_w / w) : 0, h > 0 ? ((float)display_h / h) : 0); // Setup time step Uint32 time = SDL_GetTicks();