Looking at examples at http://learnopengl.com/#!Getting-started/Hello-Triangle and many different places, I've found that the draw sequence usually goes like this:
// setup VBO, VAO, load shaders
while (true) { // game loop
glUseProgram(shader);
glBindVertexArray(someVAO);
drawStuff(...);
// ...
}
Now my question is, is there any reason why I'd want to repeatedly do glUseProgram(...)
on each frame, unless I'm using multiple shaders (such as OpenGL clearing currently used shader after rendering?)?
Also, if I am using multiple shaders, do I need to glUseProgram
before switching to a different VAO? I'm unclear on whether the VAO just gets set as active, or if it actually modifies the state of a currently used shader. I've tried looking this up in the OpenGL spec, but couldn't quite find it.
edit: Yes I did mean glUseProgram
, sorry.