Multiple shaders: how to deal with attributes?

Hello,
I was wondering which are the best practices (resulting in best performance) when using multiple shaders. The approach I would use at the moment is:
init:

  • create and populate index buffer, vertex buffer, normal buffer, …
  • compile and link glsl program

draw:

  • use the glsl program
  • query attribute locations for vertex, normal, …
  • bind buffers, set and enable the attributes
  • query all uniform locations and set corresponding data
  • glDrawElements

Is there a better approach than re-querying all locations at each draw iteration?
Thanks!
smani

Rather than querying locations at each render, you can store the locations for all the attributes/uniforms at the initialization then during render just use the stored locations of attrib./uniforms.

Mh indeed, makes sense. Thanks!