[OpenGL 3.2] glUseProgram: inside the mainloop ?
I wonder if i should put «glUseProgram» inside my render loop, or just calling it once after the GLSL program has been compiled and linked.
I'm asking this, because i tried and put it outside the render loop, and it worked.
But i read several tutorials which put it inside the render loop.
Do you only ever intend to render with one program? In general, in any serious application, you will be using multiple programs. So yes, it "goes in the render loop."
The OpenGL program is a global state, and only one program can be active. So if you have more than one program, then you need to enable each of them every time you use them.
Originally Posted by pixpaf
There is some overhead for switching programs. If you have two programs and switch MANY times between those for every frame, then it can be a good idea to sort the drawing. For example, draw all geometry with the first program, and then switch to the second program and draw the other things.