Search code examples
pythonopenglpyopengl

Obtaining values for environmental variables using PyOpengl


Simple query. I am trying to get access to the GL_MAX_RENDERBUFFER_SIZE value using pyOpengl using the following:

size= glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE)

But I get the following error

File c:\Python\Miniconda3\envs\opengl\Lib\site-packages\OpenGL\error.py:230, in _ErrorChecker.glCheckError(self, result, baseOperation, cArguments, *args)
    228 err = self._currentChecker()
    229 if err != self._noErrorResult:
--> 230     raise self._errorClass(
    231         err,
    232         result,
    233         cArguments = cArguments,
    234         baseOperation = baseOperation,
    235     )
    236 return result

GLError: GLError(
    err = 1282,
    description = b'invalid operation',
    baseOperation = glGetIntegerv,
    pyArgs = (
        GL_MAX_RENDERBUFFER_SIZE,
        ,
    ),
    cArgs = (
        GL_MAX_RENDERBUFFER_SIZE,
        array([0], dtype=int32),
    ),
    cArguments = (
        GL_MAX_RENDERBUFFER_SIZE,
        array([0], dtype=int32),
    )
)

What is the correct way of retrieving this information?


Solution

  • 'invalid operation' indicates that you are trying to retrieve the parameter before the OpenGL Context has been created. Usually, the OpenGL Context is created along with the OpenGL window. You cannot use any OpenGL API function until this is done.