Game Development Community

Vsync Not Working

by Nathan Harris · in Torque Game Engine · 03/16/2008 (1:50 am) · 6 replies

Greetings,

This has bugged me for awhile now- VSYNC does not work in TGE. My monitor is at 85Hz, however TGE is not running at that rate, whether I set the option "$pref::Video::disableVerticalSync = 0", or force it on in the nVidia Control Panel (or a combination of both). I've searched the forums for any related information, but it was dry. I couldn't get access to some of the threads that looked like they had info, but they were for T2D or TGEA owners.

I'm surprised this hasn't come up more, as I'm sure others have noticed as well. VSYNC is a pretty standard option in games, and personally I always run with it on for a smoother feel (so long as it doesn't bog down my frame rates). I have to run my TGE project in a window when I'm working with it, as I get a headache after a few minutes running fullscreen due to the low default refresh rate.

#1
03/16/2008 (6:11 pm)
Do you mean torque isn't running at 85 FPS exactly, no more no less, or are you seeing tearing?
#2
03/16/2008 (6:36 pm)
Are you forcing vsync within directx or opengl. Setting it within nvidia control panel should force it on. But there maybe something within the latest drivers that is only setting it for the directx side of house. By default TGE is going to run in opengl.

So you may take a look at this (dug it from a old post so things may have changed since then).

-------------------------
in platformWin32\winOGLVideo.cc on or around line 790:
-------------------------------------------------------------------
devMode.dmPelsWidth = newRes.w;
devMode.dmPelsHeight = newRes.h;
devMode.dmBitsPerPel = newRes.bpp;
// set the display frequency (refresh rate)
devMode.dmDisplayFrequency = 85;
// notify the devmode that displayfrequency has been set
devMode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL | DM_DISPLAYFREQUENCY;
-------------------------------------------------------------------

This will set the refresh rate to 85. In my version I appended an additional param to the $Pref::Video::Resolution attribute in the prefs.cs script:

$Pref::Video::Resolution = "800 600 32 85";
---------------------------------------------------------------------

That will give you the open of forceing a refresh rate via the preferences file. But remember that is only going to be the opengl side as the above code only effects the opengl side of TGE.
#3
03/17/2008 (12:10 am)
@Andrew - I don't know a better way of explaining that VSYNC doesn't work correctly, other than stating just that... Yes, with no VSYNC I see tearing. That is to be expected. And I wouldn't dare to expect to have a game running at a constant [insert monitor refresh rate here]FPS with VSYNC on. I know there will be dips and spikes even with VSYNC on. Your question was sort of... redundant. If I'm not running at a solid 85FPS, and I see tearing, it should be pretty obvious VSYNC isn't on :p.

[edit]
Sorry Andrew, that came off rude, but it wasn't intended that way! You just kinda made me chuckle there.
[/edit]

@Thomas - I just tried your code there, and it works perfectly. Thank you very much! Also, I was forcing VSYNC on in a few ways: directly through the nVidia CP, as well as through RivaTuner and forcing it on for OpenGL. No go on either. It seems Torque has VSYNC controls by the throat...
#4
03/17/2008 (9:26 am)
Nathan, after a couple years as a pc repair tech, and time spent here and on a couple other game boards, I've found you really have to make sure the person asking the question actually knows what's going on.
I have seen complaints from people demanding to know why a game still runs at 5fps even when they turn on VSYNC...
#5
03/17/2008 (1:45 pm)
I've noticed sometimes VSync is on, and sometimes it is off without my having adjusted any settings. This is very noticeable when the opening screen hits 500fps some launches, and 60fps others :/ Not sure what to make of it yet. Sometimes relaunching it fixes it, and sometimes it takes a reboot. Vsync is off in the nvidia control panel.

This is with a GF6800 Go Ultra video card w/ stock drivers.
#6
03/19/2008 (7:30 pm)
@Andrew - I see what you mean now, and totally agree as I've seen it myself as well (same circumstances too- I've done PC repair/build work and been on more than a few forums that have "help" sections). I wasn't thinking straight when I read your post, and was thinking "Well duh, I know what VSYNC is man". Sorry 'bout that...

@Jason - Try the "fix" Thomas posted. Works a charm for me. Right now I only need the refresh rate locked at 85 for my own personal needs, but I'll eventually add a drop down box in the options menu... I was trying to figure out if Torque had a way of fetching the desktop refresh rate- then I would just have it set to that automatically.

Somewhat off topic here, yet loosely related. I've always been able to tell if a game/application that runs fullscreen pops to a different refresh rate on CRT monitors because it makes a distinctive popping sound (because it's changing to the different rate). I've been trying to find out if this can eventually damage a monitor, though I think a quick degauss (most CRT monitors have this option) seems to fix any evil doings done by constant refresh rate/resolution changes. But I've not been able to find any "definitive" information on this. Anyone have any information or links to information related to this they can share?