title: Unable to load multiple textures in opengl es 2.0
body: <p>I'm attempting to load two textures and pass them on to two samplers in my shader, however both the samplers return the first texture I load. Furthermore if I don't load a texture into GL_TEXTURE0, both the samplers return black. I've reduced it to a single sampler/texture and still have the same issue:</p>
  
  <pre><code>    GLuint texture1;
  
      glGenTextures(2, &amp;texture1);
  
      glActiveTexture(GL_TEXTURE0); //if this is GL_TEXTURE1 or any other, I get black
      glBindTexture(GL_TEXTURE_2D, texture1);
      glEnable(GL_TEXTURE_2D);
  
      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
  
      [self LoadTextureData: [[NSBundle mainBundle] pathForResource:@"normals" ofType:@"png"]];
  
      glUniform1i(uniforms[SAMPLER_1], 1); //whether this is 0 or 1 or anything else doesn't seem to make any difference for both samplers. 
  
      return TRUE;
  </code></pre>
  
  <p>Any ideas on what I'm doing wrong?
  I'm reasonably sure my sampler indices are correct, as is my shader. LoadTextureData boils down to a glTexImage2D. </p>
  
  <p>Edit:
  This is how I attempt to load and set the two textures</p>
  
  <pre><code>        //texture 1
      GLuint texture1;
  
      glGenTextures(1, &amp;texture1);
  
      glActiveTexture(GL_TEXTURE0);
      glBindTexture(GL_TEXTURE_2D, texture1);
      glEnable(GL_TEXTURE_2D);
  
      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
  
      [self LoadTextureData: [[NSBundle mainBundle] pathForResource:@"normals" ofType:@"png"]];
  
      //texture 2
      GLuint texture2;
  
      glGenTextures(1, &amp;texture2);
  
      glActiveTexture(GL_TEXTURE1);
      glBindTexture(GL_TEXTURE_2D, texture2);
      glEnable(GL_TEXTURE_2D);
  
      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
  
  
      [self LoadTextureData: [[NSBundle mainBundle] pathForResource:@"bricks" ofType:@"jpg"]];
  
  
      glUniform1i(uniforms[SAMPLER_1], 0);
      glUniform1i(uniforms[SAMPLER_2], 1);
  </code></pre>
  
  <p>The result is both samplers return the 'normals' image.</p>
  
  <p>LoadTextureData, assignment of sampler IDs, and my shader can be found at <a href="http://paste2.org/p/1514200" rel="nofollow">http://paste2.org/p/1514200</a></p>