This book has over 100 more pages than the rst edition did. Here are the
1. This book is wrien against the most-recent specication releases:
OpenGL 4.x and GLSL 4.x0.
2. All code examples have been brought up-to-date with the current stan-
dard of the GLSL language.
3. There is an entire chapter (with examples) on the new tessellation shaders.
4. All chapters have more examples and more exercises.
5. Many diagrams have been improved. The ones involving GLSL function-
ality levels have been brought up to 4.x0.
6. The OpenGL Architecture Review Board (ARB) has depecated some por-
tions of OpenGL, but has not eliminated them. This edition discusses that,
and presents a strategy to write your own code with that in mind. All code
examples in this book now follow that strategy. Also, by following that
strategy, you will be prepared for migration to OpenGL-ES 2.0.
7. Appendices have been added showing the use of C++ classes to make
writing OpenGL shader applications easier, and help with the post-dep-
Programmable computer graphics shaders have had an interesting his-
tory. In not-too-distant memory, at least for some of us, all aspects of computer
graphics were programmable. In fact, “programmable” is probably not a good
term, because that implies that there was a programmability option when cre-
ating an image. There wasn’t. If you wanted anything to happen, you had no
choice but to program it. Yourself. “Involuntary programmability” might be a
beer way to put it.
Computer graphics APIs changed that for most graphics practitioners.
With a good API, you could write very good graphics programs much more
easily because you could let the API’s functionality take over large portions of
the graphics process. However, you paid for this in giving up any functional-
ity that the API didn’t know how to handle. A good example is surface shad-
ing, where most of the 1990s APIs could not support anything beyond simple
smooth lighted surfaces.
Fortunately, neither the computer graphics research community nor
advanced graphics practitioners were satised with this. First in software and
then in hardware, as graphics processors were developed, specic functional-
ity was developed to support the programming of features that xed-function
graphics APIs had fenced o. This functionality has now developed its own
standards, including the GLSL shader language that is part of the OpenGL
standard. Programmable graphics shaders, programs that can be downloaded