PDA

View Full Version : GL_POLYGON and a bitmap image



Zath
06-21-2006, 01:01 PM
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.heigh t,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

xavirn
06-21-2006, 11:34 PM
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();

Zath
06-22-2006, 07:35 AM
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

RigidBody
06-22-2006, 07:41 AM
try

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

Zath
06-22-2006, 08:41 AM
Thanks,

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

But it's still blurry near the camera.

Zath

ZbuffeR
06-22-2006, 09:02 AM
you need higher resolution texture, or increase "quality setting" in windows display control panel.

Zath
06-22-2006, 12:24 PM
Actually, I need to to a glrepeat.... looking into it now :D

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