Display lists and sprites

Hi dudes!

Can display lists be used to draw sprites and tiles, efficiently? I’ve learned that display lists are static calls to OpenGL commands, so, how would I work with frame based animation within the sprites?

I’m reading the red book, but if you could point me other resources about this specific issue, I’d appreciate it a lot :smiley:

Thanks in advance,

Son Of Cain

You don’t want to be using display lists for sprites, they have a high overhead for creation and you can only use them for static geometry. Instead you’ll want to be using vertex arrays (maybe with the VBO extension for even better performance). For pretty much any 2d game you’re going to be limited by fillrate rather than vertex processing, so as long as you’re not using immediate mode (glBegin/End) then you probably don’t need to worry about it too much.

Vertex arrays are pretty easy: you put all your vertex data into big arrays and draw it all in one chunk. Look up glDrawArrays and related functions. Ideally you want to minimise state changes (in particular texture binds) so where possible you should pack multiple textures into one larger texture and just sample the correct subsection within it. Since you probably have separate tile layers anyway this makes an ideal way of separating into multiple texture groups.

Hi,

Yes, I’m using immediate mode to render the texture of the current animation frame of my sprite. So, I’ll need this vertex array trick you mentioned. Thanks for pointing that out :smiley:

Could you please suggest any reference material/code on this matter (if available) ?

Son Of Cain