如何在y或x轴在opengl中绘制圆柱 [英] How to draw cylinder in y or x axis in opengl

查看:600
本文介绍了如何在y或x轴在opengl中绘制圆柱的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只想在opengl中绘制圆柱。我发现很多样品,但所有的人都在z轴绘制圆柱。我想要他们在x或y轴。我怎么能这样做。下面的代码是在z方向绘制圆柱体的代码,我不想要它。

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 is the code draw the cylinder in z direction and i dont want it

  GLUquadricObj *quadratic;
  quadratic = gluNewQuadric();
  gluCylinder(quadratic,0.1f,0.1f,3.0f,32,32);


推荐答案

您可以使用 glRotate

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

这篇关于如何在y或x轴在opengl中绘制圆柱的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆