Skip to content

Commit

Permalink
don't render all the time sample hang fix (wm_quit in the inner untre…
Browse files Browse the repository at this point in the history
…ated)
  • Loading branch information
sergeyn committed Apr 14, 2020
1 parent 875a03f commit ee71810
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
4 changes: 3 additions & 1 deletion examples/example_win32_directx12/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,9 @@ int main(int, char**)

// Start the Dear ImGui frame
ImGui_ImplDX12_NewFrame();
ImGui_ImplWin32_NewFrame();
if (!ImGui_ImplWin32_NewFrame())
break;

ImGui::NewFrame();

// 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!).
Expand Down
20 changes: 14 additions & 6 deletions examples/imgui_impl_win32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ static void ImGui_ImplWin32_UpdateGamepads()
#endif // #ifndef IMGUI_IMPL_WIN32_DISABLE_GAMEPAD
}

void ImGui_ImplWin32_NewFrame()
bool ImGui_ImplWin32_NewFrame()
{
ImGuiIO& io = ImGui::GetIO();
IM_ASSERT(io.Fonts->IsBuilt() && "Font atlas not built! It is generally built by the renderer back-end. Missing call to renderer _NewFrame() function? e.g. ImGui_ImplOpenGL3_NewFrame().");
Expand All @@ -238,13 +238,17 @@ void ImGui_ImplWin32_NewFrame()

MSG msg;
while (::PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE))
{
::TranslateMessage(&msg);
::DispatchMessage(&msg);
continue;
{
if (msg.message != WM_QUIT)
{
::TranslateMessage(&msg);
::DispatchMessage(&msg);
continue;
}
return false;
}

::QueryPerformanceCounter((LARGE_INTEGER*)&current_time);
::QueryPerformanceCounter((LARGE_INTEGER*)&current_time);
continue;
}
break;
Expand Down Expand Up @@ -280,6 +284,8 @@ void ImGui_ImplWin32_NewFrame()

// Update game controllers (if enabled and available)
ImGui_ImplWin32_UpdateGamepads();

return true;
}

// Allow compilation with old Windows SDK. MinGW doesn't have default _WIN32_WINNT/WINVER versions.
Expand Down Expand Up @@ -383,6 +389,8 @@ IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hwnd, UINT msg, WPARA
if ((UINT)wParam == DBT_DEVNODES_CHANGED)
g_WantUpdateHasGamepad = true;
return 0;
case WM_CLOSE:
io.NextRefresh = 0.0f;
}
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion examples/imgui_impl_win32.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

IMGUI_IMPL_API bool ImGui_ImplWin32_Init(void* hwnd);
IMGUI_IMPL_API void ImGui_ImplWin32_Shutdown();
IMGUI_IMPL_API void ImGui_ImplWin32_NewFrame();
IMGUI_IMPL_API bool ImGui_ImplWin32_NewFrame();

// Configuration
// - Disable gamepad support or linking with xinput.lib
Expand Down

0 comments on commit ee71810

Please sign in to comment.