使用PyOpenGL获取环境变量的数值

huangapple go评论70阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2023年6月13日 00:32:27
  • 转载请务必保留本文链接:https://go.coder-hub.com/76458618.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定