Jump to content
  • Advertisement
Sign in to follow this  
TheBuzzSaw

OpenGL 2D Sprites (ortho + textures)

This topic is 3238 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

When it comes to animating sprites using OpenGL, which is better? (A) -- Load up each frame of animation as a separate texture. Use the appropriate texture for the appropriate animation. (B) -- Load up a singular sprite sheet. Use the appropriate texture coordinates to just slice out the current animation. Also, if anyone knows the answer: why are textures best with sizes of 2^n? Is it worth concerning myself with this in a simple 2D fighter?

Share this post


Link to post
Share on other sites
Advertisement
I'd say it depends on how big your sprites are. You would'nt want to try to load a sprite sheet that's say, 8192x8192 into VRAM, as most video cards don't support massive textures. But, if you have smaller, more average size sprites, cramming them into a sprite sheet makes sense. Faster loading, less memory consumption.

Share this post


Link to post
Share on other sites
I personally use the sprite sheet method, although I do so for organizational reasons. I never considered it a matter of efficiency. I'm not sure which method is more efficient.

As for the power of two issue, just use alpha masking (which you're probably doing anyway). The actual sprite doesn't need to be a power of two, just the rectangle enclosing it. For that matter, if you use a sprite sheet, only the sprite sheet needs to be a power of two. The texture coordinates within the sheet can be anything.

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!