Sorry, I had left for vacation and just got back. I have experimented with depth test before, but there were many problems with alpha and textures.
The problems were really random and varied. Sometimes, the textures would show black where the alpha, sometimes they would load properly depending on the order they were added to the batch. How were you able to solve the weird behavior regarding depth testing and alpha? On Friday, April 29, 2016 at 5:16:13 PM UTC-5, [email protected] wrote: > > Adding/removing for ordering is unnecessary, you just need to enable depth > testing and change the relevant textures z coordinates (between 1.0 to 0.0): > > import pyglet > from pyglet.gl import * > > class group(pyglet.graphics.OrderedGroup): > def set_state(self): > if self.order == 0: > glBindTexture(GL_TEXTURE_2D, texture.id) > elif self.order == 1: > glBindTexture(GL_TEXTURE_2D, texture2.id) > > window = pyglet.window.Window(640,480) > > glEnable(GL_DEPTH_TEST) > > rendered_sprites = [] > > batch = pyglet.graphics.Batch() > > batch_idle = pyglet.graphics.Batch() > > texture = pyglet.image.load('test.png').get_texture() > > texture2 = pyglet.image.load('test2.png').get_texture() > > rendered_sprites.append(batch.add(4, GL_QUADS, group(0), > ('v3f/static', (0.0,0.0,0.0, 32.0,0.0, > 0.0, 32.0,32.0,0.0, 0.0,32.0,0.0)), > ('t3f/static', texture.tex_coords))) > > rendered_sprites.append(batch.add(4, GL_QUADS, group(1), > ('v3f/static', (16.0,0.0,0.0, 48.0,0.0, > 0.0, 48.0,32.0,0.0, 16.0,32.0,0.0)), > ('t3f/static', texture2.tex_coords))) > > > @window.event > def on_draw(): > window.clear() > glEnable(GL_TEXTURE_2D) > batch.draw() > glDisable(GL_TEXTURE_2D) > > @window.event > def on_key_press(symbol,modifiers): > if symbol == pyglet.window.key.SPACE: > if rendered_sprites[1].vertices[2] == 0.0: > for a in xrange(2,12,3): > rendered_sprites[1].vertices[a] = 1.0 > else: > for a in xrange(2,12,3): > rendered_sprites[1].vertices[a] = 0.0 > > pyglet.app.run() > > Pyglet also has multi-texturing support, if your inclined to use multiple > textures per surface. > -- 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 https://groups.google.com/group/pyglet-users. For more options, visit https://groups.google.com/d/optout.
