NSOpenGLView resize on window resize
- by ADAM
I have a class called ModelView which inherits from NSOpenGLView.
When my program runs i attach the ModelView as follows to the main window.
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
// Insert code here to initialize your application
ModelView *glView;
NSRect glViewRect = CGRectMake(0.0f, 0.0f, window.frame.size.width, window.frame.size.height);
glView = [[ModelView alloc] initWithFrame: glViewRect];
[[window contentView] addSubview:glView];
}
In my ModelView class i have a reshape function which is firing every time the window resizes
- (void)reshape
{
[super setNeedsDisplay:YES];
[[self openGLContext] update];
NSLog(@"reshap function called");
}
I want to get the main window width so i can resize the ModelView but i cant find how to get the window width from the ModelView class
I am reasonably new to cocoa/objective-c
Any help appreciated