gluCylinder?

Started by
0 comments, last by toogreat4u 15 years, 5 months ago
Hello I am brand new to opengl. I am trying to draw an upright cylinder to make it look like a cup. It seems to draw as though I were looking down the top of the cylinder. I have tried changing the rotation angle but nothing changes. I can't even move the cup around. I have an idea of how most of this work but not total comprehension. Thank you! This is what I have: glTranslatef(0.0f,0.0f,-6.0f); glBegin(GL_QUADS); GLUquadric *quadric = gluNewQuadric(); glPushMatrix(); //save first position //Draw the cylinder glTranslatef(0.0f, -1.0f, 0.0f); glPushMatrix(); glRotatef(45.0f, 1.0f, 0.0f, 0.f); //cylinder rotation glTranslatef(-1.5f,0.0f,0.0f); glRotatef(90.0f, 0.0f, 1.0f, 0.0f); gluCylinder(quadric, 1.0f, 1.0f, 1.0f, 40, 40); glPopMatrix(); glEnd();
Advertisement
OpenGL draws the cylinder about the Z direction for the tip, so in your rotations and translations your not doing anything with the Z axis. Try rotating about the Z axis by doing glRotate(degree (whatever you want), dx , dy, dz(change to 1));

Also double check your calls with the rotation and translation because normally the convention when doing a translation and rotation is this:

glTranslate(dx, dy, dz);
glRotate(angle, dx, dy, dz);
glTranslate(-dx, -dy, -dz);
/* object code */

This topic is closed to new replies.

Advertisement