Sign in to follow this  
TFS_Waldo

OpenGL Enabling/disabling shaders?

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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 1

glUseProgram(0);//shutdown shader 1

//render 2nd object
glUseProgram(shader2);//bind shader 2

glUseProgram(0);//shutdown shader 2




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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this