Dark Bit Factory & Gravity
PROGRAMMING => C / C++ /C# => Topic started by: Raizor on May 30, 2011
-
Does anyone have any tips or suggestions on the best way to handle vsync issues in an OpenGL demo/intro? It seems that if the user has their card set to automatic/application controlled, the demo may race along far too fast. At the moment I've got some crude frame timing in place that blocks if a frame is rendered too quickly. I just wonder if there's a more elegant solution.
Any advice would be greatly appreciated.
-
Maybe you should have a look at this for a start: http://www.dbfinteractive.com/forum/index.php?topic=4118.0 (http://www.dbfinteractive.com/forum/index.php?topic=4118.0) It's C(++), it's OpenGL and it's about timing. ;)
-
Thanks Padman!
-
No prob.
-
I certainly rcommend using timing as even if you turn vsync on gfx drivers can override it.
Here's a function I made in C to turn vsync on or off, probably better ways to do it but it code from a good few years ago and seems to work.
/*------------------------------------------------------------------------
' NAME : SwitchVsync
' PURPOSE : This function Sets vsync on off
' INPUTS : true or false
'------------------------------------------------------------------------*/
void SwitchVsync(bool sync)
{
BOOL (APIENTRY *wglSwapIntervalEXT)(int);
wglSwapIntervalEXT=( BOOL (APIENTRY*)(int) )wglGetProcAddress("wglSwapIntervalEXT");
if (sync=true)
{
wglSwapIntervalEXT(1);
}
else
{
wglSwapIntervalEXT(0);
}
}
One quick note, you need to have created the opengl context for this to work, so once you have your opengl window opened then call this function with true or false.
-
Thanks TinDragon. Will give that a whirl :)
-
Watch here...
Very good Tutorial.
Its similar to Hitchhikrs MASM-BASEFramework
http://www.angelcode.com/dev/timefps/timefps.asp
-
Watch here...
Very good Tutorial.
Its similar to Hitchhikrs MASM-BASEFramework
Watch where Energy?
-
Sorry... edited! :xmas:
-
Thanks Energy. Will check that out :)