wohoo this worked!! \o/
http://phpfi.com/352060
i already used the TextureGroup to automatically apply the state
changes you mentioned (by looking at the pyglet source TextureGroup
does excactly what you posted and even does glDisable() ) and also
draw a 60x38 grid of random water tiles (without animation yet).
however there are still a few issues:
first i disabled vsync and added an update function that (i hope) is
called as often as possible and get only around 110fps with core2duo/
gma965 - when i uncomment the clear() function in on_draw() i get up
to 180fps. but considering all the other stuff i will add (more layers
and animated tiles and map objects) isnt that a bit low? why?
also i got a bit troubled with the TextureGroup. It needs a texture
that it later will enable and bind and this works fine with using a
TextureAtlas as in my current code but when i try to use the
recommended resource.image module which automatically will create new
TextureAtlas'es - how do i get the (maybe multiple) textures then?

future questions:
when i now want to move on the map i have to refill the batch - i do
this via deleting the vertex_list and refilling the batch again with
add() right?
for animation it should suffice to only change the texture coordinates
in the vertex_list? another way to do animation would be to prepare
several vertex_lists with each animation step? i have to try out both
methods and compare how they perform later but at least for map
objects i have to change the textures directly as the objects there do
have different numbers of animation frames.

i hope i got all my questions covered now :)

thx for sharing your expertise!

On Sep 10, 2:21 pm, "Alex Holkner" <[EMAIL PROTECTED]> wrote:
> On 9/10/08, josch <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> >  hello again!
>
> >  on my long travel to deeper pyglet knowledge i now tried to do as you
> >  guys said and now use batches without creating sprites but by just
> >  adding vertex and texture data to my batch.
> >  here you can see my current demo code that oulines how i understand it
> >  up to now:http://phpfi.com/352024
>
> >  please correct me where I'm wrong but let me just shortly explain what
> >  my understanding is about what the code does up to now:
> >  upon creating the window my tile resource is loaded (despite the pcx
> >  extension this is a png image). the resource module automagically adds
> >  this to a TextureBin which manages a series of TextureAtlas'es which
> >  itself stores images in one big texture. The resource will return a
> >  TextureRegion that describes the placement of my image in this
> >  TextureAtlas so i can access it in there.
> >  next i set some lists and fill them once - this will be done later in
> >  a loop to add more than one tile.
> >  the vertex_data contains the coordinates of each square's corners on
> >  the screen as four x/y coordinates.
> >  the texture data stores the texture coordinates of my image in the
> >  TextureAtlas.
> >  the color_data stores the color of each of my tile's corner. this will
> >  probably be overwritten by my texture.
>
> Actually the vertex colours will scale the texture colour; effectively
> tinting it.  Usually the colour needs to be white, which you've done.
>
> >  then i add those four "corners" of my tile with their respective
> >  coordinates and colors to the batch as a GL_QUAD.
> >  the batch is then drawn in the on_draw() method
>
> >  unfortunately my texture will not show up so a hint on what i'm still
> >  doing wrong is very much appreciated.
>
> Just need to enable texturing and bind the texture.  Ideally you would
> do this in the group, so you can use different textures within the
> same batch; but for now you can just add it where your blend state is
> set.
>
> glEnable(self.tile.target)
> glBindTexture(self.tile.target, self.tile.id)
>
> 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to