Difference between glOrthof and glViewPort

被刻印的时光 ゝ 提交于 2019-11-29 17:19:40

问题


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?


回答1:


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 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,

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

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

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.



来源:https://stackoverflow.com/questions/7572862/difference-between-glorthof-and-glviewport

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!