This is just a note to NeHe about a few lines in the TGA loader source that have been nagging at me for awhile now.
texture->width = tga.header[1] * 256 + tga.header[0];
texture->height = tga.header[3] * 256 + tga.header[2];
It's bad form to do this arithmetically IMHO. You can either do it logically, or use a typecast on the pointer, and rely on the endian order to do the byteswap for you. For example:
//Obtaining value using logical shift to promote second byte,
//and binary OR to combine with first byte:
texture->width = (tga.header[1] << 8) | tga.header[0];
texture->height = (tga.header[3] << 8) | tga.header[2];
//Obtaining value using typecast on pointer, and relying
//on little endian byte order to perform byteswap.
texture->width = *((short*)&(tga.header[0]));
texture->height = *((short*)&(tga.header[2]));
The second method is rather experimental for me, and I don't know if it'd be considered messy or bad form by more experienced programmers, but the logical method shown in the first example is a much better way to obtain the values than using multpilcation and addition IMO, and even though speed is not any real issue in this perticular instance, I think it would be significantly faster if the two were compared.
Note that this is not meant as criticism, merely as a suggestion for improvement.

EDIT: This damn thing keeps screwing up my source tags.
[edited by - Nemesis2k2 on September 23, 2003 8:28:32 PM]