2015-11-18 55 views

回答

1

正如genpfault的回答中已經提到的那樣,GLSL從一開始就不支持多維數組。

擴展GL_ARB_arrays_of_arrays確實提供了您正在尋找的功能。它在4.3版中被提升爲OpenGL核心功能,所以從GLSL 4.30開始,您可以在不依賴擴展的情況下使用它。

0

沒有#version指令意味着#version 100其中多維數組是禁止的:

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.

如果使用#version 320 es你可以聲明數組的數組:

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.

...