[PyOpenGL-Users] Controlling vertical sync on Mac OS X / crashes when trying to access platform-spe
Brought to you by:
mcfletch
|
From: Nathaniel V. <nat...@gm...> - 2013-06-14 10:19:06
|
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?
By the way, I think it would be really great if a specific
platform-independent way to control vsync could be added to PyOpenGL. It's
a pretty important thing to be able to control.
Best regards,
Nathaniel
--
Nathaniel Virgo
http://nathanielvirgo.com
|