i have several objects on my scene. i want to apply my shader to one of them only. Environment: OpenGL 2.0, C++, GLUT, GLEW.
In your drawcall draw that object with that shader and draw the other ones without it.. can't really be any more simple than that ;P You could use enums in your object class where you can specify shaders that are enabled for that object and only pass them through that shader when they are supposed to.. of course if it's a fullscreen pixelshader then you're in trouble as it processes every pixel and renders a new image to display. Unless you have a way of passing the object as a parameter and a algoritm to only apply the alterations at the location of that object.
The shader program is only in effect for as long as it is installed. Only the draw calls you make while the program is installed will use the shader. You must install your shader, draw your object, and then uninstall the shader.
Edit: By "install" the shader I mean use glUseProgram
with your shader's handle. By "uninstall" I mean either installing another shader or calling glUseProgram
with an argument of 0
. See glUseProgram. My "install/uninstall" terminology comes from there.