   Sprites in opengl
  Hey.I''m creating a "2D" game engine in opengl.I was just wondering if someone got some tips on how to manage the sprites? How to store them etc.Back in the times where I used DirectDraw I just drawed all the animation frames in one bitmap for each sprite, and when I wanted to draw a specific frame, I just set the source rect to the position of that frame in the bitmap.But in openGL I use textured quads for sprites. And then I have to use texture coordinates to specify from where in the bitmap I want to draw.So I was wondering if anyone got some ideas on how to store/draw the sprites?I have been thinking of just finding the texture coordinates by using a formula like this one: 1.0f/bitmapwidth * framewidth * framenumber etc etc., but I''m guessing that would be pretty inprecise...I hope anyone can help me with this.All help is highly appreciated    "The mistakes are all waiting to be made. 
  You''re going about it pretty much the right way.I think you should give it a go then post back with your results.   Why you shouldn''t use iostream.h - ever! | A Good free online C++ book;  Okey. I''ll give it a try  "The mistakes are all waiting to be made. ;  Well, I got it up and running now It works perfectly :DI was afraid it would be very inprecise due to the very small numbers that are involved, but it seems I was wrong.Well, thanks for the reply siaspete  "The mistakes are all waiting to be made. ;quote:Original post by ziggwarth  Well, I got it up and running now It works perfectly :DI was afraid it would be very inprecise due to the very small numbers that are involved, but it seems I was wrong.You can use a border and avoid strange effects...however if you use quads of the same size of your texture (classic ''sprites'') it works incredibly good.;finding the coords that way should not be a resolution problem since:1-1024 is in the range of 10 bits.floating point values are 32 bits.conversion *should* be quite flawless, not that I''ve tested it. ;quote:Original post by Ranger_One  finding the coords that way should not be a resolution problem since:1-1024 is in the range of 10 bits.floating point values are 32 bits.conversion *should* be quite flawless, not that I''ve tested it. You must apply a border to your tex coord or you can go out from your (sub)texture. This problem is related to some (little) errors that come out from texel computation (it''s not a simple division but it involves initially a lot of vector ops) If you use an Ortho projection of the same dim of the viewport and draw a quad of the same size of the texture you get no error.Example: quad 64x64   texture 256x256 apply tex coords  (0,0)(0.25,0);(0.25,0.25)(0,0.25)It''s okIn this situation there is NO difference with 2D API and you dont need borders.If you want to use LINEAR filtering or zoom the sprites you need a border (that is put some transparent pixels around the sprite-images in the main texture).This problem is mainly related to 2D because in sprite mapping we should avoid texture repeating   ;  HI.. i was having same question too but wouldn''t be alot and little slow every frame changing textures for about 30 sprites on the screen? (including birds, grass, tree animation and stuff)I am making a 2D game too(isometric) in OpenGL and i am thinking if there is a way to do this by BuildList stuff, the problem is when i build one object with 1 frame i can''t change my frame.Hope you can helpcya;  The answer is just use one texture with lots of little sprites in it, then you just change the texture coordinates instead of changing texture objects.  That is of course if all the sprites will fit into a texture that is not too big for the driver to handle. ;  Yea , but when i build object i can''t change texture coordThere is a solution like i could use only one quad(built quad) and then call it as much times i want and put diffrent textures on him but dunno how much would that help or not for speed.I am using CallList(tree) and texture coord are already defined when it was built..?