PDA

View Full Version : How to avoid screen update "tearing"?



Theo
12-10-2000, 09:15 AM
How can I avoid "Tearing" on screen updates? If i do a aglswapdoublebuffer in the middle of a video update, part of the old image is drawn, and part of the new one is. The problem is that I can't tell when a video update is going to occur.

Is there someway of manually counting the number of video refreshes since startup? That way I could poll that number, and only redraw when it increases.

12-12-2000, 06:27 AM
Use aglSetInteger to set the Swap Interval to something like 1. That makes OpenGL wait for a screen refresh before drawing.

b = aglGetInteger(data->context, AGL_SWAP_INTERVAL, &val);
b = aglSetInteger(data->context,AGL_SWAP_INTERVAL, &val);

Or set the "swapinterval" property of the OpenGL control in my Realbasic plugin: http://www.playground.ltc.vanderbilt.edu/~holtondl/oglplug.sit.hqx

cartilago
12-12-2000, 11:20 AM
At this time aglSwapInterval is not yet implemented so callling this function makes no diference.
The only way to avoid tearing is to install
a VBL task (see Apple developer web site to find more info.) to test when the screen refresh is at the vertical retrace, and only then call aglSwapBuffers.
Also you should make shure to call glFlush() before swaping the buffers .

12-13-2000, 04:14 AM
Unfortunately syncing to the VBL by installing a VBL task, then calling aglFlush(), then calling aglSwapBuffers() *still* results in tearing. :-(
For futher discussion and a demo, please contact me directly at <adario@softhome.net>.
Thank you.

12-13-2000, 07:05 AM
AGL_SWAP_INTERVAL is documented in Apple's AGL reference included with the OpenGL download.