简体   繁体   English

OpenGL:glRotatef旋转了什么?

[英]OpenGL: What does glRotatef rotate?

When I call the glRotatef like this: 当我像这样调用glRotatef

glRotatef(angle,0.0,1.0,0.0) //rotate about y-axis

I know it is to rotate by angle degrees about the y axis . 我知道它是围绕y axis旋转angle
But, what is being rotated here? 但是, 这里正在旋转? Which object exactly? 究竟是哪个对象?

Probably a silly question, but I'm entirely new to this. 可能是一个愚蠢的问题,但我对此完全陌生。

I was able to rotate a line about it's endpoint using the answer here , but I don't really understand how it works internally. 我能够使用这里的答案旋转关于它的端点的一条线,但我真的不明白它是如何在内部工作的。

Nothing is being rotated, because OpenGL does not "store" objects. 没有任何东西在旋转,因为OpenGL不会“存储”对象。

glRotatef, like glMultMatrixf, is used to modify the currently selected transformation matrix. glRotatef与glMultMatrixf一样,用于修改当前选择的转换矩阵。 This has an effect on how things are drawn subsequently. 这会影响随后的绘制方式。 One sets the matrices (and other stuff!) how one wants, and then one draws one's objects. 一个人设置矩阵(和其他东西!)一个人想要的,然后一个人绘制一个人的对象。

For more information, see the OpenGL redbook, and google around for the difference between "retained mode" and "immediate mode". 有关更多信息,请参阅OpenGL红皮书,并查看“保留模式”和“立即模式”之间的区别。

glRotate will act on the current matrix, which is by default GL_MODELVIEW . glRotate将作用于当前矩阵,默认情况下为GL_MODELVIEW Doing so will affect any 3D object that you draw in the sequence. 这样做会影响您在序列中绘制的任何3D对象。 The current matrix is changed with glMatrixMode . 使用glMatrixMode更改当前矩阵。 The model-view matrix is then applied to any geometry rendered with glVertex , glDrawArrays , etc. 然后将模型视图矩阵应用于使用glVertexglDrawArrays等渲染的任何几何体。

OpenGL-side matrices are now deprecated. OpenGL端矩阵现已弃用。 If you use core OpenGL 3+, these functions are no longer available. 如果您使用核心OpenGL 3+,则这些功能将不再可用。 If you are new to OpenGL, I suggest that you skip learning the old ways and focus on modern, shader-oriented OpenGL. 如果您是OpenGL的新手,我建议您跳过学习旧方法并专注于面向着色器的现代OpenGL。 You can check the following links for some good tutorials. 您可以查看以下链接以获得一些好的教程。

  1. open.gl open.gl
  2. opengl-tutorial.org opengl-tutorial.org
  3. ogldev ogldev

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM