The EAGLView initWithCoder?
3 posters
The EAGLView initWithCoder?
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
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
Re: The EAGLView initWithCoder?
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
Can someone else help JJ please!!!
Tks in advance,
Cheers,
Can someone else help JJ please!!!
Tks in advance,
Cheers,
Re: The EAGLView initWithCoder?
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
3. Instead of EAGLView's initWithCoder: method - change it to initWithFrame: since you are doing it programmatically. Beginning will look like this instead.
4. You will create this view in templateAppDelegate in applicationDidFinishLaunching:
And you may need to remove MainWindow.xib from the Xcode project.
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
Re: The EAGLView initWithCoder?
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
Permissions in this forum:
You cannot reply to topics in this forum