Graphics Reference
In-Depth Information
Table 5-2
OpenGL ES Shading Language Operators (continued)
Operator Type
Description
==, !=, <, >, <=, >=
Comparison operators
&&
Logical and
^^
Logical exclusive or
||
Logical inclusive or
<<, >>
Bit-wise shift
&, ^, |
Bit-wise and, xor, or
?:
Selection
,
Sequence
Most of these operators behave just as they do in C. As mentioned in the
constructor section, the OpenGL ES Shading Language has strict type rules
that govern operators. That is, the operators must occur between variables
that have the same basic type. For the binary operators ( * / , + , - ), the
basic types of the variables must be floating point or integer. Furthermore,
operators such as multiply can operate between combinations of floats,
vectors, and matrices. Some examples are provided here:
float myFloat;
vec4
myVec4;
mat4
myMat4;
myVec4 = myVec4 * myFloat; // Multiplies each component of
// myVec4 by a scalar myFloat
myVec4 = myVec4 * myVec4; // Multiplies each component of
// myVec4 together (e.g.,
// myVec4 ^ 2)
myVec4 = myMat4 * myVec4; // Does a matrix * vector multiply of
// myMat4 * myVec4
myMat4 = myMat4 * myMat4; // Does a matrix * matrix multiply of
// myMat4 * myMat4
myMat4 = myMat4 * myFloat; // Multiplies each matrix component
// by the scalar myFloat
The comparison operators, aside from == and != ( < , <= , > , >= ), can be used
only with scalar values. To compare vectors, special built-in functions
allow you to perform comparisons on a component-by-component basis
(more on that later).
 
 
Search WWH ::




Custom Search