If you want a less comprehensive guide that will just get you started, check out the OpenGL bible.
If I misunderstood your question and you already know OpenGL, and want to study more about GLSL in particular, here's a good phong shading example that shows the basics.
Compiling a shader source is really simple,
First you need to allocate a shader slot for your source, just like you allocate a texture, using glCreateShader:
Link the shaders to each other, first allocate a program using glCreateProgram, attach the shaders into the program using glAttachShader, and link them using glLinkProgram:
The Red Book is the standard book on OpenGL. Don't be discouraged by the fact that the Amazon review for the 7th Edition has only two stars; this is because people are disappointed that there isn't more on the newest OpenGL features in the book. Previous editions got more stars.
Another good book is the OpenGL SuperBible.
The NeHe Tutorials are one of the most often cited OpenGL tutorials, with sample code not only in C++ but in many other programming languages.
Depending on what you are trying to achieve and what is your current knowledge, you can take different approaches.
If you are trying to learn OpenGL 2.0 while also learning GLSL, I suggest getting the Red book and the Orange book as a set, as they go hand in hand.
If you want a less comprehensive guide that will just get you started, check out the OpenGL bible.
If I misunderstood your question and you already know OpenGL, and want to study more about GLSL in particular, here's a good phong shading example that shows the basics.
Compiling a shader source is really simple,
First you need to allocate a shader slot for your source, just like you allocate a texture, using
glCreateShader
:After that you need to load your source code somehow. Since this is really a platform dependent solution, this is up to you.
After obtaining the source, you set it using
glShaderSource
:Then you compile your sources with
glCompileShader
:Link the shaders to each other, first allocate a program using
glCreateProgram
, attach the shaders into the program usingglAttachShader
, and link them usingglLinkProgram
:Then, just like a texture, you bind it to the current rendering stage using
glUseProgram
:To unbind it, use an id of 0 or another shader ID.
For cleanup:
And that's mostly everything to it, you can use the
glUniform
function family alongside withglGetUniform
to set parameters as well.Here are a few books that I used when writing OpenGL code in C++:
Fundamentals of Computer Graphics
OpenGL SuperBible
OpenGL Red Book
OpenGL Primer
You might check out the MIT OpenCourse on computer graphics too. It might help supplement your development.
Best of luck!