   SOIL: new lightweight image loading lib
  Hi, All.This is an announcement, but I think it fits better in this forum.  If I'm wrong, feel free to move it [8^)I've been looking for a tiny image loading library for some hobby OpenGL game projects I'm working on, but never really found exactly what I wanted.  Then I found Sean Barrett's awesome C code for loading BMP/PNG/JPG files (here).  I took that, added TGA loading support (except for indexed TGA images), wrapped some common functions like upsizing to power-of-two sizes, MIPmap generation, pre-multiplying alpha, etc. all into a single function call for easy loading of textures into OpenGL.Presenting the Simple OpenGL Image Library (yes, I'm sorry SOIL is such a lame acronym [8^)Features:Loads PNG, JPG, TGA, BMP, DDS (a subset of each type)Saves TGA, BMP, DDSLoads an image file directly into an OpenGL textureCan automatically rescale the image to the next largest power-of-two sizeCan automatically create MIPmapsCan multiply alpha on load (for more correct blending / compositing)Can flip the image verticallyCan compress to DXT1 or DXT5 (if EXT_texture_compression_s3tc is available)Will downsize the image if necessary to fit GL_MAX_TEXTURE_SIZENo external dependenciesTinyPublic DomainIf anybody is willing to give some feedback, I'd really appreciate it (I'm keeping this a C project, and my C skills are extremely rusty).  Feature requests are also welcome.[edited to add new features][Edited by - lonesock on August 16, 2007 11:59:53 AM]
  I've found it such a neat, tidy and useful drop i can't help saying thanks, good job!   ;Quote:Original post by ForestMasterI've found it such a neat, tidy and useful drop i can't help saying thanks, good job!Thanks!I updated SOIL a bit: you can now pass in a flag to specify that you want the image flipped vertically, and you can flag that you want the image compressed to use DXT(1 for RGB, 5 for RGBA), if EXT_texture_compression_s3tc is available.  Note that this could be slow, depending on your OpenGL drivers.  I'm looking into writing my own (hopefully faster) DXT1/3/5 compressor, but that's down the road.  Next step is just loading already compressed DDS files.;  Looks very cool - bookmarked for future reference :)   ;Quote:Original post by jykLooks very cool - bookmarked for future reference :)[8^)OK, I have written my own DXT1 compressor, decent quality, very fast (about 31ms for a 512x512 RGB image).  I'm planning to add this to SOIL this weekend, so if a user specifies that they want the image loaded as DXT, SOIL will do the conversion without relying on the (very slow, for me at least) OpenGL driver to do the conversion.A sample:Here is the original image, andhere is the one done in 31ms, andhere is the DXT1 file from ATI's Compressonator (~1.5 seconds)   ;  SOIL can now load compressed DDS files directly as an OpenGL texture!  It also has its own DXT compressor now, so no reliance on the OpenGL driver for uploading uncompressed images in S3TC format.  Any image file SOIL can load can be quickly compressed (~26ms for a 512x512 image on my Athlon64 3000+).  You can also save any file as a DDS file (SOIL will use the internal compressor).  This works for screenshots too.The testSOIL.exe file takes an image specified on the command line, then resizes it to the nearest larger power-of-two (if needed), pre-multiplies alpha, generates the MIPmaps, compresses to DXT1 (for RGB images) or DXT5 (for RGBA images), uploads the image to OpenGL then displays 2 quads, 1 stationary and 1 spinning with that texture on it.  When you hit [Esc] the program will exit after saving a screenshot in TGA format.The exe was compiled with MinGW 3.4.5, as was the libSOIL.a file.  The SOIL_vc8.lib file was compiled with Microsoft's very nifty free VS2005 Express edition.Please let me know if anybody gets it to work under a new compiler or has any feedback / feature requests.   ;  Oops, SOIL's MIPmap generator used to die on non-square textures...fixed now.   ;  I just uploaded a new SOIL version, here are the changes:Updated to stb_image version 0.97SOIL can now decompress DDS files (allows regular file loading, e.g. for heightmaps, etc, allows image flipping, resizing, pre-multiplying alpha, etc.  It also means that there is no need to have an alternate art asset path in case the user's machine doesn't support DXT compression)You can still force the DDS files to be loaded directly if supported (and everything GeForce2 and above will support it), but you lose all the other nifty options.There is some simple error reporting, in case an image fails to load.   ;  SOIL can now load Indexed TGA images.So, basically, except for bug fixes and porting, I'm pretty much ready to call it a day.Feedback is always appreciated.   ;  This is a very nice, clean library you have here, lonesock.I'm going to be using it to replace SDL_Image as my image loading library in my game engine.thanks for the awesome work!   