Original Post
While using the code to load uncompressed .tga files (NEHE lesson #33) I get bluish green image using the optimized xor method but no problems while using the traditional byte swapping method. the two methods or outlined below.
I verified the math for the optimized byte swapping using xor is correct. Does anybody have any ideas on what might cause this?
Thanks!
I verified the math for the optimized byte swapping using xor is correct. Does anybody have any ideas on what might cause this?
Thanks!
// -- Optimized method// Byte Swapping Optimized By Steve Thomasfor(GLuint cswap = 0; cswap < (int)tga.imageSize; cswap += tga.bytesPerPixel){ texture->imageData[cswap] ^= texture->imageData[cswap+2] ^= texture->imageData[cswap] ^= texture->imageData[cswap+2];}// -- Traditional methodfor(GLuint i=0; i<int(tga.imageSize); i+=tga.bytesPerPixel) // Loop Through The Image Data{ // Swaps The 1st And 3rd Bytes ('R'ed and 'B'lue) tga.temp=texture->imageData; // Temporarily Store The Value At Image Data 'i' texture->imageData = texture->imageData[i + 2]; // Set The 1st Byte To The Value Of The 3rd Byte texture->imageData[i + 2] = tga.temp; // Set The 3rd Byte To The Value In 'temp' (1st Byte Value)}