Uniform array length

I need the length of an uniform array in one of my shaders.
I wrote it like this:

if(aIndex > anArray.length){ ... } 

just like i would do it in java.
This is working on nvidia, but not on ati.

How i can fix this?

The GLSL spec says you need to use (member-) function syntax (note the parentheses after length):

if(index > array.length()) {}

Also, be sure to declare which version of GLSL your shader is written in, by putting a “#version 450” (or some other number) at the top, otherwise you’ll get GLSL 1.2 (or 1.1?), and that might not have supported getting the length of an array with either syntax.

Thank you!

im using 140…

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.