Using NSOpenGLView in Cocoa Programming in Mac

By: Aaron Hillegass Viewed: 153216 times  Printer Friendly Format    


NSOpenGLView is an NSView subclass that has an OpenGL drawing context. Just as you needed the focus locked on a view to do drawing with Quartz, so the OpenGL drawing context must be active for any OpenGL drawing commands to have an effect.

Here are some important methods in NSOpenGLView:

- (id)initWithFrame:(NSRect)frameRect
         pixelFormat:(NSOpenGLPixelFormat *)format

The designated initializer.

- (NSOpenGLContext*)openGLContext

Returns the view's OpenGL context.

- (void)reshape

Called when the view is resized. The OpenGL context is active when this method is called.

- (void)drawRect:(NSRect)r

Called when the view needs to be redrawn. The OpenGL context is active when this method is called.



Most Viewed Articles (in Cocoa )

Latest Articles (in Cocoa)

Comment on this tutorial