本文介绍了glPushMatrix和OpenGL ES的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对[glPushMatrix]以及矩阵转换和OpenGL ES有疑问. GLSL 指南说,在OpenGL ES下,必须计算矩阵:

However, when developing applications in modern versions of OpenGL and
OpenGL ES or in WebGL, the model matrix has to be computed.

In some versions of OpenGL (ES), a built-in uniform variable
gl_ModelViewMatrix is available in the vertex shader

据我了解,>在 all OpenGL ES规范下不可用.那么,像glMatrixMode,glRotate,...之类的功能在那里仍然有效吗?我可以使用它们来计算模型矩阵吗?如果没有,该如何处理这些转换矩阵?

解决方案

首先:您也不应该在常规OpenGL中使用矩阵处理函数.在旧版本中,它们只是呆板而又多余,在新版本中,它们已被完全删除.

第二:您提到的来源是Wikibook,这意味着它不是权威来源.就此Wikibook而言,它被编写为适应所有版本的GLSL,其中一些(主要是OpenGL-2.1)具有这些变量.

您可以通过自己计算来处理这些矩阵(不,这并不慢,OpenGL的矩阵内容不是GPU加速的),然后通过glLoadMatrix/glMultMatrix(旧版本的OpenGL)或着色器统一将它们传递给OpenGL. /p>

I have a question regarding [glPushMatrix], together with the matrix transformations, and OpenGL ES. The GLSL guide says that under OpenGL ES, the matrices have to be computed:

However, when developing applications in modern versions of OpenGL and
OpenGL ES or in WebGL, the model matrix has to be computed.

and

In some versions of OpenGL (ES), a built-in uniform variable
gl_ModelViewMatrix is available in the vertex shader

As I understood, gl_ModelViewMatrix is not available under all OpenGL ES specifications. So, are the functions like glMatrixMode, glRotate, ..., still valid there? Can I use them to calculate the model matrix? If not, how to handle those transformation matrices?

解决方案

First: You shouldn't use the matrix manipulation functions in regular OpenGL as well. In old versions they're just to inflexible and also redundant, and in newer versions they've been removed entirely.

Second: The source you're mentioning is a Wikibook which means it's not a authorative source. In the case of this Wikibook it's been written to accomodate for all versions of GLSL, and some of them, mainly for OpenGL-2.1 have those variables.

You deal with those matrices by calculating them yourself (no, this is not slower, OpenGL's matrix stuff was not GPU accelerated) and pass them to OpenGL either by glLoadMatrix/glMultMatrix (old versions of OpenGL) or a shader uniform.

这篇关于glPushMatrix和OpenGL ES的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 14:23