Following some tutorials of OpenGL I noticed some of them declare some variables like transform matrices and uniform locations on the main loop of the program. From my point of view I thought it would be a bad thing because it would allocate memory for the variables for each loop.
Is this a good thing to do? Why should I calculate the location of a uniform in the shaders very loop if the location won't change?
For example, a statement like this in this code GLint modelLoc = glGetUniformLocation(lightingShader.Program, "model");
will get the same value every loop, why should I use this inside the loop then?
No comments:
Post a Comment