I have attached to this post a new Sprite demo showing the difference between a loop animation working in EXCLUSIVE mode, and one working in COOPERATIVE mode.
The graphic container uses a client size of 800 x 600 and it displays 24 sprites, using a pixel size of 140 x 140, the sprites are built from a BMP file using the magenta color to create the region on the fly.
The animation itself is running in 32-bit ARGB composited mode.
To see the difference between each of the loop animation mode, you will have to edit the code and rem /un-rem the appropriate section:
' // EXCLUSIVE LOOP
WHILE Done = %FALSE ' Loop That Runs While done = %FALSE
IF PeekMessage(Msg, %NULL, 0, 0, %PM_REMOVE) THEN ' Is There A Message Waiting?
IF msg.message = %WM_QUIT THEN ' Have We Received A Quit Message?
Done = %TRUE ' If So done = %TRUE
ELSE ' If Not, Deal With Window Messages
CALL TranslateMessage(msg) ' Translate The Message
CALL DispatchMessage(msg ) ' Dispatch The Message
ELSE ' If There Are No Messages
' Draw The Scene.
IF gnAnimate THEN CALL DrawSprite ' Render animation
' // COOPERATIVE LOOP
' FOR K = 1 TO 5 ' Use 5 timers to get the same FPS than in exclusive mode
' CALL SetTimer(ghMain, K, K - 1, %NULL)
' WHILE GetMessage(Msg, %NULL, 0, 0)
' CALL TranslateMessage(Msg)
' CALL DispatchMessage(Msg)
' FOR K = 1 TO 5
' CALL KillTimer(ghMain, K)
Actually each loop mode should display almost the same FPS.
On my computer with VISTA AERO 64-bit and a Dual Core 2 Duo T7200 running at 2Ghz, i got:
A FPS of 109-110 and a CPU charge of 49%.
To see the difference between the two modes, move the window around in exclusive mode the animation should stop, while in cooperative mode it is still running and responsive.
In real life application, it is very important to work in cooperative mode to let the other process work smoothly and simultaneously.
Usualy one single timer is enough, but then the maximum average you can get is 65 FPS. Most of the time i am limiting myself to 30 FPS, like with BassBox or MovieBox, because that is quite enough for the human eye and it keeps the other applications very responsive (The Windows task manager can still switch between all the other running process).
Another important thing when working in cooperative mode, never draw yourself directly, but instead invalidate the rectangle or the region and let Windows process the messages accordingly.
Note: I have no idea of the FPS this will produce on Emachine, thus if you have one, please let me know.