So I am trying to use the batch class in pyglet to make some faces like this
class Block:
def __init__(self, pos):
self.pos = pos
self.top = self.get_tex('img.png')
self.batch = pyglet.graphics.Batch()
tex_coords = ('t2f',(0,0, 1,0, 1,1, 0,1, ))
self.batch.add(4, GL_QUADS, self.top, ('v3f', (self.add(pos, [0, 1, 0]), self.add(pos, [0, 1, 1]), self.add(pos, [1, 1, 1]), self.add(pos, [1, 1, 0]))), tex_coords)
def add(self, vec, toAdd):
vec = list(vec)
toAdd = list(toAdd)
vec[0] += toAdd[0]
vec[1] += toAdd[1]
vec[2] += toAdd[2]
return vec
def get_tex(self, file):
tex = pyglet.image.load(file).get_texture()
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST)
return pyglet.graphics.TextureGroup(tex)
But I get the error:
ValueError: Can only assign sequence of same size