OpenGL window systems screen tearing prevention

1.1k views Asked by At

in my OpenGL application I want to prevent screen tearing for obvious reasons. So far I have been using vsync. But I would like to replace it with a page flipping buffer swap (changing a pointer to the monitor's data instead of changing the value) to improve performance. My question is: Do the important windowing systems (Windows, Cocoa, X11) support this kind of buffer swap at all and does it need to be requested explicitly or is it the default behavior?

1

There are 1 answers

0
datenwolf On BEST ANSWER

V-Sync is the "vertical retrace synchronization". If V-Sync is enables it means, that the double buffers are exchanged in that timespan, when the display is not drawing. It's a term inherited from the time of CRT displays, where an electron beam was used to draw the image line by line from top left to the bottom. When the beam reached the bottom right it had to be returned to the top right. The electron beam was steered using two pair of electromagnet coils and (unlike the electrostatic deflectors in an oscilloscopes) can not operate beyond a certain slew rate. That's the V-Sync

Today, displays receive their data still line by line into a buffer internal to the display. At the end of a whole frame a small pause is inserted.

So the "vertical retrace" is that timespan where you can update the data in your display framebuffer, wihout interfereing with the drawing process.

So far I have been using vsync.

No, you didn't "use" vsync. You do use double buffering, which exchange is synchronized by the V-Sync.

But I would like to replace it with a page flipping buffer swap

This is not your decision to make. What method is used is chosen by the graphics hardware and its driver. Your program lives in userspace and can't even talk on that a low level with the hardware. And normally the method that performs best in the situation is used.