Hello,
I am attempting to get a simple program to work which passes two textures to a shader, and will allow me to switch between the two. Unfortunately, the shader only draws the texture that is bound to GL_TEXTURE0, regardless of the uniform assignment in the shader. The code is as follows:
The Fragment shader:
#version 400
in vec2 TexCoord;
uniform sampler2D Tex1;
uniform sampler2D Tex2;
layout (location = 0) out vec4 FragColor;
void main()
{
vec4 col2 = texture( Tex2, TexCoord );
vec4 col1 = texture( Tex1, TexCoord );
FragColor = (col1 + col2)*0.5;
}
And the C++ code:
displayShader.Use();
glActiveTexture(GL_TEXTURE0);
glEnable(GL_TEXTURE_2D);
displayShader.SetUniform("Tex2",0);
glBindTexture(GL_TEXTURE_2D, swfInter.GetRenderTexture());
glActiveTexture(GL_TEXTURE1);
glEnable(GL_TEXTURE_2D);
displayShader.SetUniform("Tex1",1);
glBindTexture(GL_TEXTURE_2D, TheScenes[0].Maps[0].TextureHandle);
m_MLAACorrector.DrawQuad(-1, displayShader, 100, 100, true );
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, 0);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, 0);
And the DrawQuad function makes no texture calls. This code successfully draws a quad with texture swfInter.GetRenderTexture() (this textures has large sections of Alpha), yet does not display TheScenes[0].Maps[0].TextureHandle. Additionally, if I swap the glBindTexture calls, then the converse is true. Please let me know if you have any ideas.
Thanks