从OpenGL ES 1.1过渡到OpenGL ES 2.0 [英] Transitioning from OpenGL ES 1.1 to OpenGL ES 2.0

查看:261
本文介绍了从OpenGL ES 1.1过渡到OpenGL ES 2.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

iPhone 3GS推出已经有一段时间了,现在可能足够的OpenGL ES 2.0支持设备的市场份额,以保证在其中发展。

It's been a while since iPhone 3GS came out, and now there might be enough market share of OpenGL ES 2.0 supporting devices to warrant developing in it.

但情况是很多开发人员可能已经在OpenGL ES 1.1中拥有庞大的代码库。

But the situation is a lot of developers probably already have huge code bases in OpenGL ES 1.1

如何将ES 1.1转换为ES 2.0?我想需要处理矩阵,以及像GL_FOG,GL_CULL这样的东西?

How does one transitionf rom ES 1.1 to ES 2.0? I suppose the matrices need to be taken care of, as well as stuff like GL_FOG, GL_CULL maybe?

是否可以为这些函数编写替代品,例如你的自己的glTranslatef,glPushmatrix等?这是否意味着性能上升?

Is it possible to write "substitutes" for these functions, e.g your own glTranslatef, glPushmatrix etc? Will this mean performance hit?

转换到ES 2.0还有哪些其他考虑因素?使用其中任何一个都有哪些优点和缺点(除了显而易见的设备支持问题)?

What other considerations are there for transitioning to ES 2.0? What advantages and disadvantages (besides the obvious device support issue) comes with using either of these?

查看与stackoverflow中的标准es标记相比es 2.0标记的数量,虽然它看起来不是2.0的时候了。

Looking at the amount of es 2.0 tags compared to standard es tags in stackoverflow, it looks like it's not the time for 2.0 yet though.

推荐答案

不要只是通过Stack Overflow上的标签中的活动在尝试确定是否使用OpenGL ES 2.0时。首先,并非每个2.0或与着色器相关的问题都被标记为这样。此外,在推出iPhone SDK时或之后不久,有很多关于OpenGL ES 1.1的信息,因此人们对该API更为熟悉。很明显,人们对OpenGL ES 2.0很感兴趣,因为我关于这个主题的一节课是迄今为止最受欢迎的我的课程视频

Don't just go by activity in the tags on Stack Overflow when trying to determine whether or not to use OpenGL ES 2.0. For one thing, not every 2.0 or shader-related question is tagged as such. Also, a lot of information was present about OpenGL ES 1.1 at or soon after the launch of the iPhone SDK, so people are much more familiar with that API. There clearly is a lot of interest in OpenGL ES 2.0, as evidenced by the fact that my one class session on the subject is by far the most popular of all of my course videos.

在大多数情况下,方式你处理你的几何图形在1.1和2.0之间是相同的,以及你的帧缓冲区之类的东西,但是其他一切都从内置函数确定转移到你自己的着色器。您将不得不编写一些代码来复制简单的函数,例如使用模型视图矩阵或纹理,但这些代码往往只需要着色器中的几行。例如,使用模型视图矩阵调整顶点就像在顶点着色器中放置这样的直线一样简单:

For the most part, the way you handle your geometry will be the same between 1.1 and 2.0, as well as things like your framebuffers, but everything else shifts from being determined by built-in functions to your own shaders. You will have to write some code to replicate simple functions like using the model view matrix or texturing, but those tend to only require a few lines in a shader. For example, using the model view matrix to adjust your vertices is as simple as placing a line like this in your vertex shader:

vec4 transformedPosition = modelViewProjMatrix * position;

就个人而言,我更换了glRotate()等函数很久以前使用Core Animation辅助函数来有效地操纵模型视图矩阵。这使得将代码转移到OpenGL ES 2.0变得微不足道。

Personally, I replaced the glRotate(), etc. functions a long while ago using the Core Animation helper functions to manipulate what effectively is a model view matrix. This made it trivial to move that code across to OpenGL ES 2.0.

Jeff LaMarche还有一个非常有用的帮助类,用于在他的文章中包装大多数着色器程序设置代码此处

Jeff LaMarche also has an extremely useful helper class for wrapping most of your shader program setup code in his article here.

有关转换到OpenGL ES 1.1的精彩指南,请参阅从OpenGL ES 1.0迁移到OpenGL ES 2.0一文,这是本书的一章 GPU Pro ,可以在随附的文档中找到 PowerVR SDK

For a great guide on making the transition to OpenGL ES 1.1, see the "Migration from OpenGL ES 1.0 to OpenGL ES 2.0" article which is a chapter in the book GPU Pro and can be found within the documentation that accompanies the free PowerVR SDK.

我'我在之前的回答中解释了OpenGL ES 2.0的优点此处这里,但是对于新API可以提供给你的前后展示也许是有用的。

I've explained what OpenGL ES 2.0 can be good for in my previous answers here and here, but perhaps it would be useful to demonstrate a before-and-after in regards to what the new API can give you.

OpenGL ES 1.1:

OpenGL ES 1.1:

OpenGL ES 2.0:

OpenGL ES 2.0:

希望你能看到更换的回报一些带着色器的内置函数。

Hopefully, you can see the payoff of replacing some of the built-in functions with shaders.

这篇关于从OpenGL ES 1.1过渡到OpenGL ES 2.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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