[rcore][win32] stop lying to the OS about when our window is updated
Instead of calling BeginPaint/EndPaint in WM_PAINT which signals to the OS that our window content is updated, now when we encounter the WM_PAINT message instead we return back to the raylib application which will trigger it to render a new frame. We've replaced the call to BeginPaint and EndPaint with a call to ValidateRect in SwapBuffers, which, means we're now correctly telling the OS when our window content is actually up-to-date. Note that this doesn't fix the window content not being updated during a window resize/move beacuse thos have their own message loop which doesn't return early when it's time to paint.
This commit is contained in:
parent
8e28a942f9
commit
6db18524b4
|
|
@ -1439,6 +1439,11 @@ void SwapScreenBuffer(void)
|
|||
LogFail("SwapBuffers", GetLastError());
|
||||
abort();
|
||||
}
|
||||
|
||||
if (!ValidateRect(global_hwnd, NULL)) {
|
||||
LogFail("ValidateRect", GetLastError());
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
double GetTime(void)
|
||||
|
|
@ -1551,6 +1556,8 @@ void PollInputEvents(void)
|
|||
|
||||
MSG msg;
|
||||
while (PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE)) {
|
||||
if (msg.message == WM_PAINT)
|
||||
return;
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessageW(&msg);
|
||||
}
|
||||
|
|
@ -1778,12 +1785,6 @@ static LRESULT WndProc2(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam, Flags
|
|||
}
|
||||
return 0;
|
||||
}
|
||||
case WM_PAINT: {
|
||||
PAINTSTRUCT ps;
|
||||
BeginPaint(hwnd, &ps);
|
||||
EndPaint(hwnd, &ps);
|
||||
return 0;
|
||||
}
|
||||
case WM_SETCURSOR:
|
||||
if (LOWORD(lparam) == HTCLIENT) {
|
||||
SetCursor(CORE.Input.Mouse.cursorHidden ? NULL : LoadCursorW(NULL, IDC_ARROW));
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user