PDA

View Full Version : Animating sprites using spritesheet



Haseeb
02-26-2012, 08:48 AM
Hey guys, im new to opengl also to the forums, im making a 2D game and i wanted to know how to use a sprite sheet in opengl. i searched quite a bit but found nothing ... i need to do this since it is a requirement for a project im working on.
Any useful links or code will be greatly appreciated :) thanks in advance

BionicBytes
02-26-2012, 09:25 AM
What is a sprite sheet?
I assume this is a texture containing a series of sprite images arranged in a regular gird....we call that a texture atlas.
Simply access each 'sprite image' by its texture coordinate when texturing the quad or sprite. For example, suppose you has only 4 'sprite' images in this atlas texture. The first image would have its top-left texture coordinate as (0,0) and it's top-right as (0.5,0).
One word about texture atlases. Make sure there are a couple of black pixels between each image so that linear filtering does not grab texels belonging to an adjacent image/sprite.