Cocos2D 2.0 - 数以万计的 OpenGL 错误数以万计、错误、Cocos2D、OpenGL

2023-09-06 09:06:51 作者:騎著小豬耕田

我正在将一个 Cocos2D 项目转换为 2.0.

I am transposing a Cocos2D project to 2.0.

我使用 Cocos2D 2.0 模板(没有物理的简单模板)创建了一个空白项目,并将所有文件从旧项目转移到空白项目.

I have created a blank project using Cocos2D 2.0 template (the simple template without physics) and transferred all files from the old project to the blank project.

我也将其转换为 ARC.

I have also converted that to ARC.

我编译并没有看到任何错误.我运行该应用程序,它似乎运行正常,但我在控制台上出现这些错误...

I compile and I see no errors. I run the app and it appears to be running correctly, but I have these errors on console...

MyApp[1266:707] cocos2d: animation stopped
MyApp[1266:707] cocos2d: animation started with frame interval: 60.00
MyApp[1266:707] cocos2d: surface size: 640x960
MyApp[1266:707] cocos2d: surface size: 640x960
MyApp[1266:707] cocos2d: animation stopped
MyApp[1266:707] cocos2d: animation started with frame interval: 60.00
MyApp[1266:707] failed to call context
MyApp[1266:707] cocos2d: surface size: 640x960
MyApp[1266:707] Failed to make complete framebuffer object 0x8CDD
OpenGL error 0x0506 in -[CCSprite draw] 532
OpenGL error 0x0502 in -[CCGLView swapBuffers] 280
MyApp[1266:707] failed to call context
MyApp[1266:707] cocos2d: surface size: 640x960
MyApp[1266:707] Failed to make complete framebuffer object 0x8CDD
OpenGL error 0x0506 in -[CCSprite draw] 532
OpenGL error 0x0502 in -[CCGLView swapBuffers] 280
OpenGL error 0x0506 in -[CCSprite draw] 532
OpenGL error 0x0502 in -[CCGLView swapBuffers] 280
OpenGL error 0x0506 in -[CCSprite draw] 532
OpenGL error 0x0502 in -[CCGLView swapBuffers] 280
OpenGL error 0x0506 in -[CCSprite draw] 532
OpenGL error 0x0502 in -[CCGLView swapBuffers] 280
OpenGL error 0x0506 in -[CCSprite draw] 532
OpenGL error 0x0502 in -[CCGLView swapBuffers] 280

正如我所说,这是从空白模板创建的.

As I said, this was created from a blank template.

我该如何解决?

推荐答案

OpenGL 错误 0x506 = GL_INVALID_FRAMEBUFFER_OPERATION

OpenGL error 0x506 = GL_INVALID_FRAMEBUFFER_OPERATION

Cocos2D 2.0 和 Cocos2D 1.0 的主要区别在于 OpenGLES 版本.Cocos2D 2.0 使用 OpenGLES 2.0,Cocos2D 1.0 使用 OpenGLES 1.0.

Main difference between Cocos2D 2.0 and Cocos2D 1.0 is OpenGLES version. Cocos2D 2.0 uses OpenGLES 2.0 and Cocos2D 1.0 uses OpenGLES 1.0.

我猜你可能使用了在 OpenGLES 1.0 中找到的 OpenGLES2.0 中没有的 API

I guess you may used API that is not found in OpenGLES2.0 that found in OpenGLES 1.0

示例:GLBegin()、GLLineWidth() 等

Example:GLBegin(), GLLineWidth() etc

使用这个绘图功能:

-(void) draw
{
    [super draw];
    ccGLEnableVertexAttribs( kCCVertexAttribFlag_Position );
    kmGLPushMatrix();
    self.world->DrawDebugData();    
    kmGLPopMatrix();
}

而不是这个:

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

    world->DrawDebugData();

    // restore default GL states
    glEnable(GL_TEXTURE_2D);
    glEnableClientState(GL_COLOR_ARRAY);
    glEnableClientState(GL_TEXTURE_COORD_ARRAY);

}

也可以使用 Cocos2D 2.0 中的 GLES-Render.h 和 GLES-Render.m

Also use GLES-Render.h and GLES-Render.m from Cocos2D 2.0