英文:
Obtaining values for environmental variables using PyOpengl
问题
我试图使用pyOpengl获取GL_MAX_RENDERBUFFER_SIZE
值,使用以下代码:
size = glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE)
但是我收到以下错误:
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),
)
)
获取这个信息的正确方式是什么?
英文:
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?
答案1
得分: 1
'无效操作' 表示您在创建 OpenGL 上下文 之前尝试检索参数。通常,OpenGL 上下文会与 OpenGL 窗口一同创建。在这之前,您不能使用任何 OpenGL API 函数。
英文:
'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.
答案2
得分: 0
因此,我之前没有得到任何答案的原因是因为我在OpenGL中没有初始化上下文(即窗口)的情况下询问此信息。我以为可以随时向系统询问这个问题,但显然这不是真的。
英文:
Okay. The reason why I was not getting any answer was because I was asking this information without initializing a context (i.e. a window) in opengl. I thought that one could ask this from the system at anytime but apparently this is not true.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论