Jump to content
  • Advertisement
Sign in to follow this  
TFS_Waldo

OpenGL Enabling/disabling shaders?

This topic is 4477 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
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 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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!