OpenGL ES 1.1 到 2.0 的重大变化? [英] OpenGL ES 1.1 to 2.0 a major change?

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

问题描述

我正在使用 cocos2d 创建一个 iPhone 应用程序,并且我正在尝试使用以下 OpenGL ES 1.1 代码.但是,我不擅长 OpenGL,而且我的应用使用 OpenGL ES 2.0,所以我需要对其进行转换.

I'm creating an iPhone app with cocos2d and I'm trying to make use of the following OpenGL ES 1.1 code. However, I'm not good with OpenGL and my app makes use of OpenGL ES 2.0 so I need to convert it.

因此我想知道,将以下代码从 ES 1.1 转换为 ES 2.0 会有多困难?是否有一些来源可以告诉我哪些方法需要替换等?

Thus I was wondering, how difficult would it be to convert the following code from ES 1.1 to ES 2.0? Is there some source that could tell me which methods need replacing etc?

-(void) draw
{
    glDisableClientState(GL_COLOR_ARRAY);
    glDisableClientState(GL_TEXTURE_COORD_ARRAY);
    glDisable(GL_TEXTURE_2D);

    glColor4ub(_color.r, _color.g, _color.b, _opacity);
    glLineWidth(1.0f);
    glEnable(GL_LINE_SMOOTH);

    if (_opacity != 255)
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

    //non-GL code here

    if (_opacity != 255)
        glBlendFunc(CC_BLEND_SRC, CC_BLEND_DST);

    glEnableClientState(GL_COLOR_ARRAY);
    glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    glEnable(GL_TEXTURE_2D);
}

推荐答案

如果你不是那么适合 OpenGL,这将不会那么容易.

It will not be that easy if you're not so fit in OpenGL.

OpenGL ES 2.0 不再有固定功能的管道.这意味着您必须使用 GLSL 顶点和片段着色器自己管理顶点变换、光照、纹理等.您还必须自己跟踪转换矩阵,不再有 glMatrixModeglPushMatrixglTranslate 等.

OpenGL ES 2.0 doesn't have a fixed-function pipeline anymore. This means you have to manage vertex transformations, lighting, texturing and the like all yourself using GLSL vertex and fragment shaders. You also have to keep track of the transformation matrices yourself, there are no glMatrixMode, glPushMatrix, glTranslate, ... anymore.

也不再有 buitlin 顶点属性(如 glVertexglColor、...).所以这些函数,连同相应的数组函数(如glVertexPointerglColorPointer、...)和gl(En/Dis)ableClientState,也被删除了.相反,您需要通用顶点属性函数(glVertexAttribglVertexAttribPointergl(En/Dis)ableVertexAttribArray,它们的行为类似)以及相应的顶点着色器为这些属性赋予正确的含义.

There are also no buitlin vertex attributes anymore (like glVertex, glColor, ...). So these functions, along with the corresponding array functions (like glVertexPointer, glColorPointer, ...) and gl(En/Dis)ableClientState, have been reomved, too. Instead you need the generic vertex attribute functions (glVertexAttrib, glVertexAttribPointer and gl(En/Dis)ableVertexAttribArray, which behave similarly) together with a corresponding vertex shader to give these attributes their correct meaning.

我建议您阅读一本好的 OpenGL ES 2.0 教程或书籍,因为从 1.1 移植到 2.0 确实是一个重大变化,至少在您从未听说过有关着色器的情况下是如此.

I suggest you look into a good OpenGL ES 2.0 tutorial or book, as porting from 1.1 to 2.0 is really a major change, at least if you never have heard anything about shaders.

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

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