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

查看:24
本文介绍了从 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?

查看 es 2.0 标签与 stackoverflow 中标准 es 标签的数量相比,看起来现在还不是 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.

推荐答案

在尝试确定是否使用 OpenGL ES 2.0 时,不要只通过 Stack Overflow 上的标签中的活动.一方面,并​​非每个 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()等函数a很久以前使用 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 的出色指南,请参阅 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天全站免登陆