[3DTEXT] Fix 3dtext.scr using near 100% CPU (#4125)

CORE-17866, CORE-8217
This commit is contained in:
Doug Lyons 2021-12-02 12:55:39 -06:00 committed by GitHub
parent c05a45e17e
commit 5c9fdcb1de
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -41,6 +41,9 @@ GLfloat extentY = 0.0f;
HINSTANCE hInstance;
BOOL fullscreen = FALSE;
UINT uTimerID; // SetTimer Actual ID
#define APP_TIMER 1 // Graphics Update Timer ID
#define APP_TIMER_INTERVAL (USER_TIMER_MINIMUM * 5) // Graphics Update Interval
// Build Our Bitmap Font
GLvoid BuildFont(GLvoid)
@ -338,12 +341,18 @@ ScreenSaverProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
// Initialize The GL Screen Using Screen Info
InitGL(Screen.right, Screen.bottom);
// Create Graphics update timer
uTimerID = SetTimer(hWnd, APP_TIMER, APP_TIMER_INTERVAL, NULL);
break;
case WM_DESTROY:
// Disable Fullscreen Mode
ChangeDisplaySettings(NULL, 0);
// Delete the Update Timer
KillTimer(hWnd, uTimerID);
// Deletes The Font Display List
KillFont();
@ -360,6 +369,8 @@ ScreenSaverProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
case WM_PAINT:
DrawGLScene();
SwapBuffers(hDC);
// Mark this window as updated, so the OS won't ask us to update it again.
ValidateRect(hWnd, NULL);
break;
case WM_SIZE: // Resizing The Screen
@ -367,6 +378,11 @@ ScreenSaverProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
ReSizeGLScene(LOWORD(lParam), HIWORD(lParam));
break;
case WM_TIMER:
// Used to update graphic based on timer udpate interval
InvalidateRect(hWnd, NULL, TRUE);
break;
default:
// Pass Windows Messages to the default screensaver window procedure
return DefScreenSaverProc(hWnd, message, wParam, lParam);