Vertical Cylinder
I'm really new to OpenGL and was hoping that someone could help me figure out how to draw a vertical cylinder and then draw another vertical cylinder on top of it. From what I can tell, the gluCylinder function only draws a cylinder along the z axis.
Sorry for the noob question but I'm lost on this one.
Besides constructing the cylinder in its desired orientation and position, you should make yourself familiar with transformations.
Look at the glTranslate and glRotate routines. Try something like
Then look at the glPushMatrix and glPopMatrix routines. Try something like
Look at the glTranslate and glRotate routines. Try something like
glRotatef( 90, 1, 0, 0 );
just before invoking gluCylinder. Play with this routine. If you got some understanding, useglTranslatef( 0, y, 0 );
with some y (unfortunately I cannot give an advice how big y has to be, because this depends on your other set-up). Then try the combinationglTranslatef( 0, y, 0 );glRotatef( 90, 1, 0, 0 );
Then look at the glPushMatrix and glPopMatrix routines. Try something like
glPushMatrix();glRotatef( 90, 1, 0, 0 );drawLowerCylinder();glPopMatrix();glPushMatrix();glTranslatef( 0, y, 0 );glRotatef( 90, 1, 0, 0 );drawUpperCylinder();glPopMatrix();
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement