Ok I see one of ur logical flows
while(!done) //Main loop { if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { ...... } else { .... rendering. } }
while(!done) //Main loop { if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { ...... } else { .... rendering. } }
when you minimized, peekMessage will always fail, so you get the rendering part.
which forces you to use a 100% single-core processor, because it does not sleep during the cycle, wait, just do the drawing again and again.
you can specify the minimum time for the rendering frame.
My suggestion:
// set a timer for wakeup ur process. while (::GetMessage(&msg, NULL, 0, 0)) { // handle the messages // do check the rendering to see if you need to render. if (currentTime - lastDrawTime > MINIMIUM_RENDER_INTERVAL) // rendering. }
// set a timer for wakeup ur process. while (::GetMessage(&msg, NULL, 0, 0)) { // handle the messages // do check the rendering to see if you need to render. if (currentTime - lastDrawTime > MINIMIUM_RENDER_INTERVAL) // rendering. }
source share