开发者

OpenGL pixels drawn with each horizontal pair swapped

开发者 https://www.devze.com 2023-02-03 14:37 出处:网络
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 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.

OpenGL pixels drawn with each horizontal pair swapped

.

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 a开发者_如何学Govoided the problem entirely by using 32-bit textures (haven't tried 24-bit at this point).


This may be unrelated, and you have found a workaround, but it could be related to OpenGL unpack alignment. Have you tried with the following call ? To instruct the alignment of every image row to 1 byte (default is 4).

glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号