Extensions and Conditional
Functionality PyOpenGL has support for
most OpenGL extensions. Extensions
are available as "normal" function
pointers by importing the constructed
package name for the extension, for
instance:from OpenGL.GL.ARB.vertex_buffer_object import * buffer = glGenBuffersARB(1)
there is no need to call
initialization functions or the like
for the extension module. You can, if
you like, call the "init" function for
the extension to retrieve a boolean
indicating whether the local machine
supports a given extension, like so:if glInitVertexBufferObjectARB():
...
However, it is normally clearer to
test for the boolean truth of the
entry points you wish to use:if (glGenBuffersARB):
buffers = glGenBuffersARB( 1 )
There are often a
number of entry points which implement
the same API, for which you would like
to use whichever implementation is
available (likely with some preference
in order). The OpenGL.extensions
module provides an easy mechanism to
support this:from OpenGL.extensions import alternate
glCreateProgram = alternate( 'glCreateProgram', glCreateProgram, glCreateProgramObjectARB)
glCreateProgram = alternate( glCreateProgram, glCreateProgramObjectARB)
If the first
element is a string it will be used as
the name of the alternate object,
otherwise the name is taken from the
first argument.