GL_POLYGON and a bitmap image

If I put this image onto another object like the teapot, it works ok, but not onto the polygon.

It just turns it green, not the grass image I need…

		glEnable(GL_TEXTURE_2D);
		BMPLoad("plants03.bmp",bmp);
		glTexImage2D(GL_TEXTURE_2D,0,3,bmp.width,bmp.height,0,GL_RGB,GL_UNSIGNED_BYTE,bmp.bytes);

		glBegin(GL_POLYGON);
			glNormal3f (1.0, 1.0, 1.0);
			glVertex3f (-50.0f, 0, -50.0f);
			glVertex3f (50.0f, 0, -50.0f);
			glVertex3f (50.0f, 0, 50.0f);
			glVertex3f (-50.0f, 0, 50.0f);
		glEnd();

		glDisable(GL_TEXTURE_2D);

Is this a case where I must specify coordinates to map?

Thanks,

Zath

glBegin(GL_POLYGON);
glNormal3f (1.0, 1.0, 1.0);
glTexCoord2i(0,0);glVertex3f (-50.0f, 0, -50.0f);
glTexCoord2i(1,0);glVertex3f (50.0f, 0, -50.0f);
glTexCoord2i(1,1);glVertex3f (50.0f, 0, 50.0f);
glTexCoord2i(0,1);glVertex3f (-50.0f, 0, 50.0f);
glEnd();

Thanks!

That is what I was missing. Still a newb to this but getting there.

But one last thing.

The bmp is mapping but closer to the camera it’s pixalated or blurred.

Zath

try

glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

Thanks,

That helped with the pixelation.
That is, no longer can see the large squares.

But it’s still blurry near the camera.

Zath

you need higher resolution texture, or increase “quality setting” in windows display control panel.

Actually, I need to to a glrepeat… looking into it now :smiley:

And yep, got it looking ok now…

		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);

		glBegin(GL_POLYGON);
			glNormal3f (1.0, 1.0, 1.0);
			glTexCoord2i(0,0);
			glVertex3f (-50.0f, 0, -50.0f);
			glTexCoord2i(9,0);
			glVertex3f (50.0f, 0, -50.0f);
			glTexCoord2i(9,9);
			glVertex3f (50.0f, 0, 50.0f);
			glTexCoord2i(0,9);
			glVertex3f (-50.0f, 0, 50.0f);
		glEnd();

Thanks all for the help on this one…

Now onto the next…

Zath