1

I'm attempting to follow along with the same tutorial as the author of the question here. Unfortunately, when I try to run the example code at the bottom of that page, I get the following error:

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

I'm using Python 2.6 and Eclipse on Windows Vista. Any ideas on how to resolve this?

Community
  • 1
  • 1
MattyZ
  • 1,541
  • 4
  • 24
  • 41

1 Answers1

1

You are probably using a different version of pyglet than the guy who wrote gletools. He was unfortunately a bit unspecific with regards to this. The bindings to the OpenGL constants are wrong.

Go to the pyglet\gl folder, something like C:\Python\Lib\site-packages\pyglet\gl and find glext_nv.py. This file has the mappings for all the OpenGL constants. Search for GL_TEXTURE_2D_ARRAY (which might be named GL_TEXTURE_2D_ARRAY_EXT or something else). On my system, it is

GL_TEXTURE_2D_ARRAY_EXT = 35866     # GL/glext.h:3183

and for instance edit texture.py to use the integer after the definition instead of the keyword itself. E.g.

#target = GL_TEXTURE_2D_ARRAY
target = 35866

Alternatively, you could update the name of the binding, but for some reason this didn't work for me. You may have to do a couple of similar changes.

Geir Smestad
  • 1,344
  • 2
  • 15
  • 25