Jump to content
  • Advertisement
Sign in to follow this  
THACO

displaying quads (in relation to sprites)

This topic is 4812 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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(..)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!