Enabling/disabling shaders?

Started by
0 comments, last by MARS_999 18 years ago
Well, I used the NeHe OpenGL basecode to use while I learn cg Shaders. Well, everything works okay. I'm using the GLEW library. Anyhow, I can write a vertex/fragment shader that just deals with a plain, uncolored polygon, and one that deals with colored polygons. And I'm working on learning more about manipulating polygons, and using textures and lighting. Anyhow, I tested a simple toon shader that I found. I used a 'GLUquadric' object to create a sphere to test the shader. But I also added a cylinder. And I want to know how I would assign the shader to the sphere, but "disable" the shader when I draw the cylinder. I mean, how do I "call" the shader when I draw the sphere, and then "uncall" (LoL =P) the shader when I draw the cylinder. I thought maybe calling "glUseProgram(p);" then "glUseProgram(NULL);", but of course that didn't work. And while I'm on the subject of shaders, does anyone know where I can find some tutorials on them? Just beginner tutorials, that are explained at least fairly well. Thanks in advance, Matt U.
:==-_ Why don't the voices just leave me alone?! _-==:
Advertisement
Well if you are using a different shader per object then you should be able to do this to setup and shutdown the shader if not something else is wrong.

glUseProgram(shader1);//bind shader 1glUseProgram(0);//shutdown shader 1//render 2nd objectglUseProgram(shader2);//bind shader 2glUseProgram(0);//shutdown shader 2


Check out http://www.clockworkcoders.com/oglsl/advanced_framework.htm

This topic is closed to new replies.

Advertisement