Graphics Programs Reference
In-Depth Information
Data Types
Like regular C types, the following basic types are commonly used in GLSL :
void: used with functions that do not return a value or for an
empty argument list
bool: represents boolean values true or false
int: a single signed integer
float: a single floating-point scalar
Vectors with two, three, or four components are also available for the basic types
mentioned previously:
bvec2: a boolean vector of two components
bvec3: a boolean vector of three components
bvec4: a boolean vector of four components
ivec2: an integer vector of two components
ivec3: an integer vector of three components
ivec4: an integer vector of four components
vec2: a floating-point vector of two components
vec3: a floating-point vector of three components
vec4: a floating-point vector of four components
Apart from these, we can also construct square matrices— mat2 , mat3 and
mat4 —from scalars, vectors, or a combination of both scalars and vectors. Matrices
are very useful data types, because they can be associated with objects to transform
them by updating the 3D-Transformation data, such as the amount of translation and
angle of rotation.
Now we'll look at some examples of declaring and initializing variables of various
types using GLSL . For these examples, we modify Listing 3-8 in such a way that the
output of the point vertex shader is not affected.
Search WWH ::




Custom Search