平民程序 - linghuye's blog

天下风云出我辈,一入江湖岁月催。皇图霸业谈笑中,不胜人生一场醉。提剑跨骑挥鬼雨,白骨如山鸟惊飞。尘事如潮人如水,只笑江湖几人回。

随笔 - 221, 文章 - 0, 评论 - 680, 引用 - 0
数据加载中……

GL_ALPHA/GL_LUMINANCE/GL_INTENSITY之差别

The difference between the three single-component texture formats, GL_ALPHA, GL_LUMINANCE and GL_INTENSITY, is in the way the four-component RGBA color vector is generated. If the value for a given texel is X, then the RGBA color vector generated is:

    * GL_ALPHA: RGBA = (0, 0, 0, X)

    * GL_LUMINANCE: RGBA = (X, X, X, 1)

    * GL_INTENSITY: RGBA = (X, X, X, X)

In other words, if we interpret the alpha as transparency, GL_ALPHA would represent a completely black texture with varying transparency, GL_LUMINANCE is an opaque texture with varying color (a grayscale image), and GL_INTENSITY is a combination where both the color and alpha channel is varying.

一个很隐晦的错误:
 glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, nWidth, nHeight, 0, GL_ALPHA, GL_UNSIGNED_BYTE, data);
可以确定当前2D纹理是有效的,data图像数据是正确的,但最终得到的纹理显示出来的图像竟然是错误的?
 查出 之前有一个glPixelStorei是错误根源, 当前的GL_PACK_ALIGNMENT,GL_UNPACK_ALIGNMENT,GL_UNPACK_ROW_LENGTH值会影响外部data最终到达纹理的方式,特别是GL_UNPACK_ROW_LENGTH!!!

Reference:
http://www.gamedev.net/community/forums/topic.asp?topic_id=307568

posted on 2008-08-23 18:35 linghuye 阅读(6399) 评论(0)  编辑 收藏 引用 所属分类: 3D图形学研究

只有注册用户登录后才能发表评论。