From a9b0abe493d4209660e68d0a1850b413c18fd941 Mon Sep 17 00:00:00 2001 From: Nick Gravelyn Date: Wed, 20 Jan 2016 06:06:31 -0800 Subject: [PATCH] Automatically updating DisplayFrameBufferScale by reading the OpenGL drawable size and comparing with the window size. This fixed dear imgui which was rendering only to 1/4 of my window. --- examples/sdl_opengl_example/imgui_impl_sdl.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/examples/sdl_opengl_example/imgui_impl_sdl.cpp b/examples/sdl_opengl_example/imgui_impl_sdl.cpp index 8359fd8a5..e222c806d 100644 --- a/examples/sdl_opengl_example/imgui_impl_sdl.cpp +++ b/examples/sdl_opengl_example/imgui_impl_sdl.cpp @@ -240,6 +240,10 @@ void ImGui_ImplSdl_NewFrame(SDL_Window *window) SDL_GetWindowSize(window, &w, &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); + // Setup time step Uint32 time = SDL_GetTicks(); double current_time = time / 1000.0;