How to draw cylinder in y or x axis in opengl

后端 未结 2 1775
长情又很酷
长情又很酷 2021-01-05 03:27

I just want to draw a cylinder in opengl. I found lots of samples but all of them draws cylinders in z axis. I want them be in x or y axis. How can i do this. The code below

2条回答
  •  心在旅途
    2021-01-05 03:54

    You can use glRotate(angle, x, y, z) to rotate your coordinate system:

    GLUquadricObj *quadratic;
    quadratic = gluNewQuadric();
    glRotatef(90.0f, 0.0f, 1.0f, 0.0f);
    gluCylinder(quadratic,0.1f,0.1f,3.0f,32,32);
    

    http://www.opengl.org/sdk/docs/man/xhtml/glRotate.xml

提交回复
热议问题