OpenGL中矩阵堆栈的意义是什么? [英] What is the point of the matrix stack in OpenGL?

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

问题描述

我为什么要使用OpenGL的矩阵堆栈(而不是包装自己的矩阵类并仅使用它)?我不太确定为什么这么简单的任务这么复杂.是否有一些特殊的用例?

Why would I use OpenGL's matrix stack (as opposed to wrapping my own matrix class and just using that)? I'm not really sure why it is so complicated for such a simple task. Is there's some special use case for it?

如果没有必要,有什么好的替代品?

If it isn't necessary, what's a good replacement for it?

推荐答案

OpenGL的矩阵堆栈(有多个-每个矩阵模式一个)适用于分层模型.也就是说,您可以定义子对象(例如,轮子)相对于其父实体(例如,汽车)的绑定,而无需考虑绘制子对象时父对象的位置/方向.也就是说,它使您可以轻松直观地编写变换.

OpenGL's matrix stacks (there are multiples--one for each matrix mode) are intended for use with hierarchical models. That is, you can define the rigging of a child object (say, a wheel) with respect to its parent body (say, a car), without regard to the location/orientation of the parent when the child is drawn. That is, it allows you to compose transforms easily and intuitively.

matix堆栈(通常是GL矩阵运算)不能替代通用矩阵数学库.它们只是存在以允许将组合的转换有效地应用于顶点数据.就像其他人所说的那样,由于固定功能管道的消亡,该功能已从OpenGL中删除,因为着色器程序的需求不如旧管道的需求统一.

The matix stacks (and GL matrix operations in general) are no substitute for a general purpose matrix math library. They simply exist to allow composed transforms to be efficiently applied to vertex data. As others have said, this functionality has been removed from OpenGL with the demise of the fixed-function pipeline, because the needs of shader programs are less uniform than the needs of the old pipeline.

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

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