• Advertisement

Archived

This topic is now archived and is closed to further replies.

FPS locked to refresh rate of monitor...

This topic is 5804 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, i currently have my monitor set to 60Hrtz... :D But i don''t want my OpenGL game to be locked @ 60Hrtz. How can i turn this off? I know it is possible to do in DirectX, but is is also possible in OpenGL?

Share this post


Link to post
Share on other sites
Advertisement

don''t know how to do it gl wise,
but you just could run the stuff that has nothing to
do with graphics in another thread, the fps
of this one is "independant" (well, almost :-)
of your graphics thread then.

I think there is no point to have the graphics
running at greater fps than your display gets
updated.


Share this post


Link to post
Share on other sites
You are absolutely right, anyway for people interested:

//--------------------------------------------------------------------------------
// Vsync stuff
//--------------------------------------------------------------------------------
// function pointer typdefs
typedef void (APIENTRY *PFNWGLEXTSWAPCONTROLPROC) (int);
typedef int (*PFNWGLEXTGETSWAPINTERVALPROC) (void);

// declare functions
PFNWGLEXTSWAPCONTROLPROC wglSwapIntervalEXT = NULL;
PFNWGLEXTGETSWAPINTERVALPROC wglGetSwapIntervalEXT = NULL;

//--------------------------------------------------------------------------------
// init VSync func
//--------------------------------------------------------------------------------
void InitVSync()
{
// get extensions of graphics card
char* extensions = (char*)glGetString(GL_EXTENSIONS);

// is WGL_EXT_swap_control in the string? VSync switch possible?
if (strstr(extensions,"WGL_EXT_swap_control"))
{
// get address''s of both functions and save them
wglSwapIntervalEXT = (PFNWGLEXTSWAPCONTROLPROC)wglGetProcAddress("wglSwapIntervalEXT");
wglGetSwapIntervalEXT = (PFNWGLEXTGETSWAPINTERVALPROC)wglGetProcAddress("wglGetSwapIntervalEXT");
}
}

//--------------------------------------------------------------------------------
// Check wheter VSync is on
//--------------------------------------------------------------------------------
bool VSyncEnabled()
{
// if interval is positif, it is not 0 so enabled
return (wglGetSwapIntervalEXT() > 0);
}

//--------------------------------------------------------------------------------
// Set VSync state
//--------------------------------------------------------------------------------
void SetVSyncState(bool enable)
{
if (enable)
wglSwapIntervalEXT(1); // set interval to 1 -> enable
else
wglSwapIntervalEXT(0); // disable
}

Share this post


Link to post
Share on other sites

  • Advertisement