OpenGL纹理颜色问题
我正在加载原始纹理(带有 Alpha 通道)并在 openGL 中显示它,一切都很好并且纹理显示,但颜色比原始颜色稍暗。我已经尝试过关闭灯光、混合和抖动,但这没有帮助。
我正在使用 mac osx。
示例图像
http://postimage.org/image/2wi1x5jic/
这是openGL纹理加载源代码:
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA , width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, &bytes[0]);
编辑:
这很奇怪,我使用了 http://forums.tigsource.com/index.php?topic=9560.0 并收到同样的故障...所以问题不是我的代码,也许是驱动程序选项?嗯...
解决方案:
谢谢@datenwolf,图像是使用 sRrgb 颜色配置文件保存的。删除它并转换为 RGB 后问题就解决了。
I'm loading raw texture (with alpha channel) and displaying it in openGL everything is fine and texture displayed, but color is little bit darker than original. I already tried to turn of lighting, blending and dithering, but this doesn't helps.
I'm using mac osx.
Sample image
http://postimage.org/image/2wi1x5jic/
Here's openGL texture loading source code:
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA , width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, &bytes[0]);
EDIT:
Thats very weird, I used example from http://forums.tigsource.com/index.php?topic=9560.0
and received same glitch ... So the problem not im my code, maybe driver options? Hm ...
SOLUTION:
Thanks @datenwolf, images were saved with sRrgb color profile. Problem is solved once I removed it and converted to RGB.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许您将 GL_MODULATE 设置为纹理环境并且顶点颜色不是白色。尝试将纹理环境设置为 GL_REPLACE。
编辑
另一个问题可能是嵌入到图像中的颜色配置文件。图像查看器可以使用此颜色配置文件来实施颜色管理,调整显示器颜色配置文件的颜色。 OpenGL 按原样不进行颜色管理;有一个扩展,即帧缓冲区和纹理是 sRGB,这是颜色管理的最小公分母。但是您仍然需要将输入图像传输到 sRGB 色彩空间。
我正在准备一篇很长的文章,深入解释如何使用 OpenGL 进行颜色管理。但它还远未完成。
Maybe you have GL_MODULATE set as texturing environment and the vertex colours are not white. Try setting the texture environment to GL_REPLACE.
EDIT
Another problem may be a color profile embedded into the image. A image viewer may use this colour profile to implement color management, adjusting the colours for your monitor's colour profile. OpenGL as-it-is doesn't do color management; there is a extension, that framebuffers and textures are sRGB, this is kind of the smallest common denominator of colour management. But then you'd still have to transfer your input images to sRGB colour space.
I've a lengthy article in preparation the explains in depth how to do colour management with OpenGL. But it's far from complete.