On 11/5/08, josch <[EMAIL PROTECTED]> wrote:
>
> consider this code:
>
> import pyglet
>
> atlas1 = pyglet.image.atlas.TextureAtlas()
> atlas2 = pyglet.image.atlas.TextureAtlas()
>
> texture_group1 = pyglet.graphics.TextureGroup(atlas1.texture)
> texture_group2 = pyglet.graphics.TextureGroup(atlas2.texture)
> group1 = pyglet.graphics.OrderedGroup(0, texture_group1)
> group2 = pyglet.graphics.OrderedGroup(1, texture_group2)
> group3 = pyglet.graphics.OrderedGroup(2, texture_group1)
>
> tile1 = atlas1.add(pyglet.image.load(None,
> file=pyglet.resource.file('test.png')))
> tile2 = atlas2.add(pyglet.image.load(None,
> file=pyglet.resource.file('test.png')))
> tile3 = atlas1.add(pyglet.image.load(None,
> file=pyglet.resource.file('test.png')))
>
> batch = pyglet.graphics.Batch()
> vertex_list = []
>
> vertex_list.append(batch.add(4, pyglet.gl.GL_QUADS, group1,
> ('v2i', [0, 0, 32, 0, 32, 32, 0, 32]),
> ('t3f', tile1.tex_coords),
> ('c4B', (255,255,255,255)*4)))
>
> vertex_list.append(batch.add(4, pyglet.gl.GL_QUADS, group2,
> ('v2i', [8, 8, 40, 8, 40, 40, 8, 40]),
> ('t3f', tile2.tex_coords),
> ('c4B', (255,255,255,255)*4)))
>
> vertex_list.append(batch.add(4, pyglet.gl.GL_QUADS, group3,
> ('v2i', [16, 16, 48, 16, 48, 48, 16, 48]),
> ('t3f', tile3.tex_coords),
> ('c4B', (255,255,255,255)*4)))
>
> window = pyglet.window.Window(800, 600)
>
> @window.event
> def on_draw():
> pyglet.gl.glClear(pyglet.gl.GL_COLOR_BUFFER_BIT)
> batch.draw()
>
> pyglet.app.run()
>
> I would assume that from the ordering in the OrderedGroup that the
> vertex lists are drawn in this order:
> tile1, tile2, tile3
> but when executing this code it can be seen that they get drawn in
> this order:
> tile1, tile3, tile2
>
> why? is this a bug?
No, groups are sorted by their parents first -- this is to reduce the
number of state changes. If you need to use atlas1 both before and
after atlas2, it will need to appear at least twice in the batch's
rendering order.
You may find the PYGLET_DEBUG_GRAPHICS_BATCH environment variable
useful; see http://pyglet.org/doc/programming_guide/debugging_tools.html
Alex.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pyglet-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/pyglet-users?hl=en
-~----------~----~----~----~------~----~------~--~---