I have defined a GLKViewController in a storyboard with an identifier. I add it to another view controller in code with
sceneController = (SceneController*)[[self storyboard] instantiateViewControllerWithIdentifier:@"openglcontroller"];
sceneController.view.frame = CGRectMake(0, 120, 320, 360);
[self addChildViewController:sceneController];
I have defined in the viewDidLoad of the GLKViewController
context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
GLKView *v = (GLKView *)self.view;
v.delegate = self;
v.context = context;
[EAGLContext setCurrentContext:context];
I verified that this viewDidLoad was called and everything exists as it should. However - (void)glkView:(GLKView *)view drawInRect:(CGRect)rect is not being called, nor -(void)update
The GLKViewController is not paused and its fps is set to 30. Why would it not call the delegate methods? I have done this in a previous app as the root view controller which of course worked. Child view controllers are a new feature in iOS 5 and nothing documented says this should not work. What am I missing?
Answer:
What was missing (in case anyone else has this problem).
[self addChildViewController:sceneController];
[[self view] addSubview:[sceneController view]]; <<<<<<<<<<<<<<<<
[sceneController didMoveToParentViewController:self];
Since the GLKViewController has a view embedded in it, you need to add it as a subview or it won't appear anywhere. D'oh!