How to use NSOpenGLContext.setValues_forParameter_ with PyObjC <= 2.2?
Phillip Nguyen <[email protected]>
| Newsgroups | gmane.comp.python.pyobjc.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi,
I'm writing code for Snow Leopard that I would like to support the default installed version of PyObjC. I'm calling NSOpenGLContext.setValues_forParameter_() which takes as its first argument a pointer to an int (or array of ints). It seems to work fine in PyObjC 2.3, but in PyObjC 2.2b3 I get
ValueError: depythonifying 'pointer', got 'int'
I don't know enough about PyObjC to figure out how to supply the 'pointer' that it wants. Currently I am using a horrible hack involving ctypes:
def set_vsync(self, vsync=True):
from objc import __version__ as pyobjc_version
if pyobjc_version[:3] in ('2.3', '2.4'):
self._nscontext.setValues_forParameter_(vsync, NSOpenGLCPSwapInterval)
else:
# This is an ugly hack, but it works.
cglContext = self._nscontext.CGLContextObj()
dir(cglContext) # must call dir in order to access pointerAsInteger???
from ctypes import cdll, util, c_void_p, c_int, byref
ctypes_context = c_void_p(cglContext.pointerAsInteger)
quartz = cdll.LoadLibrary(util.find_library('Quartz'))
value = c_int(vsync)
kCGLCPSwapInterval = 222
quartz.CGLSetParameter(ctypes_context, kCGLCPSwapInterval, byref(value))
So my question is: what is the correct way to write the else statement code in PyObjC 2.2? And why can I access cglContext.pointerAsInteger only after calling dir(cglContext)?
--phillip
------------------------------------------------------------------------------
The modern datacenter depends on network connectivity to access resources
and provide services. The best practices for maximizing a physical server's
connectivity to a physical network are well understood - see how these
rules translate into the virtual world?
http://p.sf.net/sfu/oracle-sfdevnlfb