• Advertisement
Sign in to follow this  

gluCylinder?

This topic is 3449 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

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();

Share this post


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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement