Using extension functions

Before using an extension function, you should check that the extension is implemented by the current driver. Typically this is done using glGetString(GL_EXTENSIONS), but pyglet has a convenience module, pyglet.gl.gl_info that does this for you:

if pyglet.gl.gl_info.have_extension('GL_ARB_shadow'):
    # ... do shadow-related code.
else:
    # ... raise an exception, or use a fallback method

You can also easily check the version of OpenGL:

if pyglet.gl.gl_info.have_version(1,5):
    # We can assume all OpenGL 1.5 functions are implemented.

Remember to only call the gl_info functions after creating a window.

There is a corresponding glu_info module for checking the version and extensions of GLU.

nVidia often release hardware with extensions before having them registered officially. When you import * from pyglet.gl you import only the registered extensions. You can import the latest nVidia extensions with:

from pyglet.gl.glext_nv import *