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