Game Development Community

Syncing to vertical blank

by Charlie Grisafi · in Torque Game Engine · 07/06/2004 (5:10 pm) · 6 replies

I would like to sync up the OpenGL frame buffer swaps to the PC monitors verical blanking. It appears that the buffer swaps are free running so that you can get frame rates in excess of 100 frames per second, even when the monitor frequency is only 60 Hz. This cause visible "tearing" of the screen in some cases.

I have looked through a bunch of the documentation and engine source code, and have searched the forums, but I have not been able to find any references to this anywhere.

In other OpenGl applications I have written (on PCs with Nvidia graphics) I added the following line to my C code;

putenv( "__GL_SYNC_TO_VBLANK=1" );

which tells the NVIDIA driver to sync the Opengl buffer swaps to the vertical blank.

This does not appear to work on my torque engine application, even though my PC has an Nvidia graphics card.

I have done searches on the forums, resources and documentation, but I can't find any reference to this anywhere.

If anyone has figured out how to get the Torque code to do this already, I would appreciate any advice.

Thanks

About the author

Recent Threads


#1
07/06/2004 (9:37 pm)
I am pretty sure Torque has a synch to vertical blank option available. Have you checked all the script preferences? What about the various dgl helper functions?
#2
07/07/2004 (9:11 am)
Thanks for the info.

There is a script preference $Pref::Video:DisableVerticalSync which is set to 1 in all of the fps demo scripts. This disables the vertical sync. Do you know why this would not default to 0 ?
#3
07/07/2004 (9:44 am)
Developers often like to run faster than the vsync, so they have an idea of how much extra performance there is in the system.
#4
07/08/2004 (6:30 am)
Ben,

I set the $Pref::Video:DisableVerticalSync = 0 in all of the scripts it appears in. It looks to me that the engine still does not sync to the vertical blank.

I setup my Nvidia driver to always force 640x480 resolution to have a 60Hz refresh rate. I have a frame counter on screen, and I also verify this using the console metrics(fps); command.

The frame rate still free runs, and I get frame rates in excess of 100 frames per second, when the max I should ever see is 60.

I have not seen any other prefs to force the sync.

I would appreciate any help you can give me.

Thanks
#5
07/08/2004 (1:28 pm)
Not sure on windows, but on Linux I could configure the drivers to do the vertical blank and it locked at 60 fps. I'm sure the windows drivers have a similar option?
#6
07/08/2004 (3:44 pm)
I'm still learning how to use TGE myself, so I may be way off base here, but does this affect both Debug and Release compilations?

I ask because it would make sense to me for the Debug version to ignore that command/flag in scripts so that you could spot potential problem areas more easily.