On Mon, Feb 15, 2010 at 8:55 PM, Mike Wyatt <[email protected]> wrote:
> I'm seeing a weird issue with drawing sprites and PyLepton particles.  I
> just added some Lepton particles to my Pyglet project.  It sort of works,
> but all the particles are rendered as colored quads with no texturing.
>
> I attached a test script that is just a modification of Lepton's smoke
> sample with the addition of a single sprite batch.  You should be able to
> see the smoke rendered as quads when the script first runs.  Press any key
> to toggle the sprite rendering.  After turning the sprite rendering off, the
> smoke is suddenly rendered correctly.  Interestingly, the smoke still looks
> good even when you toggle sprite rendering back on.
>
> I'm sure I simply need to set some GL state before rendering the particles,
> but nothing I've tried has worked.  Enabling blending, texturing, or
> lighting, changing blend or shade modes, or disabling depth test didn't have
> any effect.
>
> Thoughts?

I didn't come up with a definitive solution yet, but I'll throw some
clues I gathered back and see if it helps. I tried what Richard
suggested, which makes sense as it appears as though the blending mode
is wrong when the particles are drawn (the points are indeed square,
it is only the alpha blending of the point texture that makes then
appear circular) but the result was unchanged.

One thing that does "cure" the issue is to draw the particles both
before and after the sprite batch. I'm sure this is just creating the
same conditions as when the sprite is disable and then enabled, though
as yet it's not a big enough clue-stick to give me the real solution.

Another thing I grabbed is a gl trace from the pyglet batch drawing.
The calls for each batch draw are shown below. The GL enums are a bit
obfuscated, but there's nothing too surprising going on. Really all it
does is enable 2d textures, bind them, push the color bit, enable
blending and set the blend function and bind and draw the vertices. It
later pops the color info, which undoes the earlier blending function
change. It ends by disabling 2d textures, but the lepton texturizer
re-enables them and binds it's own texture before rendering so that
shouldn't be an issue.

glEnable(3553)
glBindTexture(3553, 1L)
glPushAttrib(16384)
glEnable(3042)
glBlendFunc(770, 771)
glPushClientAttrib(2)
glBindBuffer(34962, 1L)
glEnableClientState(32884)
glVertexPointer(2, 5124, 8, 0)
glBindBuffer(34962, 2L)
glEnableClientState(32886)
glColorPointer(4, 5121, 4, 0)
glBindBuffer(34962, 3L)
glEnableClientState(32888)
glTexCoordPointer(3, 5126, 12, 0)
glDrawArrays(7, 0, 4)
glBindBuffer(34962, 0)
glBindBuffer(34962, 0)
glBindBuffer(34962, 0)
glPopClientAttrib()
glPopAttrib()
glDisable(3553)

The other thing I tried was using a billboard renderer, since point
rendering (point sprites really) can sometimes be a bit dodgy. That
had exactly the same behavior.

Let me know if you find a solution. Tomorrow I can do a more complete
gl trace to see if something jumps out.

-Casey

-- 
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