为什么在OpenGL中有glMatrixMode? [英] Why is there a glMatrixMode in OpenGL?

查看:96
本文介绍了为什么在OpenGL中有glMatrixMode?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是不明白OpenGL的glMatrixMode是干什么的.

I just don't understand what OpenGL's glMatrixMode is for.

据我所知,当glMatrixMode(GL_MODELVIEW)被调用时,它 后跟glVertexglTranslateglRotate等, 也就是说,OpenGL命令将某些对象放置 空间.另一方面,如果glOrthoglFrustumgluProjection 被称为(即如何渲染放置的对象),它的调用先于glMatrixMode(GL_PROJECTION).

As far as I can see, when glMatrixMode(GL_MODELVIEW) is called, it is followed by glVertex, glTranslate, glRotate and the like, that is, OpenGL commands that place some objects somewhere in the space. On the other hand, if glOrtho or glFrustum or gluProjection is called (ie how the placed objects are rendered), it has a preceeding call of glMatrixMode(GL_PROJECTION).

我想到目前为止我写的是一个假设,有人会证明 我错了,但不是完全使用不同的 Matrix模式 point 因为有不同种类的gl功能:那些与 放置对象以及具有如何渲染对象的对象?

I guess what I have written so far is an assumption on which someone will prove me wrong, but is not the point of using different Matrix Modes exactly because there are different kinds of gl-functions: those concerned with placing objects and those with how the objects are rendered?

推荐答案

这很简单,可以很简单地回答:

This is simple and can be answered very briefly:

  • 渲染顶点(如glVertex中所示)取决于称为模型-视图矩阵" "投影矩阵的矩阵的当前状态 "

  • Rendering vertices (as in glVertex ) depends on the current state of matrices called "model-view matrix" and "projection matrix",

命令glTranslatefglPushMatrixglLoadIdentityglLoadMatrixglOrthogluPerspective和整个族影响当前矩阵(可以是以上)

The commands glTranslatef, glPushMatrix, glLoadIdentity, glLoadMatrix, glOrtho, gluPerspective and the whole family affect the current matrix (which is either of the above),

命令glMatrixMode 选择受上述命令影响的矩阵(模型视图或投影).

The command glMatrixMode selects the matrix (model-view or projection) which is affected by the forementioned commands.

(此外,还有用于纹理坐标的纹理矩阵,但很少使用.)

(Also, there's also the texture matrix used for texture coordinates, but it's seldomly used.)

所以常见的用例是:

  • 大多数时候模型视图矩阵都处于活动状态,
  • 每当您需要初始化投影矩阵时(通常是在开始时或调整窗口大小时),将活动对象切换为投影,设置透视图,然后返回到模型视图.

这篇关于为什么在OpenGL中有glMatrixMode?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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