9

我正在将 Cocos2D 项目转换为 2.0。

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

我也将其转换为 ARC。

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

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

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

我该如何解决?

4

1 回答 1

15

OpenGL 错误 0x506 = GL_INVALID_FRAMEBUFFER_OPERATION

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

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

示例:GLBegin()、GLLineWidth() 等

使用此绘图功能:

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

于 2012-07-26T06:16:33.903 回答