PDA

View Full Version : age old problem with textures



mithun_daa
12-11-2003, 10:44 AM
im havin problems mapping textures. i dont c anything happening. when i set the border to 1 though, i get a white box.

herez my code

glGenTextures 1, texName1(0)
glBindTexture glTexture2D, texName1(0)
'gluBuild2DMipmaps glTexture2D, 3, 256, 256, tiRGBA, pxlByte, intTexture(0)
glTexParameteri glTexture2D, tpnTextureWrapS, GL_REPEAT
glTexParameteri glTexture2D, tpnTextureWrapT, GL_REPEAT
glTexParameteri glTexture2D, tpnTextureMagFilter, GL_LINEAR
glTexParameteri glTexture2D, tpnTextureMinFilter, GL_LINEAR
glTexImage2D glTexture2D, 0, GL_RGBA8, 256, 256, 0, tiRGBA, pxlByte, intTexture(0)


'display routine
glEnable glcTexture2D
glTexEnvf tetTextureEnv, tenTextureEnvMode, tepDecal
glBindTexture glTexture2D, texName1(0)
MsgBox texName1(0)
glTranslated intWidth - 100, intHeight - 100, 0
glRotated intRotatey, 0, 0, 1
'glMaterialfv faceFrontAndBack, mprAmbientAndDiffuse, ambient_color(0)
glColorMaterial faceFront, cmmAmbientAndDiffuse
glEnable glcColorMaterial
glBegin bmQuads
glTexCoord2f 0, 0
glVertex2f -50, -50
glTexCoord2f 0, 1
glVertex2f -50, 50
glTexCoord2f 1, 1
glVertex2f 50, 50
glTexCoord2f 1, 0
glVertex2f 50, -50
glEnd
glDisable glcTexture2D
glDisable glcColorMaterial

Relic
12-12-2003, 01:29 AM
First, your quad is clockwise, default winding order is counterclockwise.
Try sending the vertices in this order:



3--------2
| |
| |
| |
0--------1

Texture coordinates are then:
(0, 0), (1, 0), (1, 1), (0, 1)


The color material has the effect that you set the material for front to ambient and diffuse with the current color. You look at the backface, and don't send color and don't have lighting enabled?
You can remove the color material stuff alltogether.

That the quad gets white if you specify border == 1 is obvious, because your texture image has no border and the download fails. Inconsistent textures disable the texture unit.

Add some more glGetError calls while developing and monitor them carefully!

Face culling cannot be the reason that you're not seeing anything, if you get a white box while the texture is not downloaded.
The texture env is in decal mode, it should show on both sides in full brightness even if the back material may be black.
Remains the texture image, make sure you have the correct image downloaded.
Try to download a 1x1 RGBA texture
GLubyte tex[4] = {0xFF, 0x00, 0x00, 0xFF};
Should get you red.

[This message has been edited by Relic (edited 12-12-2003).]