Graphics Reference
In-Depth Information
Uniform Variables in Compatibility Mode
In compatibility mode, GLSL defines a number of built-in uniform variables
that give you access to OpenGL state information, as we described in Chapter 5.
There are a number of built-in uniform variables, including the ModelView,
Projection, and Normal matrices, and all texture, light, and materials data.
Your applications set these values through standard OpenGL functions and
can use the associated uniform variables in your shaders.
In the discussion of the GLSL language, you saw a list of built-in uni-
form variables. Their names begin with gl_ and they give you access to all the
OpenGL state values or values derived from these states. When a program
object is made current, the built-in uniform variables that track the OpenGL
state are initialized to the current value of those states, and any later OpenGL
calls that modify state values update the built-in uniform variable that tracks
those states. The most commonly used of these are shown in Table 14.1.
Standard OpenGL Function
Built-in Uniform Variable
transformations
mat4 gl_ModelViewMatrix
mat4 gl_ModelViewProjectionMatrix
mat4 gl_ProjectionMatrix
mat3 gl_NormalMatrix
materials
struct gl_MaterialParameters {
vec4 emission;
vec4 ambient;
vec4 diffuse;
vec4 specular;
float shininess;
} gl_Frontmaterial; gl_BackMaterial;
lights
struct gl_LightSourceParameters {
vec4 ambient;
vec4 diffuse;
vec4 specular;
vec4 position;
vec4 halfVector;
vec3 spotDirection;
float spotExponent;
float spotCutoff;
float spotCosCutoff;
} gl_LightSource[gl_MaxLights];
textures
gl_TextureMatrix[i]
Search WWH ::




Custom Search