- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
将 glRotatef() 放在 glMatrixMode(GL_PROJECTION); 之后有什么区别
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glRotatef(red, green, blue);
并在 glMatrixMode(GL_MODELVIEW);
之后放置 glRotatef()glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glRotatef(red, green, blue);
最佳答案
来自 documentation :
glMatrixMode()
指定哪个矩阵是当前矩阵。
GL_MODELVIEW - Applies subsequent matrix operations to the modelview matrix stack.
GL_PROJECTION - Applies subsequent matrix operations to the projection matrix stack.
它们是什么意思?
如果您将当前矩阵模式设置为投影(例如 glMatrixMode(GL_PROJECTION)
),您需要更改投影矩阵。自然地,其中一个应该是下一行:
对于正交投影:
glOrtho(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near, GLdouble far);
gluOrtho2D(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top);
对于透视投影:
void glFrustum(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near, GLdouble far);
void gluPerspective(GLdouble fov, GLdouble aspect, GLdouble near, GLdouble far);
如果您将当前矩阵模式设置为模型 View (例如 glMatrixMode(GL_MODELVIEW)
),您是说我在模型 View 矩阵中,我可以应用基本操作来转换我的对象,例如:
glRotatef();
glTranslatef();
glScalef();
在你的问题中,如果你在 gl_projection 而不是 gl_modelview 之后使用 rotatef,你会旋转你的投影矩阵,这会破坏你的投影矩阵。
`
关于OpenGL glMatrixMode(GL_PROJECTION) 与 glMatrixMode(GL_MODELVIEW),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29804087/
static void resize(int width, int height) { const float ar = (float) width / (float) height;
将 glRotatef() 放在 glMatrixMode(GL_PROJECTION); 之后有什么区别 glMatrixMode(GL_PROJECTION); glLoadIdentity();
glMatrixMode(GL_PROJECTION)有什么区别和 glMatrixMode(GL_MODELVIEW) ? #include #include #include #define
在查看红皮书中的 reshape 示例时,我通常会发现如下内容: void reshape(int w, int h) { glViewport(0, 0, (GLsizei) w, (GLs
我的 OpenGL C++ 项目突然停止识别 glMatrixMode(GL_MODELVIEW)。我去吃晚饭,然后我的项目无法构建。 我在带有 CDT 插件的 Eclipse 中使用 Windows
原始问题 我想使用“gluPerspective”、“glViewport”和“gluLookAt”来操作我的相机和屏幕。 我将哪些功能应用于哪种矩阵模式?我应该/必须以什么顺序使用它们? 例如,我正
我是一名优秀的程序员,十分优秀!