I'm creating a drawing application that renders OpenGL when it gets a WM_SCROLL or WM_MOUSEMOVE. The thing is that there are a lot of mouse moves and I only need it to render a maximum of 60 frames per second. So I created a bool in my engine class called CanRender. so in my render() proc I do: if(!CanRender) { return; } CanRender = false;
Basically it prevents it from rendering more than 60 FPS.
I create the timer in WM_CREATE.
when I get a WM_TIMER I set CanRender to true.
I made it beep so I know the timer is running. As soon as I start scroling or moving the mouse, the beeping stops and I no longer see rendering. Why would it stop my timer? Also when I minimize the timer starts again then remaximize, it stops again.
Thanks
Message Pump:
// Main message loop:
while (GetMessage(&msg, NULL, 0, 0))
{
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return (int) msg.wParam;
creation:
case WM_CREATE:
//Set Window Title
SetWindowText(hWnd,engineGL.current.caption.c_str());
SetTimer(hWnd, // handle to main window
120, // timer identifier
17, // 60 fps interval
(TIMERPROC) NULL); // no timer callback