PDA

View Full Version : Accessing array elements



yossi
05-19-2004, 05:50 AM
Is there a way to access an array's element such as:
int array[10];
int index = 1;
int b = array[index];

The compiler report error of 'indirect access not aloud'.

How can I bypass this problem?

Many thanks,

Yossi

simongreen
05-19-2004, 08:12 PM
Is this in a fragment shader?

Fragment shaders do not support indexing into constant memory. This is a quirk of the way current hardware works. If you want random access, encode the data in a texture and use a texture lookup.