Skip to main content
gamedev.net
🔒 Locked

texturing

Started by trust 2 replies 350+ views
Original Post
trust
trust
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
trust -- some girls also like openGL
Kris2456
Kris2456
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)
------------ "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)
Myopic Rhino
Myopic Rhino
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).
Trienco
Trienco
*confused* are negative tex coords making any sense unless your texture mode is repeat?
f@dzhttp://festini.device-zero.de

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.