Unsupported Binding in PyOpenGL (Python)

In python’s Open GL wrapper, there are several bindings missing. E.g. if we would like to implement a geometry shader, the glProgramParameteri is missing (defined as a zero function pointer).

Here is a small piece of code that defines glProgramParameteri, but this could easily be modified to define any missing opengl call.

#These three defines exist in OpenGL.GL, but does not correspond to those used here
_glProgramParameteri = None
def glProgramParameteri( program, pname, value  ):
    global _glProgramParameteri
    if not _glProgramParameteri:
        import ctypes
        # Open the opengl32.dll
        gldll = ctypes.windll.opengl32
        # define a function pointer prototype of *(GLuint program, GLenum pname, GLint value)
        prototype = ctypes.WINFUNCTYPE( ctypes.c_int, ctypes.c_uint, ctypes.c_uint, ctypes.c_int )
        # Get the win gl func adress
        fptr = gldll.wglGetProcAddress( 'glProgramParameteriEXT' )
        if fptr==0:
            raise Exception( "wglGetProcAddress('glProgramParameteriEXT') returned a zero adress, which will result in a nullpointer error if used.")
        _glProgramParameteri = prototype( fptr )
    _glProgramParameteri( program, pname, value )

Good luck :slight_smile: