2015-11-18 3 views
0

Я пробовал этот код.Как определить массив 2d в GLSL ES?

varying vec2 blurCoordinates[2][2]; 

Но это приводит к ошибке:

Vertex шейдеров компиляции не удалось. ОШИБКА: 0:10: '[': Синтаксическая ошибка: ошибка синтаксиса ОШИБКА: 1 ошибка компиляции. Не генерируется код.

ответ

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.

...