   Sprites at a power of two.
  I've got a -hopefully- small question. I've just been introduced to the fact that all sprites must be at a power of two, however, there have obviously been many tricks used in order to get around having a game full of sprites of equal proportions.  What's an effective way to acheiving this? Thanks in advance.   
  Sprites don't have to be powers of two, only textures do. So what you can do is shrink/enlarge the quad/traingle that the texture is on to get different size sprites. And you can show only part of a texture on a quad/triangle. And if you're just using something like SDL for graphics, then you don't have to worry about this at all.   ;  Right. For OpenGL at least, you can pack as many sprites onto a texture as possible and just use the area of the texture you need. OpenGL (and DX too i believe) need the raw texture to be a power of two for the hardware to use effectively. But that says nothing of sprites.   ;  Thanks for taking the time to reply. I'm folliwng this tutorial: http://gpwiki.org/index.php/SDL:Tutorials:Using_SDL_with_OpenGL , and I might be misunderstanding something... according to the tutorial, doesn't the glory of using OpenGL for sprites come from the fact that you're actually texturing a flat 3D surface made to act 2D, so that you can rotate it, scale it, and all that nice stuff?  Or is there a way to still achieve this through using SDL for drawing while OpenGL is merged?   ;  You are correct.If you use SDL+OpenGL, you are using OpenGL exclusively for drawing. SDL is used for input, windowing, and "miscellanea". One of those things is graphics loading. Basically, you can use SDL_img to load a graphic file (power-of-two texture) into an SDL surface, then convert the SDL surface into an OpenGL texture proper. You then dump the SDL surface, as it is just a temporary.Once you have the OpenGL texture packed with your sprites on it, you can just draw a quad textured with the OpenGL texture and clamped to the appropriate coordinates of sprite on that texture. What you are effectively doing is "drawing" a subsection of the texture so that it looks like a sprite on the screen. Since it's just a textured quad, you can also rotate, scale, flip, blend, color, deform, and otherwise mutilate it. You can't do that with just SDL graphics. Yeah, OpenGL!   ;  but it IS actually possible to load non-power-of-two textures in openGL.one method mentioned above is to put your sprites on a pot-texture (pow of 2)but you can also use GL_ARB_Texture_rectangle to load NPOT-textures.Or you can use gluScalef (or gluBuild2DMipMaps, wich use gluScalef) to strech your NPOT to a POT texture.edit:in openGL2.0 the restrictions of POTs are totaly removed.they implementet the GL_ARB_Texture_rectangle-extension in OGL   ;Quote:Original post by WarMuuhbut it IS actually possible to load non-power-of-two textures in openGL.one method mentioned above is to put your sprites on a pot-texture (pow of 2)but you can also use GL_ARB_Texture_rectangle to load NPOT-textures.Or you can use gluScalef (or gluBuild2DMipMaps, wich use gluScalef) to strech your NPOT to a POT texture.edit:in openGL2.0 the restrictions of POTs are totaly removed.they implementet the GL_ARB_Texture_rectangle-extension in OGLJust a little clarification on this...The image scaling function you are thinking of is gluScaleImage.You can indeed use GL_ARB_texture_rectangle to use non-power-of-two (NPOT) textures in OpenGL.  There are some restrictions and differences to it than normal textures however such as no mipmapping, limited wrap modes, and non-normalized texture coordinates.It's true that in OpenGL 2.0 the NPOT texture restriction is gone, but it's not because of GL_ARB_texture_rectangle.  It's because GL_ARB_texture_non_power_of_two has been promoted to core OpenGL.  GL_ARB_texture_non_power_of_two allows you to use NPOT textures in EXACTLY the same way as POT textures, so it supports mipmapping, all wrap modes, and uses normalized texture coordinates.  For the time being at least, it does seem like most implementations are not as efficient with NPOT textures as they are with POT textures so it is still recommended to use POT textures where you can.   ;  Interesting. I was actually creating a new texture for every frame of a sprite. Is that worse than specifying clamp coordinates to one texture?Oh, and how do you use GL_ARB_texture_non_power_of_two ?   ;  You can use a different texture for each sprite, but if your sprite is not the full size of the texture, you are wasting video memory.   ;  So, if it IS the same size, then which way is faster?Oh, and, uh, how do you clamp textures like that?   