how to apply shader to specific object

c++, glsl, opengl

Solution

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.

Problem

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.

Original source