1

Right before setting any uniform parameter to the shader, I am using glGetUniformLocation to retrieve its position instead of doing it once in the begining and storing the int position value. Like this::

const int location = glGetUniformLocation(program, name.c_str());
glUniform4fv(location, 1, &v.x);

Would it considerably affect my performance?

user642252
  • 513
  • 5
  • 22
  • I'm also interested in this, not just for Android's OpenGL ES but for standard OpenGL in general. – smf68 Apr 22 '11 at 21:37

1 Answers1

1

IMHO, it will depend on the speed of comparing strings (hashes of strings). While shader is not recompiled the int position will not changed (however, it may be not changed). So it is a good practice to store locations once and get it every frame.

Yuriy Vikulov
  • 2,469
  • 5
  • 25
  • 32