嘿我所有的着色器都正确编译和链接......他们之前正在工作,我正在研究我的程序一段时间没有触及vert / frag着色器,现在glGetUniformLocation在尝试获取位置时返回大量数字
我在这三个变量上使用它:
m_sw = glGetUniformLocation(m_program, "m_sw" );
m_sh = glGetUniformLocation(m_program, "m_sh" );
m_grabLoc = glGetUniformLocation(m_program, "grabTexture");
m_sw获取值21692416 m_sh获取值21757952 m_grabLoc获取值21626880
所有三个变量都具有glGetUniformLocation返回的GLint类型。
注意:我也在不存在的制服上使用它并正确返回-1所以我很困惑!
我的垂直着色器如下所示
#version 120
varying vec2 texCoord;
void main(void)
{
gl_Position = ftransform();
texCoord = gl_MultiTexCoord0.xy;
}
我的碎片着色器如下
#version 120
uniform sampler2D grabTexture;
uniform float m_sh;
uniform float m_sw;
varying vec2 texCoord;
void main(void)
{
vec4 col = texture2D (grabTexture, texCoord.st);
//left
col += texture2D (grabTexture, vec2(texCoord.s-m_sw,texCoord.t));
//right
col += texture2D (grabTexture, vec2(texCoord.s+m_sw,texCoord.t));
//below
col += texture2D (grabTexture, vec2(texCoord.s,texCoord.t-m_sh));
//top
col += texture2D (grabTexture, vec2(texCoord.s,texCoord.t+m_sh));
//the corners of the pixels
col += texture2D (grabTexture, vec2(texCoord.s+m_sw,texCoord.t+m_sh));
col += texture2D (grabTexture, vec2(texCoord.s-m_sw,texCoord.t+m_sh));
col += texture2D (grabTexture, vec2(texCoord.s+m_sw,texCoord.t-m_sh));
col += texture2D (grabTexture, vec2(texCoord.s-m_sw,texCoord.t-m_sh));
gl_FragColor = col * 0.111111f;
}
这是一个全屏反别名的顺便说一句。
只是想知道是否有其他人遇到此问题或知道修复?
编辑:如果我将gl_FragColor更改为,我认为值得了 gl_FragColour = vec4(1.0,0.0,0.0,0.0) 如果确实使屏幕读取(如预期的那样),那么着色器肯定正在工作! :(