i have been trying batches work in pyglet, confused error message "too many values unpack" coming pyglet/graphics/__init__.py
file. guess that doing wrong syntaxwise when adding geometry batch.
i cut down code essential parts create error:
from pyglet.gl import * pyglet.graphics import * import pyglet batch = pyglet.graphics.batch() img = pyglet.image.load('pic.png') texture = img.get_texture() class textureenablegroup(pyglet.graphics.group): def set_state(self): glenable(gl_texture_2d) def unset_state(self): gldisable(gl_texture_2d) texture_enable_group = textureenablegroup() class texturebindgroup(pyglet.graphics.group): def __init__(self, texture): super(texturebindgroup, self).__init__(parent=texture_enable_group) self.texture = texture def set_state(self): glbindtexture(gl_texture_2d, self.texture.id) gltexparameteri(gl_texture_2d, gl_texture_mag_filter, gl_linear) gltexparameteri(gl_texture_2d, gl_texture_min_filter, gl_linear) def __eq__(self, other): return (self.__class__ other.__class__ , self.texture == other.__class__) batch.add(12, gl_triangles, texturebindgroup(texture), (('t2f', (0, 0)), ('v3f', (64, 64, 0)), ('t2f', (1, 1)), ('v3f', (-64, -64, 205)), ('t2f', (0, 1)), ('v3f', (-64, 64, 205)), ('t2f', (1, 1)), ('v3f', (64, -64, 205)), ('t2f', (1, 0)), ('v3f', (64, 64, 0)), ('t2f', (0, 1)), ('v3f', (-64, -64, 205))))
your problem in line:
batch.add(12, gl_triangles, texturebindgroup(texture), (('t2f', (0, 0)), ('v3f', (64, 64, 0)), ('t2f', (1, 1)), ('v3f', (-64, -64, 205)), ('t2f', (0, 1)), ('v3f', (-64, 64, 205)), ('t2f', (1, 1)), ('v3f', (64, -64, 205)), ('t2f', (1, 0)), ('v3f', (64, 64, 0)), ('t2f', (0, 1)), ('v3f', (-64, -64, 205))))
i believe should be:
batch.add(12, gl_triangles, texturebindgroup(texture), ('t2f', (0, 0)), ('v3f', (64, 64, 0)), ('t2f', (1, 1)), ('v3f', (-64, -64, 205)), ('t2f', (0, 1)), ('v3f', (-64, 64, 205)), ('t2f', (1, 1)), ('v3f', (64, -64, 205)), ('t2f', (1, 0)), ('v3f', (64, 64, 0)), ('t2f', (0, 1)), ('v3f', (-64, -64, 205)))
notice how changed last argument format ((tuple), (tuple))
(tuple), (tuple))
. i'm not familiar pyglet, discovered correct way of calling batch.add()
documentation. note *data
represents variable list of parameters @ end of function call, not tuple or list attempted.
try , let know how works out you.
Comments
Post a Comment