title: Multiple textures in GLSL - only one works
body: <p>My problem is getting more than one texture accessible in a GLSL shader.
  Here's what I'm doing:</p>
  
  <p>Shader:</p>
  
  <pre><code>uniform sampler2D sampler0;
  uniform sampler2D sampler1;
  uniform float blend;
  void main( void )
  {
      vec2 coords = gl_TexCoord[0];
      vec4 col = texture2D(sampler0, coords);
      vec4 col2 = texture2D(sampler1, coords);
      if (blend &gt; 0.5){
          gl_FragColor = col;
      } else {
          gl_FragColor = col2;
      }
  };
  </code></pre>
  
  <p>So, I simply choose between the two color values based on a uniform variable. Simple enough (this is a test), but instead of the expected behavior, I get all black <strike>when blend &lt;= 0.5</strike>.</p>
  
  <p>OpenGL code:</p>
  
  <pre><code>m_sampler0location = m_shader.FindUniform("sampler0");
  m_sampler1location = m_shader.FindUniform("sampler1");
  m_blendlocation = m_shader.FindUniform("blend");
  
  glActiveTexture(GL_TEXTURE0);
  glEnable(GL_TEXTURE_2D);
  m_extensions.glUniform1iARB(m_sampler0location, 0);
  glBindTexture(GL_TEXTURE_2D, Texture0.Handle);  
  glActiveTexture(GL_TEXTURE1);
  glEnable(GL_TEXTURE_2D);
  m_extensions.glUniform1iARB(m_sampler1location, 1);
  glBindTexture(GL_TEXTURE_2D, Texture1.Handle);
  glBegin(GL_QUADS);
      //lower left
      glTexCoord2f(0, 0);
      glVertex2f(-1.0, -1.0);
      //upper left
      glTexCoord2f(0, maxCoords0.t);
      glVertex2f(-1.0, 1.0);
      //upper right
      glTexCoord2f(maxCoords0.s, maxCoords0.t);
      glVertex2f(1.0, 1.0);
      //lower right
      glTexCoord2f(maxCoords0.s, 0);
      glVertex2f(1.0, -1.0);
  glEnd()
  </code></pre>
  
  <p>The shader is compiled and bound before all this. All the sanity checks in that process indicate that it goes ok.
  <strike>As I said, the value of <code>col</code> in the shader program reflects fragments from a texture; the value of <code>col2</code> is black. The texture that is displayed is the last active texture - if I change the last <code>glBindTexture</code> to bind <code>Texture0.Handle</code>, the texture changes.</strike> Fixed according to Bahbar's reply.</p>
  
  <p>As it is, the scene renders all black, even if I add something like <code>gl_FragColor.r = blend;</code> as the last line of the shader. But, if I comment out the call <code>glActiveTexture(GL_TEXTURE1);</code>, the shader works again, and the same texture appears in both sampler0 and sampler1. </p>
  
  <p>What's going on? The line in question, <code>glActiveTexture(GL_TEXTURE1);</code>, seems to work just fine, as evidenced by a subsequent <code>glGetIntegerv(GL_ACTIVE_TEXTURE, &amp;anint)</code>. Why does it break everything so horribly? I've already tried upgrading my display drivers.</p>