Switching to another EAGLView help.

Posts: 75
Joined: 2009.01
Post: #1
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):
#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];


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:
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
Posts: 75
Joined: 2009.01
Post: #2
Problem solved.
Quote this message in a reply
Posts: 3,591
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 3,944 May 10, 2010 12:20 PM
Last Post: maximile
  How to access EAGLView/UIView functions from C? Rasterman 10 9,855 Apr 8, 2010 10:47 AM
Last Post: Rasterman
  View is not switching jeonghyunhan 9 7,036 Mar 10, 2009 03:13 PM
Last Post: maximile
  Interface Builder and switching UIViews bruss14 3 6,494 Jun 20, 2008 12:52 PM
Last Post: AnotherJake