Search code examples
pythonpython-3.xopenglpyopengl

OpenGL.error.GLError: GLError {err = 1282}


I'm trying to know the version of Opengl API that I'm using and I'm using this code:

import OpenGL.GL as gl

# Obtenemos la versión de OpenGL API
version = gl.glGetString(gl.GL_VERSION)
print(version)

And I have this error:

OpenGL.error.GLError: GLError(
        err = 1282,
        description = b'operaci\xf3n no v\xe1lida',
        baseOperation = glGetString,
        cArguments = (GL_VERSION,)
)

What do I have to do to solve it?


Solution

  • OpenGL Error 1282 means "invalid operation". You need an OpenGL Context to call an OpenGL API function. Usually, the OpenGL context is created along with the OpenGL window. Therefore, you must create the window before you can call gl.glGetString.