On Fri, Jun 14, 2013 at 3:18 AM, Nathaniel Virgo <firstname.lastname@example.org> wrote:
Hi allI 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
if sys.platform != 'darwin':
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))
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?