8

I am transposing a Cocos2D project to 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.

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.

how do I fix that?

Duck
  • 34,902
  • 47
  • 248
  • 470
  • I solved same problem with this answer: http://stackoverflow.com/questions/8990770/failed-to-make-complete-framebuffer-object-8cd6-ios-programmatically-created-o/24657077#24657077 – Yossi Jul 09 '14 at 19:20

1 Answers1

15

OpenGL error 0x506 = GL_INVALID_FRAMEBUFFER_OPERATION

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.

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

Example:GLBegin(), GLLineWidth() etc

Use this draw function:

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

Instead of this:

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

}

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

Guru
  • 21,652
  • 10
  • 63
  • 102
  • 3
    I just cpied and pasted you code and that's it. I wish I could vote you a 1000 – Mikayil Abdullayev Feb 16 '13 at 19:37
  • @Guru - I get these errors too, but I dont call any openGL code directly. What could be causing the issue? I setup cocos2d in my appdelegate and add director.view as a subview to a UIView. The errors log constantly until the view holding the director.view becomes visible. – some_id Jun 12 '13 at 11:02
  • mixing UIKit in Cocos2d 2.0 gives same problem...see this thread http://stackoverflow.com/questions/12168079/multiple-opengl-views-cocos2d – Guru Jun 12 '13 at 11:38