OpenGL ES Shading Language : array

For matrix construction, the language is very flexible. These basic rules
describe how matrices can be constructed:
• If only one scalar argument is provided to a matrix constructor, that
value is placed in the diagonal of the matrix. For example mat4(1.0)
will create a 4 × 4 identity matrix.
• A matrix can be constructed out of multiple vector arguments, for
example a mat2 can be constructed from two vec2s.
• A matrix can be constructed out of multiple scalar arguments, one for

each value in the matrix, consumed from left to right.


There are two important things to note about the use of arrays in the
OpenGL ES Shading Language. The first is that many OpenGL ES implementations
will not allow an array to be indexed with a variable with an
unknown value at compile time. That is, OpenGL ES only mandates that
array indexing be supported by constant integral expressions (there is an
exception to this, which is the indexing of uniform variables in vertex shaders
that is discussed in Chapter 8).


The other note about arrays is that there is no syntax in the OpenGL ES
Shading Language to initialize an array at creation time. The elements of the
array need to be initialized one-by-one and also arrays cannot be const qualified
because there is no syntax for initializing such an array.


The comparison operators (==, !=, <, etc.) can only be performed on scalar
values.

你可能感兴趣的:(OpenGL ES Shading Language : array)