Sign in to follow this  
jinuuchukuu

glActiveTextureARB spits everywhere on the scene !!!

Recommended Posts

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…!

Share this post


Link to post
Share on other sites
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 0
glActiveTextureARB(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 stuff
gluSphere(balle, rayonBalle, 64, 64);

// Disable texture mapping on both units, and texgen on unit 0
glActiveTextureARB(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);

Share this post


Link to post
Share on other sites
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…

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this