glTranslate help needed
Ive drawn a dinner table and coffee table using commands
glTranslate
glRotate
gluCylinder
gluDisk etc....
and they look ok, but if i want to alter the first drawing i.e. the dinner table, it alters all the co-ordinates of everything ive drawn afterward...
This is due to the glTranslate''s being linked to each other...
What command can i use to prevent this from happening?
Thanks for any help
Lee
code for the above question......
int GlassFurniture (GLvoid)
{
///////////////DRAW DINING TABLE//////////////
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
glBindTexture(GL_TEXTURE_2D, texture[13]);
glTranslatef(0.0f,-0.6f,-2.7f);
glRotatef(90.0f,1.0f,0.0f,0.0f);
gluCylinder(quadratic,0.03f,0.03f,1.5f,3,1);
glEnable(GL_BLEND);
glBindTexture(GL_TEXTURE_2D, texture[3]);
gluDisk(quadratic,0.0f,1.0f,32,1);
///////////// DRAW COFFEE TABLE ///////////
glTranslatef(0.0f,0.0f,0.0f);
glRotatef(-90.0f,1.0f,0.0f,0.0f);
glDisable(GL_BLEND);
glBindTexture(GL_TEXTURE_2D, texture[13]);
glTranslatef(-1.2f,-0.9f,3.6f);
gluCylinder(quadratic,0.03f,0.03f,3.0f,4,1); /// top right bar
glTranslatef(-1.0f,0.0f,0.0f);
gluCylinder(quadratic,0.03f,0.03f,3.0f,4,1); /// top left bar
glTranslatef(0.1f,-0.3f,0.2f);
gluCylinder(quadratic,0.03f,0.03f,2.6f,4,1); /// bottom right bar
glTranslatef(0.7f,0.0f,0.0f);
gluCylinder(quadratic,0.03f,0.03f,2.6f,4,1); /// bottom left bar
glRotatef(-90.0f,0.0f,1.0f,0.0f);
glTranslatef(0.0f,0.0f,0.0f);
gluCylinder(quadratic,0.03f,0.03f,0.7f,4,1); /// bottom back bar
glTranslatef(2.6f,0.0f,0.0f);
gluCylinder(quadratic,0.03f,0.03f,0.7f,4,1); /// bottom front bar
glTranslatef(0.2f,0.3f,-0.2f);
gluCylinder(quadratic,0.03f,0.03f,1.0f,4,1); /// top front bar
glTranslatef(-3.0f,0.0f,0.0f);
gluCylinder(quadratic,0.03f,0.03f,1.0f,4,1); /// top back bar
glRotatef(120.0f,0.0f,1.0f,-1.4f);
glTranslatef(0.0f,0.0f,0.0f);
gluCylinder(quadratic,0.03f,0.03f,0.4f,4,1); /// back left leg
glRotatef(90.0f,0.0f,1.0f,0.0f);
glTranslatef(-0.4f,0.0f,0.0f);
gluCylinder(quadratic,0.03f,0.03f,0.4f,4,1);
glEnable(GL_BLEND);
glBindTexture(GL_TEXTURE_2D, texture[12]);
glRotatef(-120.0f,0.0f,-1.0f,1.4f);
glTranslatef(0.3f,0.8f,-1.3f);
glBegin(GL_QUADS);
glTexCoord2f(1.0f, 1.0f); glVertex3f(-0.5f, -0.5f, -1.5f);
glTexCoord2f(0.0f, 1.0f); glVertex3f( 0.5f, -0.5f, -1.5f);
glTexCoord2f(0.0f, 0.0f); glVertex3f( 0.5f, -0.5f, 1.5f);
glTexCoord2f(1.0f, 0.0f); glVertex3f(-0.5f, -0.5f, 1.5f);
glEnd();
glDisable(GL_BLEND);
glDisable(GL_TEXTURE_GEN_S);
glDisable(GL_TEXTURE_GEN_T);
return TRUE;
}
Edited by - Lee J K on February 24, 2002 9:30:17 AM
int GlassFurniture (GLvoid)
{
///////////////DRAW DINING TABLE//////////////
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
glBindTexture(GL_TEXTURE_2D, texture[13]);
glTranslatef(0.0f,-0.6f,-2.7f);
glRotatef(90.0f,1.0f,0.0f,0.0f);
gluCylinder(quadratic,0.03f,0.03f,1.5f,3,1);
glEnable(GL_BLEND);
glBindTexture(GL_TEXTURE_2D, texture[3]);
gluDisk(quadratic,0.0f,1.0f,32,1);
///////////// DRAW COFFEE TABLE ///////////
glTranslatef(0.0f,0.0f,0.0f);
glRotatef(-90.0f,1.0f,0.0f,0.0f);
glDisable(GL_BLEND);
glBindTexture(GL_TEXTURE_2D, texture[13]);
glTranslatef(-1.2f,-0.9f,3.6f);
gluCylinder(quadratic,0.03f,0.03f,3.0f,4,1); /// top right bar
glTranslatef(-1.0f,0.0f,0.0f);
gluCylinder(quadratic,0.03f,0.03f,3.0f,4,1); /// top left bar
glTranslatef(0.1f,-0.3f,0.2f);
gluCylinder(quadratic,0.03f,0.03f,2.6f,4,1); /// bottom right bar
glTranslatef(0.7f,0.0f,0.0f);
gluCylinder(quadratic,0.03f,0.03f,2.6f,4,1); /// bottom left bar
glRotatef(-90.0f,0.0f,1.0f,0.0f);
glTranslatef(0.0f,0.0f,0.0f);
gluCylinder(quadratic,0.03f,0.03f,0.7f,4,1); /// bottom back bar
glTranslatef(2.6f,0.0f,0.0f);
gluCylinder(quadratic,0.03f,0.03f,0.7f,4,1); /// bottom front bar
glTranslatef(0.2f,0.3f,-0.2f);
gluCylinder(quadratic,0.03f,0.03f,1.0f,4,1); /// top front bar
glTranslatef(-3.0f,0.0f,0.0f);
gluCylinder(quadratic,0.03f,0.03f,1.0f,4,1); /// top back bar
glRotatef(120.0f,0.0f,1.0f,-1.4f);
glTranslatef(0.0f,0.0f,0.0f);
gluCylinder(quadratic,0.03f,0.03f,0.4f,4,1); /// back left leg
glRotatef(90.0f,0.0f,1.0f,0.0f);
glTranslatef(-0.4f,0.0f,0.0f);
gluCylinder(quadratic,0.03f,0.03f,0.4f,4,1);
glEnable(GL_BLEND);
glBindTexture(GL_TEXTURE_2D, texture[12]);
glRotatef(-120.0f,0.0f,-1.0f,1.4f);
glTranslatef(0.3f,0.8f,-1.3f);
glBegin(GL_QUADS);
glTexCoord2f(1.0f, 1.0f); glVertex3f(-0.5f, -0.5f, -1.5f);
glTexCoord2f(0.0f, 1.0f); glVertex3f( 0.5f, -0.5f, -1.5f);
glTexCoord2f(0.0f, 0.0f); glVertex3f( 0.5f, -0.5f, 1.5f);
glTexCoord2f(1.0f, 0.0f); glVertex3f(-0.5f, -0.5f, 1.5f);
glEnd();
glDisable(GL_BLEND);
glDisable(GL_TEXTURE_GEN_S);
glDisable(GL_TEXTURE_GEN_T);
return TRUE;
}
Edited by - Lee J K on February 24, 2002 9:30:17 AM
Use glPushMatrix()/glPopMatrix(). To be more specific, call glPushMatrix(), draw the dining table, call glPopMatrix, then glPushMatrix again, draw the coffee table, then glPopMatrix.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement