Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Lee J K

glTranslate help needed

This topic is 6017 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
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

Share this post


Link to post
Share on other sites
Use glPushMatrix()/glPopMatrix(). To be more specific, call glPushMatrix(), draw the dining table, call glPopMatrix, then glPushMatrix again, draw the coffee table, then glPopMatrix.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!