Search code examples
opengldouble-buffering

Single buffering in OpenGL without clearing


I'd like to draw points (a lot of them) and let them appear progressively on the screen. So my idea is to draw them on the screen without clearing it.

However this would work only using single buffering : with double buffering, half of the dots would be on one buffer, and the other half on the second.

I have two questions:

  1. How can I have a single buffer that allows me to see the drawing appear as it is drawn (here a lot of dots making geometrical forms) ?
  2. Will this affect the performance of OpenGL aka will it be significantly slower (a bit slower is not a problem)

Solution

  • The simplest solution is to stop rendering to the default framebuffer entirely. Render to a texture attached to an FBO instead (if you need a depth buffer, you'll need to create one of those too). When you want to display the image, then blit your texture FBO to the default framebuffer and issue a swap-buffers call.