   Image files (internal setup)
  Hi guys,I was wondering how everyone is doing their graphic files setup.Meaning, do you have 1 graphic per file or do you use multiple graphics in 1 file?For example: animations. You could have 1 image with all the frames in it, or 1 image per frame.Or textures, multiple textures in one image file, or an image file per texture.Seeing how MSDN says to use textures that are as small as possible, I would guess 1 per file is best. But if you have a lot of odd shaped graphics, then you might save texture memory by smartly putting it all in one file (in regards to the power of 2 size restrictions).I used to have only a few image files, and they contained lots of graphics each. But then I switched to 1 image per file, as it's easier to manage and maintain (with a good folder structure behind it).For example, animation frames are all named like WalkLeft#00.png to WalkLeft#15.png (16 frames of animation). And they are accompanied by one config file that has the same name as the first frame, except for ending in .cfgIn my code I just create 1 instance of my image class, passing it the name of the first frame. The class then "sees" the associated config file which contains the nr of frames for example. It then generates the rest of the filenames and reads all those images as well. And in my code I just say DrawImage( ID, FrameNr ).I know there's lots of ways to do this, but I'm just very interested in what everyones opinion on the matter is. What are you using yourself, any pro's con's that stick out?And while we're at it, what is your preferred file format?I always used BMP files, but I'm now thinking off converting all my images to PNG files, for the alpha channel.Or a mix, with BMP by default and PNG just for those parts that need the alpha channel. Because I can't imagine it not having a negative impact on performance :)Looking forward to everyones opinion and experience,Michaël   
  When the MSDN says that textures should be as small as possible, it means that if your image is 10x10, don't create a 1024x1024 texture for it.You definitely want to get as many images as possible onto one texture, not for the memory saving (which is usually slight), but because if you have loads of sprites on different textures, then you have to keep switching textures when you draw them, which is particularly bad for performance. You really want to render as many triangles in one go as possible.My perferred format is the DirectX texture format, since it has alpha, mip maps, and is fast to load. All my resources are stored in a compressed data archive, so the file size doesn't matter much.Personally, I pack as many sprites as possible onto 256x256 "sheets", and then at runtime, I pack those sheets into several larger (usually 1024x1024 to 4096x4096) textures. That way I can usually draw all of my sprites in a single draw call.The performance hit from copying data to this large sheet isn't that bad at all, and since it's done at load time, it's usually acceptable.EDIT: All this is referring to Direct3D, it may be different with OpenGL or another graphics API.   ;  How do you access the graphics within the 1 file Steve?Is it hard coded or do you have a config file that says what graphic is where within the image?The easiest way I can visualise it now, is to create one class per image file that knows what (ID) is where (rectangle).Thanks for sharing   ;  A config file describes each sprite - it's name / ID, dimensions, and frames. And each frame contains a resource name (filename), and a rectangle for that texture which contains the sprite data.   