PDA

View Full Version : GLSL uniform sampler question



Johnson.N.M.B
06-28-2006, 03:32 PM
Hi, I am a new bie to GLSL. Here is my question:
I have set a sampler uniform to a fragment shader using glUniformiv(), but I want to get the texture stage it used and the texture target so that i can set some sampler states for it. I have looked for the specification again and again and found nothing.
May be this question is not very advanced, may be I am very stupid:(

Previously I am using NVIDIA's Cg language and it has the ability to do this, but how can I do this with GLSL?

Komat
06-28-2006, 04:06 PM
The value you set into the GLSL sampler uniform is index of texture unit to which you have to bind the desired texture.

hardtop
06-29-2006, 12:37 AM
try this:

int my_sampler_uniform_location;
my_sampler_uniform_location = GetVariable("tex");
glUniform1iARB(my_sampler_uniform_location, unit);

where "tex" is the sampler in your fragment shader
and "unit" is the texture unit index Komat is talking about.

HTH,

HardTop

Johnson.N.M.B
06-29-2006, 05:41 AM
Thank you Komat and hardtop, I'v misunderstand it. Thank you!