Graphics Reference
In-Depth Information
Arrays
In addition to structures, the OpenGL ES Shading Language supports
arrays. The syntax is very similar to C, with the arrays being based on a
0 index. The following block of code shows some examples of creating
arrays:
float floatArray[4];
vec4 vecArray[2];
Arrays can be initialized using the array initializer constructor, as shown
in the following code:
float a[4] = float[](1.0, 2.0, 3.0, 4.0);
float b[4] = float[4](1.0, 2.0, 3.0, 4.0);
vec2 c[2] = vec2[2](vec2(1.0), vec2(1.0));
Providing a size to the array constructor is optional. The number of
arguments in the array constructor must be equal to the size of the array.
Operators
Table 5-2 lists the operators that are offered in the OpenGL ES Shading
Language.
Table 5-2
OpenGL ES Shading Language Operators
Operator Type
Description
*
Multiply
/
Divide
%
Modulus
+
Add
-
Subtract
++
Increment (prefix and postfix)
--
Decrement (prefix and postfix)
=
Assignment
+=, -=, *=, /=
Arithmetic assignment
 
 
 
 
Search WWH ::




Custom Search