How to avoid unnecessary re-render?

I have an OpenGL window,in which I render a very complex model(consists of millions of triangles).When i move a pop window(e.g. a cloor dialog) over it,the OpenGL window is re-renderd.It will take a long time to render and the screen is blank,which is not acceptable.
I use MSVC as development tools,and i put the render stuff in the OnPaint event handler of window.I know the OpenGL window will reveive WM_PAINT message when a pop window moving over it,but i have no idea how to avoid unnecessary update when the OpenGL window receive WM_PAINT message.
I appreciate any help,and is any extensions can help me?


you can save/restore the screen into/from an offscreen buffer. see the wgl_buffer_region extension

I think you can render the model to an accumulation buffer and use glAccum(GL_RETURN, 1.0) when you need to repaint the window. sure you should remove the rendering routine from OnPaint() and do it elsewhere.

I think Zed’s and Nil_z’s teqs are probably best, but there’s also a glAddSwapHintRectWIN function that can specify a sub-region to be rendered. Might help the situation if a pop-up or dialog corrupts your screen.