Reputation: 1308
I am curious as to how you specify the shader to use when rendering with glDrawElements(). Is it the last shader that is bound that is used? Or do you have to use other commands.
To summarize: How do I specify which shader is used when I use glDrawElements(), i.e. the shaders that will be used on the triangles in my VBO that I render.
Upvotes: 0
Views: 1080
Reputation: 10125
glUseProgram(myCoolProgramID);
set_up_render_states();
glDraw*
glUseProgram(myGreatProgramID);
set_up_render_states();
glDraw*
glUseProgram(0);
swap_buffers();
Upvotes: 0
Reputation: 6623
Correct, you just need to bind the shader with glUseProgram()
. Any subsequent calls to rendering functions will pass through the pipeline of the bound program.
Upvotes: 7