Sign in to follow this  
sweetdaddy

gluCylinder?

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this