Endian issuses and rgb data

I am developing an open GL app which will end up running on big and little endian hardware. With 24bit R8G8B8 and 32bit R8G8B8A8 textures this is obviously not a problem, but I have hit a brick wall trying to find out the correct way to deal with 16bit packed pixel formats like R5G6B5.

I store all the textures in bigendian format on the disk, do I need to do order swapping when loading packed pixel formats onto the little endian machines? The OpenGL spec is hopelessly ambiguous about memory hirarchy issues, and trying to find a definitive answer on the web seems to be a bit like asking for gold.

Any help would be greatly appreciated. I guess I could find this out the hard way, but I`m sure someone has encountered this situation before and has a real answer…

[This message has been edited by TheWatcher (edited 05-06-2001).]

There are really 3 separate interrelated issues here having to do with endianness and textures:

  • file load/save correctness
  • texture download correctness
  • texture download performance

What is the question about?

  • Matt

Let me rephrase the question, and hopefully answer that.

Given a packed pixel point in the form R5G6B5, how will
the bits in that pixel map to two bytes on a little
endian machine so that uploading the texture is as
efficient as possible? Will it be

0xnn00 = RRRRRGGG
0xnn01 = GGGBBBBB

or

0xnn00 = GGGBBBBB
0xnn01 = RRRRRGGG