Advertisement

VSync

Started by September 25, 2002 05:54 AM
1 comment, last by moromete 22 years, 5 months ago
How can i disable VSync in a program that is using OpenGL ? I think swapbuffers or endscene does wait for it but i want to disable it. I can do this in any way ? moromete PS. I would love to search for an older post about this subject but the search system kindly replyed : The system is not functioning
There was a example on this at www.steinsoft.ner but it seems to be removed.

Here is a code that disables vsync from the steinsoft site:

include  //for wglGetProcAddress(..)#include <GL\gl.h> //for glGetString(..)#include <string.h> //for strstr(..)//function pointer typdefstypedef void (APIENTRY *PFNWGLEXTSWAPCONTROLPROC) (int);typedef int (*PFNWGLEXTGETSWAPINTERVALPROC) (void);//declare functionsPFNWGLEXTSWAPCONTROLPROC wglSwapIntervalEXT = NULL;PFNWGLEXTGETSWAPINTERVALPROC wglGetSwapIntervalEXT = NULL;//init VSync funcvoid 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");  }} bool VSyncEnabled(){  //if interval is positif, it is not 0 so enabled   return (wglGetSwapIntervalEXT() > 0);}void SetVSyncState(bool enable){  if (enable)    wglSwapIntervalEXT(1); //set interval to 1 -> enable  else    wglSwapIntervalEXT(0); //disable}


You can simply use this three functions.
At first call InitVSync() and then the another funcs.

PM
PM Times change... Excuse my poor english!
Advertisement
Thank you very much for your answer.
I will try it right now as soon as i understand what it does

moromete

This topic is closed to new replies.

Advertisement