Jump to content
  • Advertisement
Sign in to follow this  
nlib

Problems using both single and multitexture

This topic is 5122 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
Advertisement
I don't see anywhere in the code calls to glEnable/glDisable(GL_TEXTURE_2D) to turn on/off texture units.

Share this post


Link to post
Share on other sites
No, I make it once in the initializing part.
Does glEnable/glDisable(GL_TEXTURE_2D) have to be done every time?

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!