OpenGL pixels drawn with each horizontal pair swapped

Posted by Tim Kane on Stack Overflow See other posts from Stack Overflow or by Tim Kane
Published on 2011-01-12T07:11:55Z Indexed on 2011/01/13 5:53 UTC
Read the original article Hit count: 287

Filed under:
|
|

I'm somewhat new to OpenGL though I'm fairly sure my problem lies in the pixel format being used, or how my texture is being generated...

I'm drawing a texture onto a flat 2D quad using a 16bit RGB5_A1 pixel format, though I don't make use of any alpha at this stage. The problem I'm having is that each pair of horizontal pixel values have been swapped.

That is... if the pixels positions should be in this order (assume 8x2 image)

0 1 2 3 
4 5 6 7

they are instead drawn as

1 0 3 2
5 4 7 6

Or, more clearly from this image (below). Left is what I get... Right is what I should get.

.

The question is... How have I ended up with this? Is there something wrong with the pixel format? Unlikely since the colours all appear correct, and I would expect all kinds of nasty if it were down to endian-ness. Suggestions greatly appreciated.

Update: Turns out the problem was in my source renderer. Interestingly, I've avoided the problem entirely by using 32-bit textures (haven't tried 24-bit at this point).

© Stack Overflow or respective owner

Related posts about opengl

Related posts about distortion