Re: [PyOpenGL-Users] Controlling vertical sync on Mac OS X / crashes when trying to access platform
Brought to you by:
mcfletch
From: Ian M. <ia...@ge...> - 2013-06-14 19:57:26
|
On Fri, Jun 14, 2013 at 3:18 AM, Nathaniel Virgo <nat...@gm...>wrote: > Hi all > > I need to turn on vsync. Does anyone have a way to do this on OS X? I > found the following code on the web, but when I run it (after creating a > Glut window) it always causes a segmentation fault: > > import sys > > def enable_vsync(): > if sys.platform != 'darwin': > return > try: > import ctypes > import ctypes.util > ogl = ctypes.cdll.LoadLibrary(ctypes.util.find_library("OpenGL")) > # set v to 1 to enable vsync, 0 to disable vsync > v = ctypes.c_int(1) > ogl.CGLSetParameter(ogl.CGLGetCurrentContext(), ctypes.c_int(222), > ctypes.pointer(v)) > except: > print "Unable to set vsync mode, using driver defaults" > > My (very uneducated) guess is that this is because CGLGetCurrentContext > returns an int, whereas CGLSetParameter expects a pointer to a struct as > its first argument. I have tried many permutations of the above code, but I > don't know enough about ctypes to be able to fix it. > > From looking at the PyOpenGL source, it looks like there's some stuff in > there that's aimed at exposing this kind of platform-specific stuff, but I > couldn't find any documentation for it. Is there a "correct" way to call > CGLSetParameter and similar functions? > This seems relevant to GLUT VSync-ing: www.opengl.org/discussion_boards/showthread.php/173017-Vsync-with-glut Ian |