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 states for primitives, as we describe fully in Chapter 5
on the GLSL language. 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. These 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 3.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];
Table 3.2. Some common uniform variables defined by OpenGL functions in compatibility
mode.
Search WWH ::




Custom Search