View Full Version : How to implement different shaders for different objects in an OpenGL program

12-24-2014, 09:40 PM
Hello and Merry Christmas!

I have two triangles in my OpenGL program. I want to apply different effects to these triangles using different shaders.

How can I do that? How can I implement different shaders for these triangles? What is the logic for it? Is there a special function or something like that for it?

I'll be glad if you post an example or something like that.. I googled it but I couldn't find anything.

Thanks in advance.

12-25-2014, 12:12 AM

thats really simple.
you create and compile 2 pairs of shaders. so you have 2 programmobjects.

than you use the first programm ( shader pair )
gluseprogramm( progOne )
than you draw triangle number 1.

after that you use programm 2
gluseprogramm ( progTwo )
and draw the second triangle...

you can do that quite often during one frame.


12-25-2014, 12:26 AM
I understand, thank you!