Check explicitly for extension support in OpenGL

Discovered a bug in PyOpenGL under Mesa this morning.  One of those "duh!" moments where you realise you're being a bit too clever and simple about things.  Luckily it was pretty easy to fix, as the whole of the extension hierarchy is auto-generated.

Basically, in OpenGL, extensions and functions > 1.1 are all potentially missing on any given machine.  There are two mechanisms that allow you to query whether a given function is available, glGetString( GL_EXTENSIONS) and glGetString( GL_VERSION ) which allow you to parse a string to determine if the extension you want is supported.

Or, you can try to be lazy/efficient/pythonic and just try to retrieve the pointer to the function and see if it's NULL (see if the behaviour is there rather than seeing if it should be there).  That works beautifully... or did.  Problem is that Mesa now provides "stub" functions for all of the functions it knows about that *might* be supported by an underlying implementation.  That stub is *not* a NULL pointer, so on latest Ubuntu Mesa we believed everything was a valid function.  Argh.

The fix is rather invasive, as it means all extension functions now need to know where they "come from" and check for that extension/version.  Still, with auto-generation that was a 5 minute fix.

So, contrary to the title, you don't actually need to check explicitly for the extensions in PyOpenGL, as we do it for you.  You can continue to check "if function:" to decide if the behaviour is available.  Still, if you're working with raw OpenGL, remember to check for the extension before you use it!

Also fixed a stupid bug in the package, where a stray file wound up breaking Python compilation and stopped installation of the latest Beta.  Will be releasing a new-Beta with both bugs fixed at some point in the very near future.


Comments are closed.


Pingbacks are closed.