DevMaster.net Forums
[[ Home | Forums | 3D Engines Database | Wiki | Articles/Tutorials | Game Dev Jobs | IRC Chat Network | Contact Us ]]

Go Back   DevMaster.net Forums > Site Discussions > Code & Snapshot Discussion
User Name
Password
Register FAQ Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
Old 08-09-2003, 03:23 PM   #1
Dia Kharrat
DevMaster Staff
 
Join Date: Jan 2003
Posts: 1,201
Default

Code:
typedef BOOL (APIENTRY *PFNWGLSWAPINTERVALFARPROC)( int ); PFNWGLSWAPINTERVALFARPROC wglSwapIntervalEXT = 0; void setVSync(int interval=1) { const char *extensions = glGetString( GL_EXTENSIONS ); if( strstr( extensions, "WGL_EXT_swap_control" ) == 0 ) return; // Error: WGL_EXT_swap_control extension not supported on your computer.\n"); else { wglSwapIntervalEXT = (PFNWGLSWAPINTERVALFARPROC)wglGetProcAddress( "wglSwapIntervalEXT" ); if( wglSwapIntervalEXT ) wglSwapIntervalEXT(interval); } }

The default 'interval' is 1, which means VSync is on. Setting it to 0 would turn it off.
Dia Kharrat is offline   Reply With Quote
Old 08-10-2003, 02:33 AM   #2
davepermen
Senior Member
 
davepermen's Avatar
 
Join Date: Jan 2003
Location: Switzerland
Posts: 1,333
Default

nice snippet-idea, and nice snippet!
___________________________________________
davepermen.net
-Loving a Person is having the wish to see this Person happy, no matter what that means to yourself.
-No matter what it means to myself....
davepermen is offline   Reply With Quote
Old 08-12-2003, 03:07 PM   #3
baldurk
DevMaster Staff
 
baldurk's Avatar
 
Join Date: Jan 2003
Location: Mars
Posts: 1,141
Default

It's kinda only really half using OpenGL, though. It uses wgl extensions which are (obviously) only available using windows.

I don't see why you'd really want to turn off VSync. Yes it limits frame rate, but once you get to 60, why go higher?
___________________________________________
baldurk
He who knows not and knows that he knows not is ignorant. Teach him.
He who knows not and knows not that he knows not is a fool. Shun him.
baldurk is offline   Reply With Quote
Old 08-12-2003, 03:29 PM   #4
davepermen
Senior Member
 
davepermen's Avatar
 
Join Date: Jan 2003
Location: Switzerland
Posts: 1,333
Default

for measurements.

i do that in my raytracer currently, to measure raw performance.


and, if you drop from 60fps, disabling vsync is good, as you else get 60-30-15fps, i can have everything between, too.. and there is no real difference between 50 and 60 fps.. but "jumps" from 30 to 60 to 30 to 60 to 30 to 60 are visible..
___________________________________________
davepermen.net
-Loving a Person is having the wish to see this Person happy, no matter what that means to yourself.
-No matter what it means to myself....
davepermen is offline   Reply With Quote
Old 08-12-2003, 03:33 PM   #5
Dia Kharrat
DevMaster Staff
 
Join Date: Jan 2003
Posts: 1,201
Default

Well, during development, you would have to do optimizations and also analyize your code. Turning VSync off would tell you the real frames per second of your application.
Dia Kharrat is offline   Reply With Quote
Old 08-13-2003, 11:57 AM   #6
baldurk
DevMaster Staff
 
baldurk's Avatar
 
Join Date: Jan 2003
Location: Mars
Posts: 1,141
Default

I'll need to find a linux way to do it!
___________________________________________
baldurk
He who knows not and knows that he knows not is ignorant. Teach him.
He who knows not and knows not that he knows not is a fool. Shun him.
baldurk is offline   Reply With Quote
Old 08-21-2003, 07:36 PM   #7
Jesse M
Member
 
Join Date: Jun 2003
Location: Airdrie, Alberta, Canada
Posts: 32
Default

Or you could just use your compilers profiler, because it's going to give a hell of alot more information than the frame rate will. And in any case you shouldn't worry about optimizing anything during developement anyway. That's what alpha testing is for.
___________________________________________
FRAG THE PLANET
Ed Helms: Alcohol causes problems and guns solve problems. I don't see why you can't have guns in bars.
Other guy: That's a stupid idea.
Ed Helms: Yeah, if your a pussy.
Jesse M is offline   Reply With Quote
Old 08-21-2003, 11:32 PM   #8
davepermen
Senior Member
 
davepermen's Avatar
 
Join Date: Jan 2003
Location: Switzerland
Posts: 1,333
Default

its still a very useful feature.. very cheap to support, so what?
___________________________________________
davepermen.net
-Loving a Person is having the wish to see this Person happy, no matter what that means to yourself.
-No matter what it means to myself....
davepermen is offline   Reply With Quote
Old 12-29-2004, 03:19 AM   #9
SYS49152
Member
 
Join Date: Sep 2004
Posts: 57
Default

hello guys.... i have some quick questions about the vsync story.
i dont know if i should start a new thread so sorry if this is the wrong place for this.

davepermen wrote:
----------------------
and, if you drop from 60fps, disabling vsync is good, as you else get 60-30-15fps, i can have everything between, too.. and there is no real difference between 50 and 60 fps.. but "jumps" from 30 to 60 to 30 to 60 to 30 to 60 are visible..

i have this sometimes in my application. most of the time it runs 60fps but then sometimes 30fps appears. is this because the grafics-pipeline is not balance or something ? or has this to do with alphablending operations ?
in my project i have some alpha-blended objects. so ofcourse its the typical effect that appears with alpha-blendings sometimes ?

Die Kharrat wrote:
----------------------
Well, during development, you would have to do optimizations and also analyize your code. Turning VSync off would tell you the real frames per second of your application.

i remember that i read on few boards that fps over 60fps doesnt really say something.....

so iam abit confused what is really true and what not....

- Andy
SYS49152 is offline   Reply With Quote
Old 12-29-2004, 12:05 PM   #10
Dia Kharrat
DevMaster Staff
 
Join Date: Jan 2003
Posts: 1,201
Default

FPS is not the optimal measure of how efficient your coding is, but is just a general measure. An FPS of more than 60 is not important in terms of the human eye, where differences between 60 and 70 for example are not noticeable to the human eye.

However, during development, most developers turn vsync off so that they have a better measure of how certain things (adding a model, blending, etc.) affect the FPS.

However, the best way to measure efficiency and to optimize your code is to use a runtime profiler, which is a “tool” for timing bits of your code. You can either write your own or use a commercial one (there might be even free open source ones). With that tool, you’ll be able to measure for example what percentage of time a portion of a code took to execute, and the maximum and minimum time peaks it took, etc.

But for general purposes, FPS can work. Here’s an article that explains why FPS is not the best way to measure efficiency or optimize code.
Dia Kharrat is offline   Reply With Quote
Old 12-30-2004, 05:30 AM   #11
SYS49152
Member
 
Join Date: Sep 2004
Posts: 57
Default

nice link. thank you.

- Andy
SYS49152 is offline   Reply With Quote
Old 09-19-2005, 07:33 AM   #12
ahxian125
New Member
 
Join Date: Sep 2005
Posts: 1
Default Re: Turning VSync off in OpenGL

err...im a newb..where do u put these lines in? to turn off vsync
ahxian125 is offline   Reply With Quote
Old 09-19-2005, 10:09 AM   #13
Ed Mack
DevMaster Staff
 
Join Date: Jul 2003
Location: Northern Ireland
Posts: 1,250
Default Re: Turning VSync off in OpenGL

Anywhere. Just make sure it runs once, and probably run that code once you have opened a window/about to.
Ed Mack is offline   Reply With Quote
Old 09-22-2007, 08:07 AM   #14
Fragztor
New Member
 
Join Date: Sep 2007
Posts: 1
Default Re: Turning VSync off in OpenGL

i dont understand.. where is OpenGL?? ive only heard of it in CS and i dont know where to put the code in?? you said Anywhere and i did.. in my desktop and nothing happend? where shud i put it in?
Fragztor is offline   Reply With Quote
Old 09-22-2007, 10:12 AM   #15
Reedbeta
DevMaster Staff
 
Join Date: Oct 2004
Location: Seattle, WA
Posts: 3,707
Default Re: Turning VSync off in OpenGL

Umm he meant anywhere *in your OpenGL program*, not anywhere in your file system =D

(Actually, should be in the initialization section of the program, not just anywhere.)
___________________________________________
Currently working at Sucker Punch
reedbeta.com - OpenGL demos and other projects
Luabridge - a lightweight, dependency-free C++/Lua binding library.
CD Lite - an unobtrusive, minimal CD player application for Windows.
Reedbeta is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Forum Jump


All times are GMT -7. The time now is 09:05 AM.


Powered by vBulletin
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.