Break timer win32 c++

  3d, animation, c++, visual-studio, winapi

I am trying to create an animation loop through the use of timers. I want to call a different SetRenderParams(int) after approximately 5-10 seconds. I don’t know how timers work and the documentation I can find online is VERY minimal.

I tried if and while statements to break the timer, but I have come to understand it does not work as a loop, so it cannot check counts. I am never able to move to IDT_TIMER2. I am thinking I might not need multiple timers, since I do not mind keeping the same animation speed (which is what the timer essentially accomplices), but a way to alternate SetRenderParams(int) without breaking from the timer, maybe(?).

I checked timerqueues as well, but while I was checking them I got more and more confused… The link I followed to come this far was the following, however this one does not show a way to input multiple animations in sequence, only one. To be clear, I do not want to have multiple animations at the same time. I want animation after animation, distinct from each other. http://www.winprog.org/tutorial/animation.html

The code I posted is clear from all the experiments I tried.

const int IDT_TIMER1 = 1;
const int IDT_TIMER2 = 2;
SetTimer(hWnd,             // handle to main window 
    IDT_TIMER1,            // timer identifier 
    50,       // 50ms between each new frame 
    NULL);     // no timer callback``` 

SetTimer(hWnd,             // handle to main window 
    IDT_TIMER2,            // timer identifier 
    20000,                // 20s between each new frame 
    NULL);     // no timer callback 

switch (message)
{
case WM_PAINT:
{
    PAINTSTRUCT ps;
    HDC hdc = BeginPaint(hWnd, &ps);

    //=== Add code for Rendering Models);
    RenderScene(hdc);

    EndPaint(hWnd, &ps);
}
break;
case WM_TIMER:
{
    int count = 0;
    RECT rcClient;
    HDC hdc = GetDC(hWnd);
    GetClientRect(hWnd, &rcClient);

    switch (wParam)
    {

    case    IDT_TIMER1:

        SetRenderParams(13);
        InvalidateRect(hWnd, NULL, TRUE);
        ReleaseDC(hWnd, hdc);
        break;

    case  IDT_TIMER2:

        SetRenderParams(14);
        InvalidateRect(hWnd, NULL, TRUE);
        ReleaseDC(hWnd, hdc);

        break;
    }
}
break;

edit: forgot to add the initialized variables.

Source: Windows Questions C++

LEAVE A COMMENT