Minimise repainting

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

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.

OK, that seems to do the trick!

Many thanks. :stuck_out_tongue:

Rog