OpenGL - Prevent double buffers

1.3k views Asked by At

I am using tao (C#). Can I prevent OpenGL from using a buffer for drawing?

I am into a scenario that I am using the simpleOpenGlControl and need to prevent it to use another buffer.

1

There are 1 answers

0
datenwolf On

Interestingly enough, the availability/enforcement of a doublebuffer being there or not is not for OpenGL to choose, but the windowing system. A double buffer is requested for by specifying a "I want a doublebuffer" bit in the pixelformat/visual of the window (not the OpenGL context).

However the windowing system may very well choose to give you a double buffer even if you didn't ask for one. That's why it's so important to check, which pixelformat/visual you actually got and if it has a double buffer your program must act accordingly.

That being said, OpenGL itself knows how to work with double buffered windows (keep note that the actual buffer swap function is not an OpenGL function, but a function of the windowing system).

You can explicitly draw to the front buffer by selecting it as drawing destination with glDrawBuffer(GL_FRONT). However modern windowing systems usually are composited which means that your program's "front" buffer is in fact just another off-screen buffer to the windowing system, that gets presented as a whole during the presentation step. …which ultimately means, that the whole thing behaves as if you had drawn the whole thing double buffered.

There's usually no good reason at all to draw single buffered. The "visual" effect is, that – depending on what implementation you're on – you may be able to see, how the drawing process progresses. But that is not a given. It's perfectly valid for an OpenGL implementation to queue up all drawing operations and execute them between display refreshes, which would look like double buffering, again.