2D Sprites (ortho + textures)

Started by
5 comments, last by MarkS 14 years, 4 months ago
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?
Amateurs practice until they do it right.Professionals practice until they never do it wrong.
Advertisement
B

and use POT if possible unless you are on a newer Gfx card GL2.0 compliant should have NPOT support.
What is POT? never heard...
power of two.
One vote for B. Anyone else care to weigh in on this? :)
Amateurs practice until they do it right.Professionals practice until they never do it wrong.
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.
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.

No, I am not a professional programmer. I'm just a hobbyist having fun...

This topic is closed to new replies.

Advertisement