Hi,
I have a question about the best way to handle "batch".
Given a set of shapes, I add them to a batch.
After I want to modify a single shape or delete it.
Then I need to store into variables all shapes in batch. I tried to use a
dictionary.
When I add a shape to the batch, I add also an element to the dictionary
using a number as key for simple access.
*Is it a good way? Any other ideas?*
It seems OK but when I delete the first element of dictionary the behavior
is incorrect.
Here a complete code for tests.
from pyglet.gl import *
window = pyglet.window.Window(resizable=True)
batch = pyglet.graphics.Batch()
# dictionary will be a container for access to single shapes
dictionary = {}
# we add three elements to dictionary
# in the same line we add the shape to the batch
dictionary[0] = batch.add_indexed(3, pyglet.gl.GL_TRIANGLES, None,
(0, 1, 2),
('v2f', (10, 10, 10, 100, 100, 10)),
('c3B', (255, 0, 0) * 3))
dictionary[1] = batch.add_indexed(3, pyglet.gl.GL_TRIANGLES, None,
(0, 1, 2),
('v2f', (10, 10, 70, 200, 200, 70)),
('c3B', (0, 255, 0) * 3))
dictionary[2] = batch.add_indexed(3, pyglet.gl.GL_TRIANGLES, None,
(0, 1, 2),
('v2f', (10, 10, 150, 300, 300, 150)),
('c3B', (0, 0, 255) * 3))
# ##########################
# # Try this:
#
# First test: leave all this part commented
#
# Second test: uncomment ONLY the line below (access and modify a single
shape)
# dictionary[1].vertices=(10, 10, 100, 400, 200, 70)
#
# Third test: uncomment ONLY the line below (delete a single shape)
# dictionary[1].delete()
#
# Fourth test: uncomment ONLY the line below (delete the first shape)
# dictionary[0].delete()
#
# ##########################
@window.event
def on_draw():
window.clear()
batch.draw()
pyglet.app.run()
Inserisci qui il codice...
--
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.