All,

I'm looking at the pyglet opengl imaging 
documentation<http://www.pyglet.org/doc/programming_guide/opengl_imaging.html> 
and 
am unable to run the example code block:

(trimmed: my own inferred pyglet imports, "kitten = pyglet.image.load(...)")

texture = kitten.get_texture()
t = texture.tex_coords
w, h = texture.width, texture.height
array = (GLfloat * 32)(
     t[0][0], t[0][1], t[0][2], 1.,
     x,       y,       z,       1.,
     t[1][0], t[1][1], t[1][2], 1.,
     x + w,   y,       z,       1.,
     t[2][0], t[2][1], t[2][2], 1.,
     x + w,   y + h,   z,       1.,
     t[3][0], t[3][1], t[3][2], 1.,
     x,       y + h,   z,       1.)

glPushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT)
glInterleavedArrays(GL_T4F_V4F, 0, array)
glDrawArrays(GL_QUADS, 0, 4)
glPopClientAttrib()

The error I get is at the "array = ":

Traceback (most recent call last):
>   File "./simple_test.py", line 27, in <module>
>     t[0][0], t[0][1], t[0][2], 1., 
> TypeError: 'float' object has no attribute '__getitem__'


Viewing the texture.tex_coords data (e.g. the data referenced by "t[0][0]" 
that is causing the error) shows why:

(0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 0.0)


This is a single-dimension array, but the example code is expecting 
something else. Is the documentation incorrect, or am I doing something 
wrong?

Me: OS X 10.7.5, pyglet 1.2alpha1

-- 
You received this message because you are subscribed to the Google Groups 
"pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/pyglet-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to