Re: Controlling vertical sync on Mac OS X / crashes when trying to access platform-specific stuff via ctypes
Ian Mallett <[email protected]> Fri, 14 Jun 2013 12:57:04 -0700
| Newsgroups | gmane.comp.python.opengl.user |
|---|---|
| Message-ID | <CAG4NV=sPHmLq1cCKJLrJ7FgDE9qpi_2QmHOUNu==fnLDrLKOiA@mail.gmail.com> |
On Fri, Jun 14, 2013 at 3:18 AM, Nathaniel Virgo <[email protected]>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 ------------------------------------------------------------------------------ This SF.net email is sponsored by Windows: Build for Windows Store. http://p.sf.net/sfu/windows-dev2dev _______________________________________________ PyOpenGL Homepage http://pyopengl.sourceforge.net _______________________________________________ PyOpenGL-Users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/pyopengl-users