Sign in to follow this  

Problems using both single and multitexture

This topic is 4814 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, I have some big problems using both single and multitexture. For some of my triangles I want to use single texture and for some others I want to use multi. The problem is that if I want to render objects with tris of both the different types explained above, I get no multitexture. If I only render objects with multitexture tris, it works. If I only render objects with singletexture tris, it works. What am I doing wrong? Code: // Passes if(passes == 1) { glClientActiveTextureARB(GL_TEXTURE0_ARB); glEnableClientState (GL_TEXTURE_COORD_ARRAY); glEnableClientState (GL_COLOR_ARRAY); glColorPointer(4, GL_FLOAT, 0, dInfo->_colors[0]); glTexCoordPointer(2, GL_FLOAT, 0, dInfo->_uvCoords[0]); glActiveTextureARB (GL_TEXTURE0_ARB); if(mat->_textures[0]) { //glBind... mat->_textures[0] } setBlend(mat->_blendModes[0]); glVertexPointer (3, GL_FLOAT, 0, dInfo->_points); drawFaces(dInfo); setBlend(NMaterial::_BLENDMODE_NONE); } else if(passes == 2) { // Pass 0 glClientActiveTextureARB(GL_TEXTURE0_ARB); glEnableClientState (GL_TEXTURE_COORD_ARRAY); glEnableClientState (GL_COLOR_ARRAY); glColorPointer(4, GL_FLOAT, 0, dInfo->_colors[0]); glTexCoordPointer(2, GL_FLOAT, 0, dInfo->_uvCoords[0]); // Pass 0 glActiveTextureARB (GL_TEXTURE0_ARB); if(mat->_textures[0]) { //glBind... mat->_textures[0] } glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT); glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE); glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_MODULATE); glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE); glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PREVIOUS_EXT); glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE2_RGB_EXT, GL_CONSTANT_EXT); glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR); glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR); glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND2_RGB_EXT, GL_SRC_ALPHA); glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_TEXTURE); glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_EXT, GL_PREVIOUS_EXT); glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_EXT, GL_SRC_ALPHA); glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA_EXT, GL_SRC_ALPHA); glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 1.0f); glTexEnvf(GL_TEXTURE_ENV, GL_ALPHA_SCALE, 1.0f); // Pass 1 glClientActiveTextureARB(GL_TEXTURE1_ARB); glEnableClientState (GL_TEXTURE_COORD_ARRAY); glEnableClientState (GL_COLOR_ARRAY); glColorPointer(4, GL_FLOAT, 0, dInfo->_colors[1]); glTexCoordPointer(2, GL_FLOAT, 0, dInfo->_uvCoords[1]); // Pass 1 glActiveTextureARB (GL_TEXTURE1_ARB); if(mat->_textures[1]) { //glBind... mat->_textures[1] } glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT); glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE); glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_MODULATE); glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE); glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PREVIOUS_EXT); glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE2_RGB_EXT, GL_CONSTANT_EXT); glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR); glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR); glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND2_RGB_EXT, GL_SRC_ALPHA); glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_TEXTURE); glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_EXT, GL_PREVIOUS_EXT); glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_EXT, GL_SRC_ALPHA); glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA_EXT, GL_SRC_ALPHA); glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 1.0f); glTexEnvf(GL_TEXTURE_ENV, GL_ALPHA_SCALE, 1.0f); // Using same points for both textures glVertexPointer (3, GL_FLOAT, 0, dInfo->_points); drawFaces(dInfo); setBlend(NMaterial::_BLENDMODE_NONE); }

Share this post


Link to post
Share on other sites
Since you want to switch multitexture-single texturing during rendering, setting up texture stages only once in initialization wouldn't exactly do the trick.

glEnable/glDisable(GL_TEXTURE_2D) operates only one the current active texture unit.
You have to enable/disable texture units seperately. For example:


//Enable texture units 0&1(multitexturing)
glActiveTextureARB(GL_TEXTURE1_ARB);
glEnable(GL_TEXTURE_2D);//Enable texunit1
glActiveTextureARB(GL_TEXTURE0_ARB);
glEnable(GL_TEXTURE_2D);//Enable texunit0

//Draw multitextured objects

//Keep only texunit0 on
glActiveTextureARB(GL_TEXTURE1_ARB);
glDisable(GL_TEXTURE_2D);//Disable texunit1

//Draw single textured objects


Share this post


Link to post
Share on other sites

This topic is 4814 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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