PDA

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



explorer101
12-24-2014, 10: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.

uwi2k2
12-25-2014, 01:12 AM
hi,

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.

cu
uwi2k2

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