Sign in to follow this  
IrYoKu1

How can I disable vsync using GLUT under Vista?

Recommended Posts

IrYoKu1    174
Hi, As I am benchmarking shaders, I need to disable vsync. I know there are issues with vsync stuff in Vista in windowed mode, so I have used the Game mode in GLUT in order to switch to fullscreen. But it's still vsync'ed by default. There is some way of disabling vsync using GLUT? Or maybe the problem is in some other place? Thanks In Advance, Jorge

Share this post


Link to post
Share on other sites
vibe3d    100
it's not a glut issue...it's a simple extension to do this.

wglSwapIntervalEXT(0) will disable vsync under windows.

i know the nvidia control panel allows you to globally disable vsync, although i don't like doing that.

anyway this is yet another question that could have been VERY EASILY answered using a simple google search.

Share this post


Link to post
Share on other sites
Kambiz    758

//Download wglext.h from http://oss.sgi.com/projects/ogl-sample/sdk.html
#include <gl\wglext.h>

PFNWGLSWAPINTERVALEXTPROC wglSwapIntervalEXT = NULL;
PFNWGLGETSWAPINTERVALEXTPROC wglGetSwapIntervalEXT = NULL;


//from NeHe Lesson 45
bool IsExtensionSupported( char* szTargetExtension )
{
const unsigned char *pszExtensions = NULL;
const unsigned char *pszStart;
unsigned char *pszWhere, *pszTerminator;

// Extension names should not have spaces
pszWhere = (unsigned char *) strchr( szTargetExtension, ' ' );
if( pszWhere || *szTargetExtension == '\0' )
return false;

// Get Extensions String
pszExtensions = glGetString( GL_EXTENSIONS );

// Search The Extensions String For An Exact Copy
pszStart = pszExtensions;
for(;;)
{
pszWhere = (unsigned char *) strstr( (const char *) pszStart, szTargetExtension );
if( !pszWhere )
break;
pszTerminator = pszWhere + strlen( szTargetExtension );
if( pszWhere == pszStart || *( pszWhere - 1 ) == ' ' )
if( *pszTerminator == ' ' || *pszTerminator == '\0' )
return true;
pszStart = pszTerminator;
}
return false;
}

bool InitVSync()
{
if (IsExtensionSupported("WGL_EXT_swap_control"))
{
wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC)
wglGetProcAddress("wglSwapIntervalEXT");
wglGetSwapIntervalEXT = (PFNWGLGETSWAPINTERVALEXTPROC)
wglGetProcAddress("wglGetSwapIntervalEXT");
return true;
}
return false;// WGL_EXT_swap_control not supported
}
bool SetVSync(bool VSync)
{
if(!wglSwapIntervalEXT) return false;
wglSwapIntervalEXT(VSync);
return true;
}
bool GetVSync(bool* VSync)
{
if(!wglGetSwapIntervalEXT) return false;//VSynce value is not valid...
*VSync = wglGetSwapIntervalEXT();
return true;
}






Links:
wglext.h
WGL_EXT_swap_control

Share this post


Link to post
Share on other sites
IrYoKu1    174
I searched in the wrong direction it seems.

As I am using glew I can use wglGetSwapIntervalEXT by simply including <GL/wglew.h>

Thanks to both for your help.

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