PDA

View Full Version : problem



jonn82
01-30-2004, 08:09 AM
I have the following code in OpenGL and I want to make a specific drawing

void Render()
{

glClear(GL_COLOR_BUFFER_BIT ); // Clean up the colour of the window
// and the depth buffer


glTranslatef(0,-30,0);
glRotatef(80,1,0,0);
glColor3f(0.5, 0.5, 1.0);
GLUquadricObj *p = gluNewQuadric();
gluQuadricDrawStyle(p,GLU_FILL);
gluCylinder(p, 40.0, 40.0, 7.0, 1000, 100);
glColor3f(1.0, 1.0, 1.0);
glScalef(40,40,40);
Circle();



glMatrixMode(GL_MODELVIEW);
glLoadIdentity(); //loading identity table

}

You can easily see that I draw a cylinder with a circle just over it. What I want to do is draw another cylinder of different size just above the already drawn shape. I tried to use the same code to draw the next cylinder, but it appears below...and when I try to translate the first shape and put it lower it seems the glTranslate(); command has no effect !!!
What should I do?

jwatte
01-30-2004, 08:57 AM
Ask in the beginners forum?

mikeman
01-30-2004, 09:27 AM
When you use matrix transformations to scale,rotate or move an object put them inside a PushMatrix...PopMatrix.
Here's an example:

glPushMatrix;
glTranslatef(x,y,z);
DrawFirstObject;
glPopMAtrix;

glPushMatrix;
glScalef(2,2,2);
glRotatef(40.0,0,1,0);
DrawSecondObject;
glPopMAtrix;

But it really is a begginer's question.