I’m sure you guys have seen this enough times, but I’m having constant probs getting more than one texture on the go at one time in a pixel shader.
Here’s the gist of my code:
<make texture map>
glGenTextures(1, &texture1)
glBindTexture(GL_TEX_2D, … data)
glTexParam(…)
<make texture map>
glGenTextures(1, &texture2)
glBindTexture(GL_TEX_2D, … data)
glTexParam(…)
glUseProgramObjectARB(program)
glActiveTexture(GL_TEXTURE0)
glBindTexture(GL_TEXTURE_2D, texture1);
glUniform1iARB(glGetUniformLocationARB(program, “tex1”))
glActiveTexture(GL_TEXTURE1)
glBindTexture(GL_TEXTURE_2D, texture2);
glUniform1iARB(glGetUniformLocationARB(program, “tex2”))
I then draw my textured quad.
The glGetUniformLocationARB calls return 0 and 1 respectively.
The problem seems to be, no matter what I try the texture that the pixel shader uses is the one that has the first glBindTexture call. So it’s not like it’s having problems making the texture etc, as I can check by reversing the glBindT calls.
If you need to know, here’s my dead basic shader code:
“uniform sampler2D tex1;”
“uniform sampler2D tex2;”
“void main(void)”
“{”
" vec2 texCoord = gl_TexCoord[0].xy;"
" vec4 c1 = texture2D(frame, texCoord);"
" vec4 c2 = texture2D(prevframe, texCoord);"
" gl_FragColor = vec4(c2.x);" //changing to c1 will give the same texture as c2
“}”
}
I know that the shader’s being run as the image I get on the screen is greyscale (as I’m assigning the red channel of the textureto all the channels of the fragment)
Please can someone suggest something dumb that I’m doing? This is killing me!