0

我刚刚从问题 #6663300 中读到 glut 函数不正确,我应该使用 glu 绘图原语而不是 glut 绘图原语。

所以我对如何使用 GLUquadricObj 有一些疑问。无论我走到哪里,GLUquadricObj 通常用作指针,然后在 1 个绘图阶段结束时创建和销毁新实例。是否有任何给定时间在没有指针的情况下使用 GLUquadricObj,以便将 GLUquadricObj 的引用传递给 gluCylinder 之类的函数?

对于第二个问题,假设我有一个不断更新的动画,它会一直持续到他的程序关闭,我应该为绘制的每一帧创建和删除 GLUquadricObj 吗?或者我可以只留下一个 GLUquadricObj ,然后在程序关闭时将其删除?如果我只想在整个动画中保留 1 个 GLUquadricObj 指针,是否需要使用绘图列表?

GLUquadricObj *qobj = 0; qobj = gluNewQuadric();

gluCylinder(qobj, CylinderRadius, CylinderRadius, length, Slices, stacks);

gluDeleteQuadric(qobj);

让 GLUquadricObj 是全局的而不是本地的是否更有效?或者我应该让 GLUquadricObj 在绘制的框架内被创建和销毁?

4

1 回答 1

0

is there any given time where GLUquadricObj is used without pointer so that you pass reference of the GLUquadricObj into functions like gluCylinder?

I don't think so. declaring a GLUquadricObj variable probably doesn't set its internal state correctly, so don't do it. (although i haven't looked at the glu source so i can't say for sure)

is it any more efficient to have the GLUquadricObj being global rather than local?

Probably very slightly.

or should I just leave GLUquadricObj being created and destroyed within a drawn frame?

Yes. Don't worry about efficiency if you are only learning opengl, the difference this change would make is completely undetectable. Just leave it the way it is.

于 2013-01-23T18:25:12.250 回答