The gluinitdisplaymode function. Here I set it to a single buffer.
Fig );
OpenGL has a forward buffer, which may be in the video memory. Setting a single buffer means that only the front buffer is used, and the graphics in the front buffer are drawn to the screen. However, the front buffer does not guarantee that it will be drawn to the screen only after you have drawn a complete image (it does not guarantee the submission of one frame at a time ). Therefore, when you draw an animated image, the intermediate process may also be displayed on the screen, which causes flickering and other strange phenomena.
Therefore, you should use double buffering when drawing an animation. That is to say, our painting is always done on the back buffer. After the painting, we use the function to submit the buffer image to the front buffer.
The specific operation will be explained later when it comes to animation.
In addition, after setting the double buffer, you can switch to the single buffer mode and then switch back. However, if the single buffer mode is set at the beginning, it cannot be changed.
There is a paragraph on the http://www.opengl.org/resources/faq/technical/rasterization.htm:
14.020 how do I change between double-andsingle-buffered mode, in an existing a window?
If you create a single-buffered window, you can't change it.
If you create a double-buffered window, you can treat it as a single-buffered window by setting gldrawbuffer () to gl_front and replacing your swap buffers call with a glflush () call. to switch back to double-buffered, you need to set gldrawbuffer () to gl_back, and call swap buffers at the end of the frame.