Skip to content

Commit

Permalink
Late reporting of the fact that the GUI was asked to be closed.
Browse files Browse the repository at this point in the history
This will allow us to still display a functioning GUI while the
process is shutting down.
  • Loading branch information
ktf committed Aug 18, 2023
1 parent 897e168 commit 50fe5c3
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
3 changes: 3 additions & 0 deletions DebugGUI/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ if(APPLE)
src/implot_internal.h
src/imconfig.h
src/DebugGUIAPIv2.h
src/DebugGUIAPIv3.h
# src/Sokol3DUtils.h
src/DebugGUI.h
src/imgui_impl_glfw.h
Expand Down Expand Up @@ -68,6 +69,7 @@ elseif(GLFW_FOUND)
src/GL3DUtils.h
src/DebugGUI.h
src/DebugGUIAPIv2.h
src/DebugGUIAPIv3.h
src/imgui_impl_opengl3.h
src/imgui_impl_glfw.h
src/icons_font_awesome.h
Expand All @@ -85,6 +87,7 @@ else()
src/GL3DUtils.h
src/DebugGUI.h
src/DebugGUIAPIv2.h
src/DebugGUIAPIv3.h
src/imgui_impl_glfw_gl3.h
src/icons_font_awesome.h
)
Expand Down
7 changes: 4 additions & 3 deletions DebugGUI/src/DebugGUI.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,6 @@ bool pollGUIPreRender(void* context, float delta)
if (context) {
GLFWwindow* window = reinterpret_cast<GLFWwindow*>(context);

if (glfwWindowShouldClose(window)) {
return false;
}
glfwPollEvents();
ImGui_ImplOpenGL3_NewFrame();
ImGui_ImplGlfw_NewFrame();
Expand All @@ -116,6 +113,10 @@ bool pollGUIPreRender(void* context, float delta)
ImVec4 clear_color = ImColor(114, 144, 154);
glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
glClear(GL_COLOR_BUFFER_BIT);

if (glfwWindowShouldClose(window)) {
return false;
}
} else {
// Just initialize new frame
ImGuiIO& io = ImGui::GetIO();
Expand Down
Empty file added DebugGUI/src/DebugGUIAPIv3.h
Empty file.
6 changes: 1 addition & 5 deletions DebugGUI/src/DebugGUIMacos.mm
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,6 @@ bool pollGUIPreRender(void *context, float delta) {

auto *ctx = reinterpret_cast<DebugGUIContext *>(context);
NSWindow *nswin = glfwGetCocoaWindow(ctx->window);
if (glfwWindowShouldClose(ctx->window)) {
return false;
}
@autoreleasepool {
glfwPollEvents();
int width, height;
Expand All @@ -183,8 +180,7 @@ bool pollGUIPreRender(void *context, float delta) {
ImGui_ImplGlfw_NewFrame();
ImGui::NewFrame();
}

return true;
return glfwWindowShouldClose(ctx->window) == false;
}

void pollGUIPostRender(void *context, void *drawData) {
Expand Down

0 comments on commit 50fe5c3

Please sign in to comment.