PDA

View Full Version : Minimise repainting



10-12-2006, 05:12 AM
This is not strictly an OpenGL-specific question, but I'm guessing you guys are still the best to ask.

My app doesn't have any moving components in the window until the user actually does something like drag the mouse, etc - and yet, it is hammering the processor by constantly repainting the window at dozens of frames per second.

What I need to know is, is there any way I can easily tell my DrawGLScene function to only repaint the window when it actually needs to be repainted - i.e. when another window is dragged in front of it, etc?

I tried moving my draw function call to inside the WM_PAINT event, but this is still being constantly called many times per second when it really doesn't seem to need painting.

Any suggestions much appreciated!

Rog

k_szczech
10-12-2006, 06:01 AM
Read about InvalidateRect and ValidateRect.
Basically if you don't call ValidateRect at the end of WM_PAINT Windows will assume that some portion of your window is not yet updated and will send WM_PAINT again.
You should use InvalidateRect whenever some action is taken that needs repainting.

10-12-2006, 08:02 AM
OK, that seems to do the trick!

Many thanks. :p


Rog