SCOpenGLView

Inherits From:
NSView : NSResponder : NSObject

Conforms To:
NSCoding

Declared In:
Sc21/SCOpenGLView.h

Class Description

SCOpenGLView is a replacement for NSOpenGLView.

The main purpose of this class is to be able to use an SCOpenGLPixelFormat in order to be able to archive/unarchive this class. In all other respects, SCOpenGLView behaves like NSOpenGLView.


Method Types

Initializing an SCOpenGLView
- initWithFrame:
- initWithFrame:pixelFormat:
- prepareOpenGL
Accessing the pixelformat
+ defaultPixelFormat
- setPixelFormat:
- pixelFormat
Handling the OpenGL context
- clearGLContext
- openGLContext
- setOpenGLContext:
Drawing and updating
- reshape
- update


Class Methods

defaultPixelFormat

+ (SCOpenGLPixelFormat *)defaultPixelFormat

Returns a default SCOpenGLPixelFormat.


Instance Methods

clearGLContext

- (void)clearGLContext

Releases the NSOpenGLContext associated with the receiver. If necessary, this method calls clearDrawable on the context before releasing it.


initWithFrame:

- (id)initWithFrame:(NSRect)frameRect

Equivalent to -initWithFrame:frameRect pixelFormat:nil.


initWithFrame:pixelFormat:

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

Designated initializer.

Initializes a newly allocated NSOpenGLView with frameRect as its frame rectangle and format as its pixelformat.

Passing nil as pixelFormat will result in the pixelformat being set to the result of +defaultPixelFormat when the OpenGL context is initialized.


openGLContext

- (NSOpenGLContext *)openGLContext

Returns the NSOpenGLContext associated with the receiver. If the receiver has no associated context, a new NSOpenGLContext is created and returned. This new context is initialized with the pixelformat returned by sending pixelFormat to the receiver, or (if this returns nil) a new pixelformat created by +defaultPixelFormat.


pixelFormat

- (SCOpenGLPixelFormat *)pixelFormat

Returns the pixel format associated with the receiver.


prepareOpenGL

- (void)prepareOpenGL

Used by subclassers to initialize OpenGL state. This function is called once after an OpenGL context is created and the drawable is attached.

On Panther, NSOpenGLContext will automatically send this message to its view from its -makeCurrentContext method. On Jaguar, this function is called explicitly from our -openGLContext method, emulating Panther's behavior.


reshape

- (void)reshape

Called if the visible rectangle or bounds of the receiver change (for scrolling or resize). The default implementation does nothing. Override this method if you need to adjust the viewport and display frustum.


setOpenGLContext:

- (void)setOpenGLContext:(NSOpenGLContext *)context

Sets the NSOpenGLContext used by the receiver to allow sharing the same context on a per view basis. Replaces the existing context if one was already created. You must send setView: to the context to sync the context with the view.


setPixelFormat:

- (void)setPixelFormat:(SCOpenGLPixelFormat *)pixelFormat

Sets the receiver's pixel format to pixelFormat


update

- (void)update

Called if the view's context needs to be updated because the window moves, or if the view moves or is resized. This method simply calls NSOpenGLContext's update. Override this method if you need to add locks for multithreaded access to multiple contexts.


Sc21 version 1.0 © 2003-2004 Systems in Motion AS.