Texture files

Hi, I was wondering what the easiest file format to load for textures is? I Do not want source code but to attempt this from first principles, and was wondering if any one could offer advice.

I have already had a look at a few file formats at wotsit.org, but tiff and jpg seem to difficult for me to load. Any suggestions for an easier format?

TGA is a very good format and it’s very easy to read too. If you’re a beginner in programming, I suggest you go for uncompressed TGAs and forget about compression for now. Compressed TGAs are not that difficult, but requires some programming experience to implement.

Be careful of LSB / MSB ordering when reading binary data. If you’re working on Intel PC’s this shouldn’t be a problem, though if on MAC you may have to switch bytes…

The tga file format is definately the easiest, as bob said, uncompressed is the way to go for ease of implimentation.

check out www.wotsit.org for the file format spec

A common error is to construct a TGA header structure that does not align to 18 bytes. Be careful if trying to read the header into a structure and ensure that the structure’s size is actually 18 bytes.

If sizeof() returns anything greater than 18, then you will need to add the line

#pragma pack(1)

to force 1 byte alignment of data.