alexin
February 22nd, 2008, 06:26 AM
I have the following code to turn vsync on or off:
void Application::setVSync(bool vsync) throw(OcasoException){
typedef BOOL (APIENTRY *PFNWGLSWAPINTERVALFARPROC)(int);
PFNWGLSWAPINTERVALFARPROC wglSwapIntervalEXT = 0;
const char* extensions = (char*) glGetString(GL_EXTENSIONS);
if(strstr(extensions, "WGL_EXT_swap_control") == 0 ){
throw OcasoException("Extension not supported.");
}else{
wglSwapIntervalEXT = (PFNWGLSWAPINTERVALFARPROC) wglGetProcAddress("wglSwapIntervalEXT");
if(wglSwapIntervalEXT){
wglSwapIntervalEXT(vsync ? 1 : 0);
}
}
}
The code fails in the first 'if' statement. The debugger says 'extensions' is a bad pointer.
What's the problem? Is there a better way to turn vsync on or off?
void Application::setVSync(bool vsync) throw(OcasoException){
typedef BOOL (APIENTRY *PFNWGLSWAPINTERVALFARPROC)(int);
PFNWGLSWAPINTERVALFARPROC wglSwapIntervalEXT = 0;
const char* extensions = (char*) glGetString(GL_EXTENSIONS);
if(strstr(extensions, "WGL_EXT_swap_control") == 0 ){
throw OcasoException("Extension not supported.");
}else{
wglSwapIntervalEXT = (PFNWGLSWAPINTERVALFARPROC) wglGetProcAddress("wglSwapIntervalEXT");
if(wglSwapIntervalEXT){
wglSwapIntervalEXT(vsync ? 1 : 0);
}
}
}
The code fails in the first 'if' statement. The debugger says 'extensions' is a bad pointer.
What's the problem? Is there a better way to turn vsync on or off?