9

The following shader method:

float[1] GetArray()
{
    float array[1];
    array[0] = 1.0;
    return array;
}

Gives me: ERROR: 0:1: 'GetArray' : syntax error: Array size must appear after variable name

SeismicSquall
  • 348
  • 2
  • 10

1 Answers1

11

I found a way to work around this limitation. You can return an array by modifying the passed in array by reference. Here is a sample fragment shader:

void GetArray(inout vec4 array[1])
{
    array[0] = vec4(.5,.2,.1,1.0);
} 

void main()
{
    vec4 test[1];
    GetArray(test);
    gl_FragColor = test[0];
}
SeismicSquall
  • 348
  • 2
  • 10