hello,
i am using glsl with java since a short time
and fall over an simple variable problem.
//Fragment Shader
uniform sampler2D t0; // my texture
uniform int eec1,eec2,eec3,eec4; // a simple int variable
sampler2D tex[20]; //a set of 2dtextures
int ini=0;
…
void main(void)
{
//One Time Init
if (ini==0)
{
ini=1;
tex[0]=t0;tex[1]=t1;tex[2]=t2;tex[3]=t3;
//put the sampler2d in an array
}
…
/*
that works perfect,but only when i define the
vars eec1-4 in the fragment shader(static)
(like int eec1=1;) ,
when i want to get eec1-4 over uniform
from the java application the fragment shader wont work.
(its strange… the vars are transmitted,but it seems
to be a problem that glsl wont use external ints in arrays)
//Java Example
int eec1 = gl.glGetUniformLocationARB(program, “eec1”);
gl.glUniform1iARB(eec1, 1);
*/
…
//when removing // the shader works
//eec1=0; //textur 1
//eec2=1; //textur 2
//eec3=2; //textur 3
//eec4=3; //textur 4
vec4 texel_av=0;
" texel_av += texture2D(tex[eec1] , texCoord)*pow1;
" texel_av += texture2D(tex[eec2] , texCoord)*pow4;
" texel_av += texture2D(tex[eec3] , texCoord)*pow2;
" texel_av += texture2D(tex[eec4] , texCoord)*pow3;
…
}
can anybody help me please?