Multitexturing woes

Alright, I’m positive I’m doing something stupid, but I am unable to get multitexturing to work. I’m working from the GT40 tutorial from Chman’s website. I’m just trying to get a little test done with a brute force renderer, but ran into this issues.

All that is happening is the base texture is applied but no detail texture is showing up. My framerate also drops about 25% from just rendering with normal texturing.

The display is reporting true for ARB_multitexture. Is there something I need to do within LWJGL to set it up?

I’m positive that the detail texture is loaded properly, because if I set it as GL.TEXTURE0_ARB it renders.

Here’s my rendering method.


public void render() {
        float shade;
        float texLeft = 0.0f;
        float texUp = 0.0f;
        float texDown = 0.0f;
        
        float red = 1.0f;
        float green = 1.0f;
        float blue = 1.0f;
        
        if(isDetailed && isTextured) {
              gl.disable(GL.BLEND);
              gl.activeTextureARB(GL.TEXTURE0_ARB);
                  gl.enable(GL.TEXTURE_2D);
                  TextureManager.getTextureManager().bind(textureId);
                  gl.activeTextureARB( GL.TEXTURE1_ARB );
                  
                  gl.texEnvi( GL.TEXTURE_ENV, GL.TEXTURE_ENV_MODE, GL.COMBINE_ARB );
                  gl.texEnvi( GL.TEXTURE_ENV, GL.RGB_SCALE_ARB, 2 );

                  TextureManager.getTextureManager().bind(id);
        } else if(isTextured) {
              gl.enable(GL.TEXTURE_2D);
              TextureManager.getTextureManager().bind(textureId);
        }

        for (int z = 0; z < terrainSize - 1; z++) {
            gl.begin(GL.TRIANGLE_STRIP);

            if(isTextured) {
                texUp = (float)z/terrainSize;
                      texDown = (float)(z+1)/terrainSize;
            }
            
            for (int x = 0; x < terrainSize - 1; x++) {
                  
                  if(isTextured && isDetailed) {
                              texLeft = (float)x/terrainSize;
                              gl.multiTexCoord2fARB( GL.TEXTURE0_ARB, texLeft, texUp );
                              gl.multiTexCoord2fARB( GL.TEXTURE1_ARB, texLeft*repeatDetailMap, 
                                          texUp*repeatDetailMap );
                  }else if(isTextured) {
                    texLeft = (float)x/terrainSize;
                    gl.texCoord2f(texLeft, texUp);
                }
                
                if(isLighted) {
                    shade = lightMap.getShade(x,z);
                    red = shade * lightMap.getColor().x;
                    green = shade * lightMap.getColor().y;
                    blue = shade * lightMap.getColor().z;
                    
                } else {
                    shade = (float)heightData.getTrueHeightAtPoint(x, z);
                    shade /= 255;
                    red = shade;
                    green = shade;
                    blue = shade;
                }
                
                gl.color3f(red, green, blue);

                gl.vertex3f(x, heightData.getScaledHeightAtPoint(x, z), z);

                if(isLighted) {
                    shade = lightMap.getShade(x,z+1);
                              red = shade * lightMap.getColor().x;
                              green = shade * lightMap.getColor().y;
                              blue = shade * lightMap.getColor().z;
                } else {
                    shade = (float)heightData.getTrueHeightAtPoint(x, z+1);
                    shade /= 255;
                              red = shade;
                              green = shade;
                              blue = shade;
                }
                gl.color3f(red, green, blue);
                if(isTextured && isDetailed) {
                              gl.multiTexCoord2fARB( GL.TEXTURE0_ARB, texLeft, texDown );
                              gl.multiTexCoord2fARB( GL.TEXTURE1_ARB, texLeft*repeatDetailMap,
                                    texDown*repeatDetailMap );
                }else if(isTextured) {
                    gl.texCoord2f(texLeft, texDown);
                }

                gl.vertex3f(
                    x,
                    heightData.getScaledHeightAtPoint(x, z + 1),
                    z + 1);
            }

            gl.end();
        }
        
        if(isTextured && isDetailed) {
              gl.activeTextureARB( GL.TEXTURE1_ARB );
              gl.disable( GL.TEXTURE_2D );
              gl.bindTexture( GL.TEXTURE_2D, 0 );
              gl.activeTextureARB( GL.TEXTURE0_ARB );
              gl.disable( GL.TEXTURE_2D );
              gl.bindTexture( GL.TEXTURE_2D, 0 );
              
            }else if(isTextured) {
              gl.disable(GL.TEXTURE_2D);
        }
    }


Thanks for any help.

Well, I’m not sure what I did. I nuked all the multitexturing code and started over, I retyped it from memory, and it worked. I still don’t know what I was doing incorrectly before, and comparing the posted code with the working doesn’t reveal any obvious answers. This matter is resolved though.

Well, you forgot to enable texturing on unit 1…

Cas :slight_smile:

Damn… ok, no more responses to this thread… let my stupidity get buried. I was wondering why the second attempt worked… I swore I did the “same” thing.