On Sun, Nov 10, 2013 at 12:31 PM, Mikolaj <[email protected]> wrote:
> Thanks, that was what I needed. I don't know anything about opengl yet, so
> this is a bit mystical for me, but I will have to learn some of it in the
> future, to do things like "show green ellipse around selected agents" etc.
>
> What was meant in the comments about group? I didn't understand this:
>
> ## TODO:
>> ## needs a proper group for the batch,
>> ## push / pop of attribute bit probably want to go to the group
>>
>
>
>
>
workaround to not use groups:
add
gl.glColor4ub(*self.color4u)
in draw, just before the self.batch.draw()
A word about groups and batches:
A pyglet batch represents a collection of homogeneous (vertex, <vertex
attribute 1>,..) intended to be drawn all in the same primitive mode
(GL_POINTS, GL_TRIANGLES, etc)
The collection can be broken into subsets, each one with an associated
pyglet.graphics.Group
The batch draw is something akin to (**pseudocode**)
for each group in batch:
group.set_state()
gl_draw_list( batch.set_primitive_mode(),
group.vertices_with_attributes)
group.unset_state()
Typical operations to do in group.set_state : call glColor if needed, bind
texture(s), set parameters for shaders, preserve gl state that we want
restored after the draw, set blend mode
By defining proper groups, two collections of vertices that want slightly
different gl state can be in the same batch, which
is better for memory management
by using hierarchical set / unset states, the total number of gl stte
changes are reduced, so better performance
Read more in the pyglet programming guide,
http://www.pyglet.org/doc/programming_guide/batched_rendering.html
Also, the slides and code from
http://tartley.com/?p=378
can help to understand pyglet batches.
Returning to the sample code, the comment about moving certain bits of
functionality to a group tried to suggest moving some things from the
node.draw to a group.set_state, to be more near to the usage pattern of
pyglet batches.
--
You received this message because you are subscribed to the Google Groups
"cocos2d discuss" 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 http://groups.google.com/group/cocos-discuss.
For more options, visit https://groups.google.com/groups/opt_out.