In IB I placed an NSOpenGLView instance into the window.
I have all of my drawing code inside a custom NSViewController like so:
// MyOpenGLViewController.h
@interface MyOpenGLViewController : NSViewController
{
IBOutlet NSOpenGLView *glView;
}
// MyOpenGLViewController.m
-(void)awakeFromNib
{
[self drawFrame];
}
-(void)drawFrame
{
[[glView openGLContext] makeCurrentContext];
glClearColor(0, 0, 0, 1);
}
Everything is linked up and "drawFrame" gets called but I don't get anything on the screen. It's always white. What should I be checking for?
Typically one subclasses NSOpenGLView and installs a timer to update your data model and if anything changes then draw the changes. The controller shouldn't be doing the drawing. Apple has some good documentation on getting something working. Start with the OpenGl Programming Guide for Mac OS X.
I seem to remember a bug with using the NSOpenGLView object in Interface Builder. What I always do is add a generic NSObject where you want the view and set its class to be your NSOpenGLView subclass.