PDA

View Full Version : Binding sampler2DArray, use glActiveTexture?



nickels
06-09-2010, 06:12 PM
I could answer this question by experiment, but I am in the middle of a destructive refactor and can't try anything intelligently until I get my answer !!

I have several texture samplers:

uniform sampler2DArray shadowMapSampler;
uniform sampler2D diffuseSampler;
uniform sampler2D emissiveSampler;

etc...


I want to line all of these up with textures, so I use
glActiveTexture(GL_TEXTURE#N); glBindTexture(GL_TEXTURE_2D, tex);
glUniform1i(samplernLoc, #N);

etc...

This works for sampler2D, so my question is: Do I do the same thing for sampler2DArray? Except that my call will be glBind(GL_TEXTURE_2D_ARRAY_EXT, texArray) instead?

Would just try it, but I'm broken for the moment!!! help!

If this is right, it should work for multiple sampler2DArray objects, yes?

Dark Photon
06-10-2010, 05:24 AM
uniform sampler2DArray shadowMapSampler;
uniform sampler2D diffuseSampler;
uniform sampler2D emissiveSampler;
...
I want to line all of these up with textures, so I use
glActiveTexture(GL_TEXTURE#N);
glBindTexture(GL_TEXTURE_2D, tex);
glUniform1i(samplernLoc, #N);

etc...

This works for sampler2D, so my question is: Do I do the same thing for sampler2DArray? Except that my call will be glBind(GL_TEXTURE_2D_ARRAY_EXT, texArray) instead?
Exactly. Just packrat the texture target along with the texture handle. Works fine.