Graphics Reference
In-Depth Information
fog
struct gl_FogParameters {
vec4 color;
float density;
float start;
float end;
float scale;
} gl_Fog
Table 14.1. Uniform variables defined by compatibility-mode OpenGL functions.
Defining Attribute Variables in Your Application
Atribute variables are a way to provide per-vertex data to a vertex shader.
These are only available to a vertex shader. If any vertex-speciic atribute data
needs to be used by a shader, the vertex shader must first convert it to an out
variable so the later shader can take it as an in variable. Here we describe the
general approach to defining variables that describe properties of an individ-
ual vertex in your model.
Besides the usual atribute data such as the coordinates, normal, color,
or texture coordinates of a vertex, you may also need to define other data to
associate with a vertex. OpenGL lets applications deine custom atributes to
pass to a vertex shader. Each vertex atribute has an indexed location and can
contain up to four values.
As with uniform variables, you need to determine the location of an atri-
bute variable before you can set it:
GLint glGetAttribLocataion( program, GLchar * attribName );
where attribName is a character string of the name of the variable.
An application can specify a per-vertex atribute value using one of the
functions
void glVertexAttrib{i}{t}{v}(GLuint location, TYPE val)
The value of i can be 1, 2, 3, or 4, depending on the dimension of the
data to be given to that atribute. The value of t specifies the data type for the
data to be given to the atribute; this can be b (byte), s (short), i (int), f (float),
d (double), ub (unsigned byte), us (unsigned short), or ui (unsigned int). The
suffix v means that the data is in vector form rather than as a list of scalars.
These are consistent with the format of the glVertex* functions.
The parameter location is the particular symbol table location of the
atribute variable you are seting, and the parameter or parameters val are
Search WWH ::




Custom Search