交换每个水平对绘制的OpenGL像素 [英] OpenGL pixels drawn with each horizontal pair swapped

查看:78
本文介绍了交换每个水平对绘制的OpenGL像素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对OpenGL有点陌生,尽管我可以肯定我的问题在于所使用的像素格式或纹理的生成方式...

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...

我正在使用16位RGB5_A1像素格式将纹理绘制到平面2D正方形上,尽管在此阶段我不使用任何alpha.我遇到的问题是,每对水平像素值都已交换.

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.

也就是说...如果像素位置应以此顺序排列(假设图像为8x2)

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

0 1 2 3 
4 5 6 7

它们被绘制为

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.

更新:原来问题出在我的源渲染器中.有趣的是,我通过使用32位纹理(此时尚未尝试使用24位)完全避免了该问题.

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).

推荐答案

这可能无关紧要,您已经找到了解决方法,但它可能与OpenGL解压缩对齐有关.您是否尝试了以下电话?指示每个图像行的对齐方式为1个字节(默认为4个字节).

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

这篇关于交换每个水平对绘制的OpenGL像素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆