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:

import OpenGL
# 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.


One thought on “bug in python-opengl + mesa

  1. If I only had read your analysis earlier. I spent several hours debugging this until I finally concluded that disabling the error checking should do the trick. At least a workaround exists, but what if one actually wants to have error checking enabled? Do you know of any way to make sure glInit is called before the first glGetError is executed?

    Thanks for sharing your findings!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s