PDA

View Full Version : Getting textures to tile across a poly



dpgraves
03-13-2001, 09:16 PM
I think I use GL_REPEAT to get a texture to tile across a rectange, but its not working. I know I'm missing something basic. Below are the settings I use for every texture:

glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MO DULATE);
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_FILTE R,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTE R,GL_LINEAR);

Bob
03-14-2001, 01:09 AM
How do you setup your texture coordinates?

dpgraves
03-14-2001, 11:45 AM
I have a Poly class that has a draw function that looks like so:

void Poly::draw()
{
glBindTexture(GL_TEXTURE_2D,textureID) ;

glBegin(GL_QUADS);

glColor3ub(hColor.red,hColor.green,hColor.blue);

glTexCoord2f(0.0,1.0);
glVertex3f(hLocalVertices[0].x,hLocalVertices[0].y,hLocalVertices[0].z);

glTexCoord2f(1.0,1.0);
glVertex3f(hLocalVertices[1].x,hLocalVertices[1].y,hLocalVertices[1].z);

glTexCoord2f(1.0,0.0);
glVertex3f(hLocalVertices[2].x,hLocalVertices[2].y,hLocalVertices[2].z);

glTexCoord2f(0.0,0.0);
glVertex3f(hLocalVertices[3].x,hLocalVertices[3].y,hLocalVertices[3].z);

glEnd();
}

Right now I only have it drawing quads.

Kondrat
03-14-2001, 12:01 PM
You must specific setup texture coordinates..
for example:

glBegin(GL_QUADS);
glTexCoord2d(0,0); glVertex2d(-4,-4);
glTexCoord2d(0,2); glVertex2d(-4, 4);
glTexCoord2d(3,2); glVertex2d( 4, 4);
glTexCoord2d(3,0); glVertex2d( 4,-4);
glEnd();

so you get 3 horiz & 2 vert texture