GLSL part II
- Page 50 has a list of the operators.
-
- Flow control.
- if (be) { statement; } else { statement;}
- The else clause is optional
- As are the {}
- switch (int_value) { case : statements; break; default: statements}
- No statements before the first case.
- for, while and do while as in C++
- break, continue, return
- discard : fragment shader only, exit with a message to disregard results.
- Functions:
- There are a large number of predefined functions
- Look at a appendix c
- Many math functions, sin, sinh, pow, log, exp, sqrt,
- Utility : max, min, clamp, mix (linear interpolation)
- ID: isnan, isinf
- Geometry: length, distance, dot, cross, normalize
- Matrix: transpose, determinant, inverse
- User Defined Functions
- type identifier([access modifier] type id, ...)
- void return type is permitted
- access modifiers
- in: default, pass by value
- const in: as you would expect, pass by constant value
- out: value is undefined on invocation, copied out on exit
- inout: pass by reference
- Body as in C
- There is a preprocessor
- #ifdef, #define, #undef, #ifndef, #else, #elif, #endif