Using Multiple Texture Units

I’m developing a shadowing application which requires the use of multiple texture units (when using Textured Models)and I’m coming unstuck with how to use them when using Shadow Mapping.

Basically I want tex0 to be the model texture and tex1 to be the shadow map which is projected over the model/scene.

I’m doing :

for each light {
set to light position
generateshadowmap
set up tex gen on glActiveTexture(GL_…1_ARB)
set to cam position
set up hardware shadow map filters (COMPARE_R_TO_TEXTURE, etc)
glActiveTexture(GL_TEXTURE0_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
renderScene();
disable tex gen
}

My question is how do you use glActiveTexture() and when to use them when switching between textures. Because I get a black artefact across my scene when I try to use multitexturing. At the moment I’ve got nothing but textureless boxes :frowning:

Neutrinohunter

If you are getting artifacts then it is probably due to precision issues. Have a look at http://www.paulsprojects.net/tutorials/smt/smt.html which has a tutorial, although using fixed pipeline.

There is nothing special with glActiveTexture.