I have an OpenGL application that uses Shaders and Vertex Buffer Objects, with GLM for matrices and vectors. Because there are matrix transformations that occur every frame, I'm calling glUniformMatrix4fv() every frame. Below is a snippet of my code:
ViewMatrix = glm::rotate(glm::mat4(1.0f), glm::radians(YRotation), glm::vec3(0.0f, 1.0f, 0.0f)) * ViewMatrix;
ViewMatrix = glm::rotate(glm::mat4(1.0f), glm::radians(XRotation), glm::vec3(1.0f, 0.0f, 0.0f)) * ViewMatrix;
ViewMatrix = glm::translate(glm::mat4(1.0f), Translate) * ViewMatrix;
...
glUniformMatrix4fv(ShaderProgram->GetUniformLocation("View"), 1, GL_FALSE, glm::value_ptr(ViewMatrix));
As shown, I am calling GetUniformLocation() to get the location of the View matrix that I declared as a uniform in the shader. It is a member function of a CProgram
class which simply calls glGetUniformLocation(). Because this is being called every frame, I was wondering whether it would be better to call glGetUniformLocation() only once, at the beginning of the program, and repeatedly use the value returned from that. Would there actually be any noticeable difference in frame rate?