NSOpenGLView resize on window resize
Posted
by ADAM
on Stack Overflow
See other posts from Stack Overflow
or by ADAM
Published on 2010-03-13T21:25:39Z
Indexed on
2010/03/13
21:35 UTC
Read the original article
Hit count: 362
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
© Stack Overflow or respective owner