From 94c52a32c7d4f6a1eafed6e6e6bfbb605699a41f Mon Sep 17 00:00:00 2001 From: Kubat <mael.martin31@gmail.com> Date: Wed, 17 Jun 2020 19:07:24 +0200 Subject: [PATCH] No more 'black screen' when pop a window out of the primary window --- imgui.ini | 13 ++++--------- main.cpp | 38 +++++++++++++++++++------------------- 2 files changed, 23 insertions(+), 28 deletions(-) diff --git a/imgui.ini b/imgui.ini index 2e48e74..e0339bb 100644 --- a/imgui.ini +++ b/imgui.ini @@ -4,16 +4,14 @@ Size=400,400 Collapsed=0 [Window][Hello, world!] -Pos=745,530 -Size=643,193 +Pos=166,90 +Size=660,407 Collapsed=0 -DockId=0x00000003,0 [Window][Dear ImGui Demo] -Pos=745,128 -Size=643,400 +Pos=997,69 +Size=750,497 Collapsed=0 -DockId=0x00000002,0 [Window][Another Window] Pos=60,60 @@ -81,7 +79,4 @@ Size=771,465 Collapsed=0 [Docking][Data] -DockNode ID=0x00000001 Pos=745,146 Size=643,595 Split=Y - DockNode ID=0x00000002 Parent=0x00000001 SizeRef=849,526 Selected=0xE927CF2F - DockNode ID=0x00000003 Parent=0x00000001 SizeRef=849,254 Selected=0xEBE6C6E6 diff --git a/main.cpp b/main.cpp index f2d9da0..0e34694 100644 --- a/main.cpp +++ b/main.cpp @@ -174,24 +174,6 @@ int main(int argc, char **argv) } } - /* Always redraw */ - { - int w, h; - int __one__one = 1; - SDL_GetWindowSize(window, &w, &h); - mpv_opengl_fbo fbo = { - .fbo = 0, - .w = w, - .h = h, - }; - mpv_render_param params[] = { - {MPV_RENDER_PARAM_OPENGL_FBO, &fbo}, - {MPV_RENDER_PARAM_FLIP_Y, &__one__one}, - {(mpv_render_param_type)0} - }; - mpv_render_context_render(mpv_gl, params); - } - // Start the Dear ImGui frame ImGui_ImplOpenGL3_NewFrame(); ImGui_ImplSDL2_NewFrame(window); @@ -236,7 +218,22 @@ int main(int argc, char **argv) // Rendering ImGui::Render(); - ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); + + /* Always redraw */ + int w, h; + int __one__one = 1; + SDL_GetWindowSize(window, &w, &h); + mpv_opengl_fbo fbo = { + .fbo = 0, + .w = w, + .h = h, + }; + mpv_render_param params[] = { + {MPV_RENDER_PARAM_OPENGL_FBO, &fbo}, + {MPV_RENDER_PARAM_FLIP_Y, &__one__one}, + {(mpv_render_param_type)0} + }; + // mpv_render_context_render(mpv_gl, params); if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable) { @@ -246,6 +243,9 @@ int main(int argc, char **argv) ImGui::RenderPlatformWindowsDefault(); SDL_GL_MakeCurrent(backup_current_window, backup_current_context); } + mpv_render_context_render(mpv_gl, params); + + ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); SDL_GL_SwapWindow(window); } -- GitLab