• ### Popular Now

• 10
• 13
• 18
• 27
• 9

#### Archived

This topic is now archived and is closed to further replies.

This topic is 5290 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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];

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:

//Obtaining value using typecast on pointer, and relying

//on little endian byte order to perform byteswap.


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]

##### Share on other sites
Actually, NeHe''s method, unlike your second one, is cross-platform, since it doesn''t assume anything about the endianness of the target platform.

How appropriate. You fight like a cow.