I’ve found a function that implements vertical sync under linux with only one call, it have dependencies on two gdk functions, it’s implemented in the gtk port i’ve posted in the extend section in the file ofAppRunner.cpp from line 428 plus two typedefs at the begining of the file: http://forum.openframeworks.cc/t/of-gtk±port/560/0
I don’t understand very much about opengl so I don’t know if it can be used with glut but just in case:
typedef GLvoid
(*glXSwapIntervalSGIFunc) (GLint);
typedef GLvoid
(*glXSwapIntervalMESAFunc) (GLint);
//--------------------------------------
void ofSetVerticalSync(bool bSync){
//----------------------------
#ifdef TARGET_WIN32
//----------------------------
if (bSync) {
if (GLEE_WGL_EXT_swap_control) wglSwapIntervalEXT (1);
} else {
if (GLEE_WGL_EXT_swap_control) wglSwapIntervalEXT (0);
}
//----------------------------
#endif
//----------------------------
//--------------------------------------
#ifdef TARGET_OSX
//--------------------------------------
long sync = bSync == true ? 1 : 0;
CGLSetParameter (CGLGetCurrentContext(), kCGLCPSwapInterval, &sync);
//--------------------------------------
#endif
//--------------------------------------
//--------------------------------------
#ifdef TARGET_LINUX
//--------------------------------------
gint iInterval = bSync == true ? 2 : 0;
const gchar* pcDummy = NULL;
glXSwapIntervalSGIFunc glXSwapIntervalSGI = 0;
glXSwapIntervalMESAFunc glXSwapIntervalMESA = 0;
pcDummy = glXQueryExtensionsString (GDK_DISPLAY_XDISPLAY
(gdk_display_get_default ()), 0);
if (g_strrstr (pcDummy, "GLX_SGI_swap_control") != NULL)
{
glXSwapIntervalSGI = (glXSwapIntervalSGIFunc)
gdk_gl_get_proc_address ("glXSwapIntervalSGI");
if (glXSwapIntervalSGI)
glXSwapIntervalSGI (iInterval);
else
g_print ("Could not get glXSwapIntervalSGI()\n");
}
else if (g_strrstr (pcDummy, "GLX_MESA_swap_control") != NULL)
{
glXSwapIntervalMESA = (glXSwapIntervalMESAFunc)
gdk_gl_get_proc_address ("glXSwapIntervalMESA");
if (glXSwapIntervalMESA)
glXSwapIntervalMESA (iInterval);
else
g_print ("Could not get glXSwapIntervalMESA()\n");
}
else
g_print ("Unable to switch sync-to-vblank on.\n");
//--------------------------------------
#endif
//--------------------------------------
}