glOrthof 和 glViewPort 的区别 [英] Difference between glOrthof and glViewPort

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

问题描述

在 OpenGL-ES 上,我对设置之间的区别感到困惑

On OpenGL-ES i'm confused on what the difference is between setting

glOrthof()  
glViewPort()
GLU.gluOrtho2D()

带有各自的参数.因为我相信这一切都将您可以看到的部分设置为指定的坐标(宽度,高度).我应该使用哪个?

with it's respective parameters. Since I believe it's all setting the part you can see to the specified coordinates (width, height). Which should I use?

推荐答案

glViewport 决定了 OpenGL 绘制到的窗口部分.这可能是整个窗口,也可能是一小部分(想想控制台游戏的分屏"模式——每个玩家都有不同的视口).

The glViewport determins the portion of the window to which OpenGL is drawing to. This may be the entire window, or a subsection (think console game's "split screen" mode- a different viewport for every player).

glOrthof 应用 正射投影到当前矩阵,通常在此调用之前设置为投影矩阵.投影矩阵与模型视图结合生成一个矩阵,将 OpenGL 坐标转换为屏幕坐标.

glOrthof applies an orthographic projection to the current matrix, which is usually set to the projection matrix before this call. The projection matrix is combined with the modelview to produce a matrix that translates your OpenGL coordinates to screen coordinates.

gluOrtho2D,

这等价于使用near = -1 和far = 1 调用glOrtho.

This is equivalent to calling glOrtho with near = -1 and far = 1.

我推荐此页面,了解有关查看和转换如何工作的更多详细信息OpenGL.

I'd recommend this page for more details on how viewing and transformation works in OpenGL.

你应该使用哪个?视口和正交投影是不同的关注点,因此您需要分别调用.glOrthof 和 gluOrtho2D 大致相当;了解差异并使用其中一个.

Which should you use? Viewports and orthographic projections are different concerns, so you'll need a call for each. glOrthof and gluOrtho2D are roughly equivalent; know the difference and use one or the other.

这篇关于glOrthof 和 glViewPort 的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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