Well, we already have LoadTGA, so… Yes you want a loader for other formats too!
LoadTGA is intended for lab work. The format is fairly simple so the loader is relatively understandable. But JPEG and PNG are better formats, and when you use LittleOBJLoader with a .mtl file, you will want to load the textures as-is and not fiddle with converting.
LoadTexture is a small package of four loaders with a single loading call loading any of them, PNG, JPG, TGA and PPM. The only external dependency is zlib, so the amount of the usual hassle of installing things is kept to a minimum. Instead, I have included two small loaders that I didn’t write, PNGlite and nanojpeg. Also LoadTGA has been modified to make it simpler to work with. It had a workaround for non-power-of-two textures which was rather elegant in its way but caused confusion.
A demo is included, rendering the image below from four texture files. They intentionally are not square and not power of 2 size.
A variant, called LoadTextureCombo, collects all four loaders into a single file, with a single no-worries call “LoadTexture”. It is notable that the file includes the legal notices of each part, and the license of each part stands of its own. I believe this is legal for the demands of all parts (essentially PNGlite and nanojpeg since I wrote the others).
This makes it very convenient, although far from as transparent as LoadTGA or, even more so, readppm. Thus, I still consider LoadTGA to be a good entry point, while LoadTexture should be perfect for project work.
NEW: In the latest version, the “combo” version is now the only one. Separate files made no sense.
Download new version, now with proper C++ support.
Old version: