Reputation: 4232
I've tried this code.
varying vec2 blurCoordinates[2][2];
But it results in error:
Vertex shader compilation failed. ERROR: 0:10: '[' : Syntax error: syntax error ERROR: 1 compilation errors. No code generated.
Upvotes: 1
Views: 10216
Reputation: 52084
No #version
directive implies #version 100
where multi-dimensional arrays are prohibited:
Section 4.1.9, "Arrays" (page 24):
Variables of the same type can be aggregated into arrays by declaring a name followed by brackets ( [ ] ) enclosing a size. The array size must be an integral constant expression (see Section 4.3.3 “Integral Constant Expressions” ) greater than zero. It is illegal to index an array with an integral constant expression greater than or equal to its declared size. It is also illegal to index an array with a negative constant expression. Arrays declared as formal parameters in a function declaration must specify a size. Only one-dimensional arrays may be declared. All basic types and structures can be formed into arrays.
If you use #version 320 es
you can declare arrays of arrays:
Section 4.1.9, "Arrays" (page 40):
Variables of the same type can be aggregated into arrays by declaring a name followed by brackets ( [ ] ) enclosing an optional size. When present, the array size must be a constant integral expression (see section 4.3.3 “Constant Expressions”) greater than zero. The type of the size parameter can be a signed or unsigned integer and the choice of type does not affect the type of the resulting array. Arrays only have a single dimension (a single number within “[ ]”), however, arrays of arrays can be declared. Any type can be formed into an array.
...
Upvotes: 2
Reputation: 45322
As already noted in genpfault's answer, GLSL does not support multidimensional arrays right from the beginning.
The extension GL_ARB_arrays_of_arrays
does provide the features you are looking for. It was promoted an OpenGL core feature in Version 4.3, so beginning with GLSL 4.30, you can use that without relying on extensions.
Upvotes: 3