glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, texture[1]);
glColor3f(1.0f,1.0f,1.0f);
glBegin(GL_QUADS);
glNormal3f( 0.0f, 0.0f, 1.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f(x, y, 0.0f);
glTexCoord2f(0.0f, 1.0f); glVertex3f(x+0.02f, y, 0.0f);
glTexCoord2f(0.0f, 0.0f); glVertex3f(x+0.02f, y-0.02f, 0.0f);
glTexCoord2f(1.0f, 0.0f); glVertex3f(x, y-0.02f, 0.0f);
glEnd();
glDisable(GL_TEXTURE_2D);
glPrint(x1, y1+0.02f,0,"x: %1.2f", x);
glPrint(x1+0.1f, y1+0.02f, 0,"y: %1.2f", y);
Texturing multiple objects.
I have a function that draws a square with a texture, but it only displays the texture the first time I call it, so only the first square has a texture. The others just dont appear.
The function body.
January 02, 2001 10:02 PM
i think you need to translate the square, so that your not just drawing the same square.
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, texture[1]);
glColor3f(1.0f,1.0f,1.0f);
glPushMatrix();
glTranslatef(x,y,0) // <--- ***use this***
glBegin(GL_QUADS);
glNormal3f( 0.0f, 0.0f, 1.0f);
glTexCoord2f(1.0f, 1.0f);glVertex3f(0, 0, 0.0f);
glTexCoord2f(0.0f, 1.0f);glVertex3f(0+0.02f, 0, 0.0f);
glTexCoord2f(0.0f, 0.0f);glVertex3f(0+0.02f, 0-0.02f, 0.0f);
glTexCoord2f(1.0f, 0.0f);glVertex3f(0, 0-0.02f, 0.0f);
glEnd();
glPopMatrix();
glDisable(GL_TEXTURE_2D);
glPrint(x1, y1+0.02f,0,"x: %1.2f", x);
glPrint(x1+0.1f, y1+0.02f, 0,"y: %1.2f", y);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, texture[1]);
glColor3f(1.0f,1.0f,1.0f);
glPushMatrix();
glTranslatef(x,y,0) // <--- ***use this***
glBegin(GL_QUADS);
glNormal3f( 0.0f, 0.0f, 1.0f);
glTexCoord2f(1.0f, 1.0f);glVertex3f(0, 0, 0.0f);
glTexCoord2f(0.0f, 1.0f);glVertex3f(0+0.02f, 0, 0.0f);
glTexCoord2f(0.0f, 0.0f);glVertex3f(0+0.02f, 0-0.02f, 0.0f);
glTexCoord2f(1.0f, 0.0f);glVertex3f(0, 0-0.02f, 0.0f);
glEnd();
glPopMatrix();
glDisable(GL_TEXTURE_2D);
glPrint(x1, y1+0.02f,0,"x: %1.2f", x);
glPrint(x1+0.1f, y1+0.02f, 0,"y: %1.2f", y);
x and y change, so they shouldnt be drawing on top of each other. It worked fine untill i added textures(just white blocks before).
but thanks for the tip none the less, i'll give it a shot.
Edited by - rask on January 2, 2001 11:16:29 PM
but thanks for the tip none the less, i'll give it a shot.
Edited by - rask on January 2, 2001 11:16:29 PM
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement