OpenGL 4.4 - glBindTextures

OpenGL 4.4 comes with “glBindTextures(first, count, array_of_textures)” function to bind all textures at once, but in an OpenGL 3.3+ environment I need to assign a texture’s unit to a specificed Shader’s Variable Location using “glUniform1i()” like this (pseudo code):


uint texChannel;
uint shaderVariableLocation;
uint samplerObjectIndex;
uint textures[2];
int texCount;

  //init
texCount = 2;
glGenSampler(1, &samplerObjIndex);
glGenTextures(texCount, &textures);

  //exec during rendering
for (i=0; i<texCount; i++){
  texChannel = i;
  shaderVariableLocation = myGetShaderVariableLocation('texture'+texChannel);
  glActivetexture(GL_TEXTURE0 + texChannel);
  glBindTexture(GL_TEXTURE_2D, textures[i]);
  glUniform1i(shaderVariableLocation, texChannel);
  glBindSampler(texChannel, samplerObjIndex);
}

…and it works very well.
Now I would like to bind all textures at once using new function “glBindTextures()”:


  //exec during rendering
glBindTextures(0, 2, &textures);
for (i=0; i<texCount; i++){
  texChannel = i;
  shaderVariableLocation = myGetShaderVariableLocation('texture'+texChannel);
  glUniform1i(shaderVariableLocation, texChannel);
  glBindSampler(texChannel, samplerObjIndex);
}

…but it doesn’t works!
I think “glUniform1i()” works only on current binded texture and not just linking Shader Variable’s Location to an existing TextureUnit, so I think it is impossibile to replicate previous case.
So why adding this new function if it is inusable in an OpenGL 3.3+ environment?

I said right?
Thanks!