PDA

View Full Version : uniform array length



SkySoldier
09-09-2014, 08:48 AM
Hello.
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?

carsten neumann
09-09-2014, 11:15 AM
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.

SkySoldier
09-09-2014, 03:30 PM
Thank you!

im using 140...