bug in python-opengl + mesa

Since like forever, I have never succeed in executing python-opengl demos on debian lenny. It always segfault during glutInitDisplayMode. After some debugging, here is why.

One should be able to call glGetError at any time. If there’s nothing wrong, it should just return something like GLNOERROR. Any raw (native) function call in python-opengl, no matter it belongs to GL, GLU or GLUT, will always call glGetError right after each call to check for error. I think this is wrong since functions like glutInitDisplayMode have NOTHING to do with glGetError. With mesa 7.0.3-5 in my system, the call to glGetError without glInit will cause segfault. I check the same thing on Ubuntu, which has an older version of mesa and python-opengl, and it does not happen.

python-opengl enabled error checking by default with OpenGL.ERROR_CHECKING, which is set to True in OpenGL/__init__.py. This code snippet can disable it:

1
2
3
import OpenGL
OpenGL.ERROR_CHECKING = False
# import other stuffs such as OpenGL.GL, etc.

or you can just modify the __init__.py to disable it by default.

Given the current status of python-opengl and low level x protocol support in python, I think the best language to do 3D in FOSS world will still be pure simple C.