PDA

View Full Version : Textures and Lightning



Rodrix
12-28-2005, 01:55 PM
Hi everyone!
I hope you all had a merry christmas and happy hanukka and hope you all have a great new year! :)

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!!! :)

dmy
12-28-2005, 04:05 PM
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 .

Rodrix
12-28-2005, 09:30 PM
Thank you so much!!!! :)
It worked! ;)
I hope you have a great new year!