displaying quads (in relation to sprites)

Started by
4 comments, last by zedzeek 18 years, 7 months ago
In my project I am going to have some sprites mainly used for small entities and items. At times there could be a few on the screen, I am not sure how many maybe 50? How should I display them, currently most if not all will be billboarded and could be moving each with own texture. Currently I would just do glBegin(GL_QUADS) do the texCoords and the verts for one, then move on to next one. Since I will only have 4 verts for each sprite and each sprite has different texture, would it be a waste in creating a vertex array or even a vbo for each sprite? -THACO
Advertisement
Quote:Original post by THACO
In my project I am going to have some sprites mainly used for small entities and items. At times there could be a few on the screen, I am not sure how many maybe 50? How should I display them, currently most if not all will be billboarded and could be moving each with own texture. Currently I would just do glBegin(GL_QUADS) do the texCoords and the verts for one, then move on to next one. Since I will only have 4 verts for each sprite and each sprite has different texture, would it be a waste in creating a vertex array or even a vbo for each sprite?
-THACO


Creating a display list should be good enough and simpler ( VA and VBO may reduce performance *)
50 sprites is not a great number: also an old card is able to render 10-20000 quads per second (ie ~100-1000 @ 100fps ) !!!

Some hints:

- use a great texture in which you store different quad textures then use tex coordinates to map the right 'sub textures' onto the quad.

- sort sprites by texture ( change texture can be expensive )

- use texture objects ( see glBindTextures )

- use a sort of hash map ( for example a simple grid ) to cull sprites out of the viewport; better if you can cull more than one sprite at once!

EDIT: (*) in this special 2D application
Thanks for those hints, I have been using texture objects, and also I have considered using bigger textures, currently I only do that for animated sprites but I will see if I can extend that. The one problem with display lists is that most of the textures will be billboarded so I will need to modify the verticies, they will not be constant (each one will be modified differently) so I cannot put a glrotate or translate before I call the display list. I have no used display list in actual code just read about them (only used vertex array and vbos). Thanks for reminding me about culling also and sorting sprites by texture.

-THACO
Once you have the quad in a display list, a simple transformation before calling the list can bill-board it for you. All you need is a transformation matrix that has opposite rotation from the current modelview matrix. I implemented this effect nicely from This Tutorial
why not use ARB point sprites?
Quote:would it be a waste in creating a vertex array or even a vbo for each sprite?

yes.
for 4 verts just use immediate mode, if u have sprites that share the same texture then u can batch them together and use VAs (i wouldnt worry about VBO)

just noticed youre talking about 50 quads in that case just use begin(..)

This topic is closed to new replies.

Advertisement