Pladnius Brooks
Pladnius Brooks

Reputation: 1308

OpenGL - Using shaders with glDrawElements

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: 1076

Answers (2)

fen
fen

Reputation: 10115

glUseProgram(myCoolProgramID);
set_up_render_states();
glDraw*

glUseProgram(myGreatProgramID);
set_up_render_states();
glDraw*

glUseProgram(0);
swap_buffers();  

Upvotes: 0

jli
jli

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

Related Questions