OpenGL ES 2.0 / GLSL 1.0
Operators and Expressions
最終更新:
opengles
-
view
Operators [5.1]
Numbered in order of precedence. The relational and equality operators > < <= >= == != evaluate to a Boolean.
To compare vectors component-wise, use functions such as lessThan(), equal(), etc.
To compare vectors component-wise, use functions such as lessThan(), equal(), etc.
Operator | Description | Associativity |
( ) | parenthetical grouping | N/A |
[ ] ( ) . ++ -- |
array subscript function call & constructor structure field or method selector, swizzler postfix increment and decrement |
L - R |
++ -- + - ! |
prefix increment and decrement unary |
R - L |
* / | multiplicative | L - R |
+ - | additive | L - R |
< > <= >= | relational | L - R |
== != | equality | L - R |
&& | logical and | L - R |
^^ | logical exclusive or | L - R |
|| | logical inclusive or | L - R |
? : | selection (Selects one entire operand. Use mix() to select individual components of vectors.) | L - R |
= += -= *= /= |
assignment arithmetic assignments |
L - R |
, | sequence | L - R |
Vector Components [5.5]
In addition to array numeric subscript syntax, names of vector components are denoted by a single letter. Components can be swizzled and replicated, e.g.: pos.xx, pos.zy
{x, y, z, w} | Use when accessing vectors that represent points or normals |
{r, g, b, a} | Use when accessing vectors that represent colors |
{s, t, p, q} | Use when accessing vectors that represent texture coordinates |