| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/AppKit.framework |
| Availability | Available in Mac OS X v10.0 and later. |
| Companion guide | |
| Declared in | NSOpenGLView.h |
| Related sample code |
An NSOpenGLView object maintains an NSOpenGLPixelFormat and NSOpenGLContext object into which OpenGL calls can be rendered. The view provides methods for accessing and managing the NSOpenGLPixelFormat and NSOpenGLContext objects, as well as notifications of visible region changes.
An NSOpenGLView object cannot have subviews. You can, however, divide a single NSOpenGLView into multiple rendering areas using the glViewport function.
When creating an NSOpenGLView object in Interface Builder, you use the inspector window to specify the pixel format attributes you want for the view. Only those attributes listed in the Interface Builder inspector are set when the view is instantiated.
Note: In versions of the Xcode Tools that shipped prior to Mac OS X v10.4, the Interface Builder inspector does not list any pixel format attributes for NSOpenGLView.
Returns a default NSOpenGLPixelFormat object.
+ (NSOpenGLPixelFormat *)defaultPixelFormat
A pixel format object with no attributes set.
Typically used with the initializer initWithFrame:pixelFormat:, this object has no attributes set.
NSOpenGLView.hReleases the NSOpenGLContext object associated with the view.
- (void)clearGLContext
If necessary, this method calls the clearDrawable method of the context object before releasing it.
NSOpenGLView.hReturns an NSOpenGLView object initialized with the specified frame rectangle and pixel format.
- (id)initWithFrame:(NSRect)frameRect pixelFormat:(NSOpenGLPixelFormat *)format
The frame rectangle for the view, specified in the coordinate system of its parent view.
The pixel format to use when creating the view's NSOpenGLContext object.
An initialized NSOpenGLView object, or nil if the object could not be initialized.
NSOpenGLView.hReturns the NSOpenGLContext object associated with the receiver.
- (NSOpenGLContext *)openGLContext
The OpenGL context object of the receiver.
If the receiver has no associated context object, a new NSOpenGLContext object is created and returned. The new object is initialized with the receiver’s pixel format information.
NSOpenGLView.hReturns the NSOpenGLPixelFormat object associated with the receiver.
- (NSOpenGLPixelFormat *)pixelFormat
The receiver's pixel format object.
NSOpenGLView.hUsed by subclasses to initialize OpenGL state.
- (void)prepareOpenGL
This method is called only once after the OpenGL context is made the current context. Subclasses that implement this method can use it to configure the Open GL state in preparation for drawing.
NSOpenGLView.hCalled by Cocoa when the view's visible rectangle or bounds change.
- (void)reshape
Cocoa typically calls this method during scrolling and resize operations but may call it in other situations when the view's rectangles change. The default implementation does nothing. You can override this method if you need to adjust the viewport and display frustum.
NSOpenGLView.hSets the NSOpenGLContext object associated with the receiver.
- (void)setOpenGLContext:(NSOpenGLContext *)context
The OpenGL context object to associate with the receiver.
This method releases the current OpenGL context, if one already exists. You must also call the setView: method of the context object to synchronize the context with the view.
NSOpenGLView.hSets the receiver’s NSOpenGLPixelFormat object to the specified object.
- (void)setPixelFormat:(NSOpenGLPixelFormat *)pixelFormat
The new pixel format object for the receiver.
NSOpenGLView.hCalled by Cocoa when the view’s window moves or when the view itself moves or is resized.
- (void)update
The default implementation simply calls the update method of NSOpenGLContext. You can override this method to perform additional update operations on the context or if you need to add locks for multithreaded access to multiple contexts.
NSOpenGLView.h
Last updated: 2007-01-26