#### Archived

This topic is now archived and is closed to further replies.

# texturing

This topic is 5127 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi guys! I've tried to apply a texture on a simple quad, but the quad appears all in grey. Here is the code I use:
void drawFace (int x, int z, float* normal)
{
glPushMatrix();
{
glBegin (GL_POLYGON);
glNormal3fv(normal);
glTexCoord2f(-1, 0);
glVertex3f( -x/2, 10, z/2);

glTexCoord2f(-1,-1);
glVertex3f( -x/2, 10, -z/2);

glTexCoord2f(0,1);
glVertex3f( x/2, 10, -z/2);

glTexCoord2f(0,0);
glVertex3f( x/2, 10, z/2);
glEnd();
}
glPopMatrix();
}

//DRAW THE TABLE

void drawTable ()
{
glPushMatrix();
{
glScalef(0.7, 0.7,  0.7);
glTranslatef(0,10,0);
//tapis

glPushMatrix();
{
//glColor3f(0.4,0.6,0);

glColor3f(1,1,1);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, texture[0]);
GLfloat normal [3] = {0, 1, 0};
drawFace(50,80,normal);
glDisable(GL_TEXTURE_2D);
}
glPopMatrix();
...

Any idea? Thanks a lot! trust

##### Share on other sites
Im not a pro at texture loading, but there are a few things you should check.

1) Is the image acctually in the same folder as the .EXE

2) Is the loader you are using any good.

3) is the image size in multiples (I think) of 32 EG: 32,64,128,256,512

thats the best i can suggest...

--------

"Here lies a toppled God,
His fall was not a small one,
We but built his pedastle,
A narrow, and a tall one"
Frank Herbert (Dune:Messiah)

##### Share on other sites
Sounds like you don''t have a valid texture, possibly because of one of the reasons listed above. Check to see whether you''re loading the image correctly, and try calling glGetError() before (to make sure it''s GL_NO_ERROR) and after (to see if an error condition has been set) glTexImage2D() (or whatever you''re using).

##### Share on other sites
*confused* are negative tex coords making any sense unless your texture mode is repeat?

• 40
• 15
• 10
• 23
• 19