View Full Version : struct trouble

05-17-2004, 08:08 AM
has anyone used structures in their shaders?
I'm having some difficulty doing so.

I have this declared globally:
struct TexInfo
uniform sampler2D tex; //texture unit
uniform int method; //method(reflective,projected,etc...)
uniform int application;//Blend,Decal,Modulate, etc...
uniform TexInfo textureInfo[4];

then in a function later on i have:
if(textureInfo[i].method == reflective)
do something...

the program compiles but fails to link.

thanks in advance.

05-17-2004, 08:58 AM
Looks weird to me to have "uniform" inside of structs. Try without.

05-17-2004, 09:53 AM
well, what you see there is the last configuration out of many attempts. i tried without, with, rearranged, spelled backwards etc...
well, maybe not spelled backwards.

no luck with any of the permutations I've tried.

05-17-2004, 10:24 AM
I have try following and it's work:

struct XXX
vec4 a;
vec4 b;

uniform XXX p;

void main()
gl_FragColor = p.a*p.b;
}Just set uniforms "p.a" and "p.b".