The EAGLView initWithCoder?

View previous topic View next topic Go down

The EAGLView initWithCoder?

Post  jj on Sun Nov 09, 2008 5:19 pm

Your template utilizes the EAGLView being stored in the xib file, and called into play with initWithCoder.

Could you elaborate on how the view is initally constructed?

I would like to programmatically (later in the game menus) create and add the EAGLView once the game options have been set.

How would I change the current loading for this to work?

Thx in advance

jj

Posts : 77
Join date : 2008-09-24

View user profile

Back to top Go down

Re: The EAGLView initWithCoder?

Post  sio2interactive on Sun Nov 09, 2008 7:07 pm

Sorry dude, but I have absolutely no idea... I just use the develop OpenGL ES template app, and gather the misc. code around to init what I have to... I really not familiar with cocoa, my field of expertise is basically on GL Wink

Can someone else help JJ please!!!

Tks in advance,

Cheers,
avatar
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 38
Location : Shanghai

View user profile http://sio2interactive.com

Back to top Go down

Re: The EAGLView initWithCoder?

Post  zzajin on Sun Nov 09, 2008 8:17 pm

I did this awhile ago with a port of Irrlicht Engine. I think the following covers it, but in case I miss something it's because I'm not looking at a simple case and also trying to convert to sio2 code.

1. you need to remove "Main nib file base name" in Info.plist

2. A line in main.mm needs to change
Code:
int retVal = UIApplicationMain(argc, argv, nil, @"templateAppDelegate");

3. Instead of EAGLView's initWithCoder: method - change it to initWithFrame: since you are doing it programmatically. Beginning will look like this instead.

Code:


//The GL view is stored in the nib file. When it's unarchived it's sent -initWithCoder:
//- (id)initWithCoder:(NSCoder*)coder {
//programmatically we will call this instead

- (id)initWithFrame:(CGRect)frame
{   
   if ((self = [super initWithFrame: frame])) {


//hopefully the rest is evident

4. You will create this view in templateAppDelegate in applicationDidFinishLaunching:


Code:

- (void)applicationDidFinishLaunching:(UIApplication *)application {
   
   CGRect               rect = [[UIScreen mainScreen] applicationFrame];
   CGFloat               components[3];
   
   //Create a full-screen window
   window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
   [window setBackgroundColor:[UIColor blackColor]];
   
   //Create the OpenGL drawing view and add it to the window
   glView = [[UntitledView alloc] initWithFrame:CGRectMake(rect.origin.x, rect.origin.y, rect.size.width, rect.size.height)]; // - kPaletteHeight
   [window addSubview:glView];
   
   //Show the window
   [window makeKeyAndVisible];   
   // Look in the Info.plist file and you'll see the status bar is hidden
   // Set the style to black so it matches the background of the application
   //[application setStatusBarStyle:UIStatusBarStyleBlackTranslucent animated:NO];
   // Now show the status bar, but animate to the style.
   //[application setStatusBarHidden:NO animated:YES];
      
        //The rest is what I currently have in sio2's applicationDidFinishLaunching:
   [[UIApplication sharedApplication] setStatusBarOrientation: UIInterfaceOrientationLandscapeRight animated: NO];
   
   //Keep the app awake
   [ [UIApplication sharedApplication] setIdleTimerDisabled:YES ];
   
   glView.animationInterval = 1.0 / 60.0;
   [glView startAnimation];
   

    [[UIAccelerometer sharedAccelerometer] setUpdateInterval:( 1.0f / 30.0f )];
    [[UIAccelerometer sharedAccelerometer] setDelegate:self];   
}



And you may need to remove MainWindow.xib from the Xcode project.

zzajin

Posts : 81
Join date : 2008-10-14

View user profile

Back to top Go down

Re: The EAGLView initWithCoder?

Post  zzajin on Sun Nov 09, 2008 8:27 pm

Actually jj, I think something like 3 and 4 pertain to your case. The above is for starting an app in an OpenGL ES view.

zzajin

Posts : 81
Join date : 2008-10-14

View user profile

Back to top Go down

Re: The EAGLView initWithCoder?

Post  Sponsored content


Sponsored content


Back to top Go down

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum