Why does my timer stop ticking?

I am creating a drawing application that displays OpenGL when it receives WM_SCROLL or WM_MOUSEMOVE. The fact is that there are many mouse movements, and I only need them to display 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;

This basically prevents rendering of more than 60 FPS.

I am creating a timer in WM_CREATE.

when I get WM_TIMER, I set CanRender to true.

I made a beep, so I know the timer is working. As soon as I start scrolling or moving the mouse, the beep stops and I no longer see the rendering. Why does he stop my timer? Also, when I minimize the timer, it starts again and then deletes it again, it stops again.

thank

Pump Message:

// Main message loop:
while (GetMessage(&msg, NULL, 0, 0))
{
    if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
    {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }

}

return (int) msg.wParam;

Creature:

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 
+5
source share
1 answer

Why is it so hard?

Drawing in a Windows application is usually performed only in the WM_PAINT message and is triggered by the RedrawWindow function. You can call RedrawWindow on WM_SCROLL and WM_MOUSEMOVE. Several calls to RedrawWindow (WM_PAINT messages) will be minimized if your application cannot keep up with the drawing.

, OpenGL , .


... , WM_SCROLL WM_MOUSEMOVE. . , ( ), , WM_TIMER . , .

+3

All Articles