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
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];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With