glActiveTextureARB spits everywhere on the scene !!!

Started by
1 comment, last by jinuuchukuu 18 years, 6 months ago
I combined multitexturing and sphere mapping to apply on specified objects an environment reflect beside the object’s texture or/and colours. After all the initiation worked out is tried to use the calls like this glEnable(GL_TEXTURE_GEN_S); glEnable(GL_TEXTURE_GEN_T); glActiveTextureARB(GL_TEXTURE0_ARB); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, texture[0]); glActiveTextureARB(GL_TEXTURE1_ARB); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, texture[2]); gluSphere(balle, rayonBalle, 64, 64); glDisable(GL_TEXTURE1_ARB); glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE0_ARB); glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_GEN_T); glDisable(GL_TEXTURE_GEN_S); Trying to concentrate the multitexturing only one or more object appeared to be impossible, the actived TEXTURE0_ARB TEXTURE1_ARB won’t deactivate… May someone tell me if I forgot something or what I’m doing wrong…!
Advertisement
glActiveTextureARB(GL_TEXTUREx_ARB) is just a unit selector, it won't enable or disable something by itself. It merely selects the unit on which subsequent state changing commands (glEnable, glDisable, etc) are carried out.

So, first you need to realize that GL_TEXTURE_GEN modes are also affected by the active texture unit, since they're part of the texture state and independent for each unit. Then, you need to call glDisable(GL_TEXTURE_2D) for each unit you would like to disable.

Something like this:
// Enable texture mapping units 0 and 1, plus texgen on unit 0glActiveTextureARB(GL_TEXTURE0_ARB);glEnable(GL_TEXTURE_GEN_S);glEnable(GL_TEXTURE_GEN_T);glEnable(GL_TEXTURE_2D);glBindTexture(GL_TEXTURE_2D, texture[0]);glActiveTextureARB(GL_TEXTURE1_ARB);glEnable(GL_TEXTURE_2D);glBindTexture(GL_TEXTURE_2D, texture[2]);// Render stuffgluSphere(balle, rayonBalle, 64, 64);// Disable texture mapping on both units, and texgen on unit 0glActiveTextureARB(GL_TEXTURE1_ARB);glDisable(GL_TEXTURE_2D);glActiveTextureARB(GL_TEXTURE0_ARB);glDisable(GL_TEXTURE_2D);glDisable(GL_TEXTURE_GEN_T);glDisable(GL_TEXTURE_GEN_S);

All right, thanks
Used the right way as you showed me, the multitex works like more educated (does not spits everywhere on the street anymore ;-))
Even if because of my blended sphere I presume, my reflection try doesn’t look like one…

This topic is closed to new replies.

Advertisement