views:

51

answers:

0

Hello,

I'm trying to learn how to use vertex buffers by making a sprite engine. I create a new buffer for each texture page I have, and can add instances of textured quads to the buffers, interleave their vertex and uv information and render them out fine using DrawElements.

However, I can't find any way of setting the alpha on individual vertices ( or ideally quads) within a single vertex buffer. For example, say I had 10 particles (textured quads) in a vertex buffer and I wanted to fade one out, how would I do that?

I can set alpha on a whole vertex buffer by calling glColor4f and glTexEnvi in the draw function, but can't find a way to do it to particular vertices.

I should point out that I've also got a vertex buffer for non-textured coloured quads, and I can obviously alpha those out fine, cause the data is partly made up of an alpha value.

I've tried adding the same colour information to the texture vertex buffer and using that in the draw function, but I get weird results - is this the way to go, and I just need to set some modes up properly somewhere?

The fact that I can't find anything on the internet about this makes me think I'm missing something blindingly obvious - there must be a way to draw textured sprites in a vertex buffer but still control their individual alpha levels. Anyone got any insights?

Thanks in advance for your help.