I'm using GLKit's GLKViewController/GLKView to do some basic OpenGL drawing.
I'd like to setup the ViewPort in the ViewDidLoad method. After reading the GLKView reference, I thought I'd be able to do it like this:
- (void)viewDidLoad
{
[super viewDidLoad];
self.context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
if (!self.context) {
NSLog(@"Failed to create ES context");
}
GLKView *view = (GLKView *)self.view;
view.context = self.context;
glViewport( 0, 0, view.DrawableWidth, view.DrawableHeight );
}
The problem is that both DrawableWidth
and DrawableHeight
properties are zero. Why is that? When the GLKView calls DrawInRect, they're set and their values are what I would expect.