Switching to another EAGLView help.

Member
Posts: 75
Joined: 2009.01
Post: #1
Hi!
I'm running into a few problems trying to switch from one EAGLView to another.

This is what RootView.m looks like (RootView is a subclass of UIView which I use to switch between views):
Code:
#import "RootView.h"
#import "EAGLView.h"
#import "BattleScene.h"
#import "RandomView.h"

@implementation RootView

@synthesize glView, battleScene, randomView;

- (id)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        // Initialization code
        gameFrame = self.bounds;
        glView = [[EAGLView alloc] initWithFrame:gameFrame];
        [self addSubview:glView];
        //battleScene = [[BattleScene alloc] initWithFrame:gameFrame];
        //[self addSubview:battleScene];
        glView.rootView = self;
    }
    return self;
}


- (void)goToBattleScene {
    battleScene.rootView = self;
    [glView removeFromSuperview];
    battleScene = [[BattleScene alloc] initWithFrame:gameFrame];
    [self addSubview:battleScene];
    //randomView = [[RandomView alloc] initWithFrame:gameFrame];
    //[self addSubview:randomView];
}


- (void)dealloc {
    [glView release];
    [battleScene release];
    [randomView release];
    [super dealloc];
}


@end

The battleScene is the other OpenGLES View and the randomView is just a normal UIView with a white background.
I cannot get this to work.
I call goToBattleScene in glView and when randomView is uncommented it works but when battleScene is uncommented i get a blank grey screen with some error that keeps repeating.
I'm thinking it has something to do with the line:
Code:
glView.rootView = self;

This is all in code with no IB and no UIViewControllers.

Any help and advice on best practices would be appreciated, thanks.
Quote this message in a reply
Member
Posts: 75
Joined: 2009.01
Post: #2
Problem solved.
Quote this message in a reply
Moderator
Posts: 3,579
Joined: 2003.06
Post: #3
jeonghyunhan Wrote:Problem solved.

So what was the fix?
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Switching between UIViewContollers mberger 2 2,813 May 10, 2010 12:20 PM
Last Post: maximile
  How to access EAGLView/UIView functions from C? Rasterman 10 6,156 Apr 8, 2010 10:47 AM
Last Post: Rasterman
  View is not switching jeonghyunhan 9 4,364 Mar 10, 2009 03:13 PM
Last Post: maximile