PDA

View Full Version : struct trouble



Aeluned
05-17-2004, 07:08 AM
Also,
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.

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

Aeluned
05-17-2004, 08: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.

yooyo
05-17-2004, 09: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".

yooyo