How to implement different shaders for different objects in an OpenGL program

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.


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.


I understand, thank you!