使用gletools和教程代码时出现GL_TEXTURE_2D_ARRAY错误

时间:2012-06-17 06:41:53

标签: python opengl pyglet

我正在尝试按照与here.问题的作者相同的教程进行操作 不幸的是,当我尝试在该页面的底部运行示例代码时,我收到以下错误:

Traceback (most recent call last):
  File "C:\Users\Matt\workspace\pygletTest\main.py", line 9, in <module>
    from gletools import ShaderProgram, FragmentShader, VertexShader
  File "build\bdist.win32\egg\gletools\__init__.py", line 9, in <module>
    # See the README file for information on usage and redistribution.
  File "build\bdist.win32\egg\gletools\texture.py", line 454, in <module>
  File "build\bdist.win32\egg\gletools\texture.py", line 455, in ArrayTexture
NameError: name 'GL_TEXTURE_2D_ARRAY' is not defined

我在Windows Vista上使用Python 2.6和Eclipse。关于如何解决这个问题的任何想法?

1 个答案:

答案 0 :(得分:1)

你可能正在使用与编写gletools的人不同的pyglet版本。不幸的是,他对此有点不明确。对OpenGL常量的绑定是错误的。

转到pyglet \ gl文件夹,例如C:\ Python \ Lib \ site-packages \ pyglet \ gl,找到glext_nv.py。该文件包含所有OpenGL常量的映射。搜索GL_TEXTURE_2D_ARRAY(可能命名为GL_TEXTURE_2D_ARRAY_EXT或其他内容)。在我的系统上,它是

GL_TEXTURE_2D_ARRAY_EXT = 35866     # GL/glext.h:3183

并且例如编辑texture.py以在定义之后使用整数而不是关键字本身。 E.g。

#target = GL_TEXTURE_2D_ARRAY
target = 35866

或者,您可以更新绑定的名称,但由于某种原因,这对我不起作用。您可能需要做一些类似的更改。