[pypy-dev] pyopengl on pypy, take 2

rndblnch rndblnch at gmail.com
Thu Dec 2 17:21:47 CET 2010


hi,


with your help, i have been able to patch pyopengl to make non-trivial 
glut/opengl interactive programs (involving shaders, vertex and pixel buffers)
run on pypy.
the programs:
http://bitbucket.org/rndblnch/opengl-programmable/

some details about pyopengl modifications here:
http://thread.gmane.org/gmane.comp.python.opengl.devel/1004/focus=1007


the only thing i add to change that is not already in the pypy svn is a minor 
check in _ctypes._Pointer.setcontents to make it raise a TypeError rather than 
an AttributeError if the value passed do not have a _ensure_objects method:

 class _Pointer(_CData):
     def setcontents(self, value):
         if not isinstance(value, self._type_):
             raise TypeError("expected %s instead of %s" % (
                 self._type_.__name__, type(value).__name__))
         self._objects = {keepalive_key(1):value}
+        if not hasattr(value, "_ensure_objects"):
+            raise TypeError
         if value._ensure_objects() is not None:
             self._objects[keepalive_key(0)] = value._objects
         value = value._buffer
         self._buffer[0] = value

a better check might be "if not isinstance(value, _CData)". i hope you will
consider this minor change for inclusion into pypy's ctypes implementation.


i still have other issues, but at least all my programs run and are interactive.
i have not looked at the performance, but i have a question on this aspect: 
since most of the python code is executed as c callbacks passed to glut, should
i except any gain at all? is pypy able to jit those functions wrapped by ctypes
and passed down as callbacks to a c library?

thanks again,

renaud







More information about the Pypy-dev mailing list