HelloArrow App closes immediately upon launch

Discussion in 'iOS Programming' started by TalkBinary, Jun 29, 2010.

  1. TalkBinary macrumors newbie

    Joined:
    Jun 20, 2010
    #1
    I'm using this to learn how to program in OpenGL ES iPhone 3D Programming and tried doing their HelloArrow application.

    Unfortunately, this is the second time I've tried it and all that happens is the application launches on the iPhone Simulator, displays the splash image (Default.png) and closes immediately. The book mentions I should see a solid gray screen and I don't. I've followed the tutorial to the best of my ability. If anyone could help me determine why this application closes immediately, please let me know.

    I'm using the most recent version of the iPhone SDK and Xcode.

    I followed this tutorial up to the Setting Up the Icons and the Launch Image.

    I found the following error message.

    Code:
    2010-06-29 16:06:27.484 HelloArrow[1086:207] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </Users/kuriyaki/Library/Application Support/iPhone Simulator/4.0/Applications/65DD7F0F-B51C-4AF1-B5D3-80B9BFCC10E0/HelloArrow.app> (loaded)' with name 'MainWindow''
    main.m
    Code:
    #import <UIKit/UIKit.h>
    
    int main(int argc, char *argv[]) {
        
        NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
        int retVal = UIApplicationMain(argc, argv, nil, @"HelloArrowAppDelegate");
        [pool release];
        return retVal;
    }
    
    HelloArrowAppDelegate.h
    Code:
    #import <UIKit/UIKit.h>
    #import "GLView.h"
    
    @interface HelloArrowAppDelegate : NSObject <UIApplicationDelegate> {
        UIWindow* m_window;
        GLView* m_view;
    }
    
    @end
    HelloArrowAppDelegate.mm
    Code:
    #import "HelloArrowAppDelegate.h"
    #import <UIKit/UIKit.h>
    #import "GLVåçiew.h"
    
    @implementation HelloArrowAppDelegate
    
    - (BOOL) application: (UIApplication*) application
    didFinishLaunchingWithOptions: (NSDictionary*) launchOptions    
    {
        CGRect screenBounds = [[UIScreen mainScreen] bounds];
    	
        m_window = [[UIWindow alloc] initWithFrame: screenBounds];
        m_view = [[GLView alloc] initWithFrame: screenBounds];
    	
        [m_window addSubview: m_view];
        [m_window makeKeyAndVisible];
        return YES;
    }
    
    - (void) dealloc
    {
        [m_view release];
        [m_window release];
        [super dealloc];
    }
    
    @end
    GLView.h
    Code:
    #import <UIKit/UIKit.h>
    #import <OpenGLES/EAGL.h>
    #import <QuartzCore/QuartzCore.h>
    #import <OpenGLES/ES1/gl.h>
    #import <OpenGLES/ES1/glext.h>
    
    @interface GLView : UIView {
    	EAGLContext* m_context;
    }
    
    - (void) drawView;
    
    @end
    
    GLView.mm
    Code:
    #import "GLView.h"
    
    
    @implementation GLView
    
    + (Class) layerClass
    {
    	return [CAEAGLLayer class];
    }
    
    - (id) initWithFrame: (CGRect) frame
    {
        if (self = [super initWithFrame:frame]) {
            CAEAGLLayer* eaglLayer = (CAEAGLLayer*) super.layer; 
            eaglLayer.opaque = YES; 
    		
            m_context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1]; 
    		
            if (!m_context || ![EAGLContext setCurrentContext:m_context]) { 
                [self release];
                return nil;
            }
    		
            GLuint framebuffer, renderbuffer;
    		glGenFramebuffersOES(1, &framebuffer);
    		glGenRenderbuffersOES(1, &renderbuffer);
    		
    		glBindFramebufferOES(GL_FRAMEBUFFER_OES, framebuffer);
    		glBindRenderbufferOES(GL_RENDERBUFFER_OES, renderbuffer);
    		
    		[m_context
    		 renderbufferStorage:GL_RENDERBUFFER_OES
    		 fromDrawable: eaglLayer];
    		
    		glFramebufferRenderbufferOES(
    									 GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES,
    									 GL_RENDERBUFFER_OES, renderbuffer);
    		
    		glViewport(0, 0, CGRectGetWidth(frame), CGRectGetHeight(frame));
    		
    		[self drawView];
        }
        return self;
    }
    
    
    - (void) drawView
    {
    	glClearColor(0.5f, 0.5f, 0.5f, 1);
    	glClear(GL_COLOR_BUFFER_BIT);
    
    	[m_context presentRenderbuffer:GL_RENDERBUFFER_OES];
    }
    	
    - (void)dealloc {
    	if ([EAGLContext currentContext] == m_context) 
    		[EAGLContext setCurrentContext:nil];
    	
    	[m_context release];
    	[super dealloc];
    }
    
    
    @end
    
     
  2. TalkBinary thread starter macrumors newbie

    Joined:
    Jun 20, 2010
    #2
    Solved

    Ok I figured this out. I had to remove the nib reference in the pch file.
     

Share This Page