Sign in to follow this  
deepsender

Vsync and fps

Recommended Posts

deepsender    100
I want to turn off the vsync on my card in order to see actual frame rates while developing in Opengl. I've come up with this code.
void setVSync(void)
{
	typedef bool (APIENTRY *PFNWGLSWAPINTERVALFARPROC)(int);
	PFNWGLSWAPINTERVALFARPROC wglSwapIntervalEXT = 0;
	wglSwapIntervalEXT = (PFNWGLSWAPINTERVALFARPROC)wglGetProcAddress("WGL_EXT_swap_control");
	if (wglSwapIntervalEXT) wglSwapIntervalEXT(0);
}

My frame rate stays at 60. Even when I turn vsync off through my hardware, fps=60. What might be going wrong here? Thanks for any help.

Share this post


Link to post
Share on other sites
bakery2k1    712
This line:
wglSwapIntervalEXT = (PFNWGLSWAPINTERVALFARPROC)wglGetProcAddress("WGL_EXT_swap_control");
will not work. Your wglSwapIntervalEXT variable will be set to NULL, since the parameter to wglGetProcAddress needs to be a function name. You need:
wglSwapIntervalEXT = (PFNWGLSWAPINTERVALFARPROC)wglGetProcAddress("wglSwapIntervalEXT");


EDIT: Also make sure you have a valid OpenGL context (i.e., you have created your OpenGL-enabled window) before calling this function.

Share this post


Link to post
Share on other sites
deepsender    100
I made the code correction, and still no change in frame rate. My card's vertical sync is set to Application-controlled.

I'm executing the setVSync() during the call to the InitGL() procedure.


To get fps, I execute this code each time I draw a scene.

nframes++;
t = GetTickCount() - start_ticks;
if (t > 1000) {
frames_per_second = nframes;
nframes = 0;
start_ticks = GetTickCount();
}

The frame rate stays at 60 or very close.

If it helps, I'm working on a notebook with an Nvidia GeForce Go 6800 Ultra.

Thanks.

Share this post


Link to post
Share on other sites
deepsender    100
If the code above doesn't work, does that mean something is wrong with my graphic card setup?

Shouldn't vsync be handled internally by OpenGL?

Is this subject addressed in any of the NeHe tutorials, or anywhere on their site? I couldn't find it.

Am I posting in the wrong forum?

I'm using the tauren12 method of trying to get an answer here.

Thanks.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this