Note that there are some explanatory texts on larger screens.

plurals
  1. POlaunching a coco2d OpenGL View from a viewcontroller
    text
    copied!<p>Normally, the coco2d OpenGL view is launched from the appdelegate. </p> <p>Method1: luanching from appdelegate </p> <pre><code>- (void) applicationDidFinishLaunching:(UIApplication*)application { // Init the window window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; // Try to use CADisplayLink director // if it fails (SDK &lt; 3.1) use the default director if( ! [CCDirector setDirectorType:kCCDirectorTypeDisplayLink] ) [CCDirector setDirectorType:kCCDirectorTypeDefault]; CCDirector *director = [CCDirector sharedDirector]; // Init the View Controller viewController = [[RootViewController alloc] initWithNibName:nil bundle:nil]; viewController.wantsFullScreenLayout = YES; // // Create the EAGLView manually // 1. Create a RGB565 format. Alternative: RGBA8 // 2. depth format of 0 bit. Use 16 or 24 bit for 3d effects, like CCPageTurnTransition // // EAGLView *glView = [EAGLView viewWithFrame:[window bounds] pixelFormat:kEAGLColorFormatRGB565 // kEAGLColorFormatRGBA8 depthFormat:0 // GL_DEPTH_COMPONENT16_OES ]; // attach the openglView to the director [director setOpenGLView:glView]; </code></pre> <p>but I need to able to launch the OpenGL view from a viewcontroller so, inside my viewcontroller's viewdidload function I did this</p> <p>method2: launch from viewcontroller - (void)viewDidLoad {</p> <pre><code> [super viewDidLoad]; self.view.frame = CGRectMake(0, 0, 320, 480); // Create an CCGLView with a RGB565 color buffer, and a depth buffer of 0-bits CCGLView *glView = [CCGLView viewWithFrame:CGRectMake(0,0,320,480) pixelFormat:kEAGLColorFormatRGB565 //kEAGLColorFormatRGBA8 depthFormat:0 //GL_DEPTH_COMPONENT24_OES preserveBackbuffer:NO sharegroup:nil multiSampling:NO numberOfSamples:0]; director_ = (CCDirectorIOS*) [CCDirector sharedDirector]; director_.wantsFullScreenLayout = YES; // Display FSP and SPF [director_ setDisplayStats:YES]; // set FPS at 60 [director_ setAnimationInterval:1.0/60]; // attach the openglView to the director [director_ setView:glView]; // for rotation and other messages [director_ setDelegate:self]; // 2D projection [director_ setProjection:kCCDirectorProjection2D]; // Run the intro Scene [CCTexture2D setDefaultAlphaPixelFormat:kCCTexture2DPixelFormat_RGBA8888]; // and add the scene to the stack. The director will run it when it automatically when the view is displayed. [director_ pushScene: [helloworld scene]]; </code></pre> <p>method2 is not working I don't see any scene, nothing shows up. so the question is how to make OpenGL View present from a viewcontroller?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload