I recently down load the source code for a pong game and noticed ALL of the drawing was done outside of the WM_PAINT message. The program had some code in WM_SIZE and other places to make sure that the window was redrawn correctly if it was resized, covered up, etc. My question is then, what if, any are the advantages of doing it this way vs. ddoing all (or most) painting in the WM_PAINT message?
January 14, 2001 12:42 PM
cos WM_PAINT is slooooooooooooooooooooooooooooooow. You can''t have fast updates using it.
The advantage to doing the frame redrawing in WM_PAINT is that once you move the window around, and it gets covered by other stuff etc, it will call the redrawing code.
The advantage, is if you have a app/game which doesnt redraw its frames all the time (it may only be displaying a static image for example), you can save time by only redrawing the window once it is obscured, rather than redrawing it every second if the content doesnt change.
In most games, you will be redrawing the frame each time thru the loop however, so you dont really need to bother about WM_PAINT.
The advantage, is if you have a app/game which doesnt redraw its frames all the time (it may only be displaying a static image for example), you can save time by only redrawing the window once it is obscured, rather than redrawing it every second if the content doesnt change.
In most games, you will be redrawing the frame each time thru the loop however, so you dont really need to bother about WM_PAINT.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement