Graphics Reference
In-Depth Information
GLSL omits some of the capabilities
of C, and some areas where GLSL
has language features that remind
us of the best of earlier generations
of computer languages. This chap-
ter focuses on these differences and
discusses why they are needed for
the shader environment. There is a
tendency for any discussion like this
to have a strong flavor of a language
manual, and you might find that
you use this chapter more as a refer-
ence than as general reading.
We introduced a number
of GLSL language features in
Chapter 3, but here we take a more thorough approach to the language and
describe it more formally. We are working from the GLSL language specifica-
tion [23] and include those features and capabilities that we believe are most
useful to you, but we are not absolutely complete in our coverage. Once you
are familiar with a good working set of GLSL, you probably should read the
GLSL specification to see what else is there—especially since the language will
continue to evolve over time. 1
We are indebted to the GLSL Shader Language Specification document
both for the overall information it contains and for its excellent tables of GLSL
functions and operations that we have borrowed from extensively.
GLSL shader capabilities are very much
a moving target. This chapter and all
our examples are based on GLSL 4.1.
However, we also include many features
that are deprecated in that standard but are
available in compatibility mode, because
they may be helpful to someone learning to
work with shaders for the first time.
In order to keep current on GLSL,
you should consult [32] from time to time. 1
You will not need a new copy of glman ,
however, because OpenGL will compile
only the GLSL shaders, but you may need
to get a new OpenGL driver.
Factors that Shape Shader Languages
Shader languages operate in a different environment and with different goals
than general-purpose languages. Their environment is the processing capabil-
ity of graphics cards, which differs in some important ways from the capability
of a general CPU, and their goals are tightly focused on supporting graphics
operations, rather than more general kinds of computations. These capabilities
shape the language in significant ways, and it is important that you under-
stand their impacts as you write shaders.
1. Good resources: “OpenGL.” Khronos . Available at htp://www.khronos.org/opengl/.
“OpenGL 4.2 API Quick Reference Card.” Khronos . Available at htp://www.khronos.org/iles/
opengl42-quick-reference-card.pdf, 2010.
“OpenGL Shading Language.” OpenGL . Available at htp://www.opengl.org/documentation/glsl/,
2011.
 
Search WWH ::




Custom Search