title: OpenGL texture unbinding
body: <p>I have an array of textures for model rendering in OpenGL. This array holds diffuse and specular textures. Since some meshes don't have a specular texture, I simply bind the NULL texture to my specular sampler after each rendering, and I only bind one if the mesh has a specular texture. However, I still see specular textures on meshes that don't have one.<br><br>
  This is my code for rendering<br>
  materialIndices holds the index of the texture in the array, if the mesh does not have a specular texture<br>
  the index is -1
  <br>texture unit 0 for diffuse
  <br>texture unit 2 for specular <br></p>
  
  <pre><code>void CModel::render()
  {
      if (!loaded)    return;
      int numMeshes = meshSize.size();
      for (int i = 0; i &lt; numMeshes; i++)
      {
          int matIndex = materialIndices[i][0];
          textures[matIndex].bind(0);
          int specIndex = materialIndices[i][1];
          if (specIndex &gt;= 0) textures[specIndex].bind(2);
          glDrawArrays(GL_TRIANGLES, meshStartIndices[i], meshSize[i]);
  
          glActiveTexture(GL_TEXTURE2);
          glBindTexture(GL_TEXTURE_2D, NULL);
      }
  }
  </code></pre>