wake up windows main loop when updating fps, use PostMessage instead of the blocking SendMessage
This commit is contained in:
14
src/main.cpp
14
src/main.cpp
@@ -23,6 +23,7 @@
|
||||
#include <sstream>
|
||||
|
||||
#define WM_USER_CLOSE (WM_USER + 1)
|
||||
#define WM_USER_WAKEUP (WM_USER + 2)
|
||||
|
||||
LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp);
|
||||
HINSTANCE hInst;
|
||||
@@ -108,7 +109,7 @@ void destroy_window()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(main_task_mutex);
|
||||
main_tasklist.emplace_back([=] {
|
||||
SendMessage(hWnd, WM_USER_CLOSE, 0, 0);
|
||||
PostMessage(hWnd, WM_USER_CLOSE, 0, 0);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -196,10 +197,13 @@ void win32_update_fps(int frames)
|
||||
else
|
||||
swprintf_s(title_fps, L"%s - %d fps", window_title, frames);
|
||||
|
||||
std::lock_guard<std::mutex> lock(main_task_mutex);
|
||||
main_tasklist.emplace_back([] {
|
||||
SetWindowText(hWnd, title_fps);
|
||||
});
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(main_task_mutex);
|
||||
main_tasklist.emplace_back([] {
|
||||
SetWindowText(hWnd, title_fps);
|
||||
});
|
||||
}
|
||||
PostMessage(hWnd, WM_USER_WAKEUP, 0, 0);
|
||||
}
|
||||
|
||||
void win32_show_cursor(bool visible)
|
||||
|
||||
Reference in New Issue
Block a user