struct trouble

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.

Looks weird to me to have “uniform” inside of structs. Try without.

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.

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

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