OpenGL error 0x0506 in -[CCSprite draw] 530 to run project on ios divice in cocos2d?

| | August 5, 2015

I am running my cocos2d program on simulator. It works fine but when I run it on device, it throws error OpenGL error 0x0506 in -[CCSprite draw] 530. In my program I want to push one scene to another scene.At that time it shows error. Sometime it works fine on device at first time, but sometimes it shows error.Please help me about it. I also tried to google it

My Code As below:

First Load LoadingLayer as below.

-(void) directorDidReshapeProjection:(CCDirector*)director

        if ([[director runningScene] isRunning])

            [[CCDirector sharedDirector] resume]; //pause the director

            [[CCDirector sharedDirector] pushScene:[HelloWorldLayer scene]];
            [[CCDirector sharedDirector] runWithScene:[LoadingLayer scene]];


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

    // Create the main window
    window_ = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

    [self.window setBackgroundColor:[UIColor whiteColor]];

    glView = [CCGLView viewWithFrame:[window_ bounds]

    director_ = (CCDirectorIOS*) [CCDirector sharedDirector];

    director_.wantsFullScreenLayout = YES;

    // Display FSP and SPF
    [director_ setDisplayStats:NO];

    // set FPS at 60
    [director_ setAnimationInterval:1.0/60];

    // attach the openglView to the director
    [director_ setView:glView];

    // 2D projection
    [director_ setProjection:kCCDirectorProjection2D];

    //  [director setProjection:kCCDirectorProjection3D];

    // Enables High Res mode (Retina Display) on iPhone 4 and maintains low res on all other devices
    if( ! [director_ enableRetinaDisplay:YES] )
        CCLOG(@"Retina Display Not supported");

    // Default texture format for PNG/BMP/TIFF/JPEG/GIF images
    // It can be RGBA8888, RGBA4444, RGB5_A1, RGB565
    // You can change this setting at any time.
    [CCTexture2D setDefaultAlphaPixelFormat:kCCTexture2DPixelFormat_RGBA8888];

        CCFileUtils *sharedFileUtils = [CCFileUtils sharedFileUtils];
    [sharedFileUtils setEnableFallbackSuffixes:NO];             // Default: NO. No fallback suffixes are going to be used
    [sharedFileUtils setiPhoneRetinaDisplaySuffix:@"-hd"];      // Default on iPhone RetinaDisplay is "-hd"
    [sharedFileUtils setiPadSuffix:@"-ipad"];                   // Default on iPad is "ipad"
    [sharedFileUtils setiPadRetinaDisplaySuffix:@"-ipadhd"];    // Default on iPad RetinaDisplay is "-ipadhd"

    // Assume that PVR images have premultiplied alpha
    [CCTexture2D PVRImagesHavePremultipliedAlpha:YES];

    // Create a Navigation Controller with the Director
    navController_ = [[MyNavigationController alloc]    initWithRootViewController:director_];
    navController_.navigationBarHidden = YES;

    // for rotation and other messages
    [director_ setDelegate:navController_];

    // set the Navigation Controller as the root view controller
    [window_ setRootViewController:navController_];

    // make main window visible
    [window_ makeKeyAndVisible];

    return YES;

After LoadingLayer It Push To has buuton click on it go to HelloWorldLayer.

        director_ = (CCDirectorIOS*) [CCDirector sharedDirector];
        [director_ replaceScene:[HelloWorldLayer scene]];
        [self.navigationController pushViewController:director_ animated:YES];

Low as Scene to Viewcontroller to scene.

app is not crash but it got error

enter image description here

Leave a Reply