Graphics Reference
In-Depth Information
The keywords' meanings are
const : The value of the input parameter is copied to the formal param-
eter, but no change to the formal parameter is allowed in the function.
in : The value of the actual parameter is copied to the formal parameter,
but no changed value will be returned. The actual parameter may be an
expression that sets the value to be copied into the function. The formal
parameter may be changed during the execution of the function. The key-
word in may be preceded by const , in which case the formal parameter
will be treated as a const in the function.
out : The formal parameter must be an lvalue and will have no value
until it is set inside the function. Any function operations may use this
parameter, but a value must be set in the function. The value of the for-
mal parameter in the function is copied to the actual parameter when the
function terminates.
inout : The formal parameter must be an lvalue and is assumed to have
a value when it is copied to the function, and this value may be used or
changed during the function execution. When the function terminates,
the value of the formal parameter is copied to the actual parameter.
Const
The const data type lets you declare named compile-time constants. Any vari-
ables qualified by const are read-only variables for that shader and must be
initialized when declared; the initial values must be constant expressions. The
const qualifier can be used with any of the basic data types. As in C++, using
const is good programming style because it is strongly typed and it will cause
the compiler to throw an error if you atempt to re-assign a value to something
you originally expected should never get reassigned.
GLSL has several built-in const variables for vertex and fragment shad-
ers. The values given for initialization are implementation-dependent and are
the minimum values allowed.
const int gl_MaxLights = 8;
const int gl_MaxClipPlanes = 6;
const int gl_MaxTextureUnits = 2;
const int gl_MaxTextureCoords = 2;
const int gl_MaxVertexAttribs = 16;
const int gl_MaxVertexUniformComponents = 512;
const int gl_MaxVaryingFloats = 32;
const int gl_MaxVertexTextureImageUnits = 0;
const int gl_MaxCombinedTextureImageUnits = 2;
const int gl_MaxTextureImageUnits = 2;
const int gl_MaxFragmentUniformComponents = 64;
const int gl_MaxDrawBuffers = 1;
Search WWH ::




Custom Search