Resize Window,glClearColor

I have two questions。
first question,I created a Win32 window demo;I just want to draw my graphics in the lower right corner of the window;When the program starts, I start a timer, each 1s redraw the graphics in the lower right corner;I used GL_SCISSOR_TEST,The result is correct。But when I adjust the window size, the color set by glClearColor will fill the entire window,I do not understand。I used double buffer。In the window procedure function WndProc, I processed the message WM_ERASEBKGND (return 0), WM_SIZE (return 0 or glViewPort (NewWidth, NewHeight))。

second question,I create a win32 window demo; when the program starts, I start 2 timers, a timer draws the triangle on the left side of the window, a timer draws the quadrilateral to the right of the window; when I resize the window, there will be blinking.I used double buffer. I guess the same reason as the first question.

thanks very much!

If the window is resized, the framebuffer contents are lost. You need to redraw the entire window; the contents of any part you don’t redraw will be undefined.

With double buffering, a buffer swap causes the contents of the back buffer to be undefined. You need to redraw the entire window before performing another swap.

If you want the framebuffer contents to persist, you need to use a framebuffer object (FBO), or some other form of off-screen drawing surface (e.g. pbuffer or pixmap). FBOs were added in the ARB_framebuffer_object extension, which became part of core OpenGL in version 3.0. If you’re restricted to an earlier version of OpenGL, you’ll have to use platform-specific features.