Textures and Lightning

Hi everyone!
I hope you all had a merry christmas and happy hanukka and hope you all have a great new year! :slight_smile:

I have the following problem, and i hope any of you guys can help me please!

I got a setting that has an object with textures (the wooden floor) and object without textures (a black metalic table on on top of the wooden floor).

Without loading the floor textures all materials are displayes alright. But when loading the floor texture the black metalic table looks orangish like the floor as well as the white details of the table appear orangish.

This is my pseudo-code:

glBindTexture glTexture2D, gaTextures(0) โ€™ Select Our Texture
//Draw Floor

    glPushMatrix           
      glScalef 0.5, 0.5, 0.5
          glCallList MetallicTable
    glPopMatrix 

If I comment the glBindTexture line everything works fine (but without textures)

This is how I set-up the textures. None worked fine without causing the previous problem:
'Create the Nearest Filtered Texture
glBindTexture glTexture2D, gaTextures(0)
glTexParameteri glTexture2D, tpnTextureMagFilter, GL_NEAREST
glTexParameteri glTexture2D, tpnTextureMinFilter, GL_NEAREST
glTexImage2D glTexture2D, 0, 3, bmInfo.biWidth, bmInfo.biHeight, _
0, tiBGRExt, GL_UNSIGNED_BYTE, baImageData(0)

'Create the Linear Filtered Texture
glBindTexture glTexture2D, gaTextures(1)
glTexParameteri glTexture2D, tpnTextureMagFilter, GL_LINEAR
glTexParameteri glTexture2D, tpnTextureMinFilter, GL_LINEAR
glTexImage2D glTexture2D, 0, 3, bmInfo.biWidth, bmInfo.biHeight, _
0, tiBGRExt, GL_UNSIGNED_BYTE, baImageData(0)

'Create the Mipmapped Texture
glBindTexture glTexture2D, gaTextures(2)
glTexParameteri glTexture2D, tpnTextureMagFilter, GL_LINEAR
glTexParameteri glTexture2D, tpnTextureMinFilter, GL_LINEAR_MIPMAP_NEAREST
gluBuild2DMipmaps glTexture2D, 3, bmInfo.biWidth, bmInfo.biHeight, tiBGRExt, _
GL_UNSIGNED_BYTE, ByVal VarPtr(baImageData(0))

And these are my OpenGL settings:
glClearColor 0.5, 0.5, 0.7, 1
glShadeModel GL_SMOOTH
glClearDepth 1#
glEnable GL_DEPTH_TEST
glDepthFunc (GL_LESS) 'glless
glHint GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST
glEnable GL_BLEND
glEnable glcTexture2D โ€™ Enable Texture Mapping

 glEnable (GL_NORMALIZE) 'Para que no se cague la iluminacion al hacer resize

Thank you so much!!! :slight_smile:

this happens because for the floor you need to enable texturing, but for the table you donโ€™t want it.

before drawing the table you should do:
glDisable( GL_TEXTURE_2D );

and before drawing the floor:
glEnable( GL_TEXTURE_2D );

you seem to be using display lists, so youโ€™re lucky you can put the previous enable/disable directly inside the list definition .

Thank you so much!!! :slight_smile:
It worked! :wink:
I hope you have a great new year!