Mac OS X Porting - OpenGL transitions/NSOpenGLView

From Apache OpenOffice Wiki
Jump to: navigation, search

What is important with NSOpenGLView :

Warning: this is objective C  :-)

Instance method ( i.e. static ): defaultPixelFormat

other important information:

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

=> the initWithFrame has two parameters, and thus cannot be confused with the initWithFrame from NSView

=> there is no draw:(NSRect)aFrameRect , just use the one inherited from NSView

To add an OpenGLView inside an NSView, simply (after created and correctly initialized both) do:

[myNSView addSubview:pOpenGLView]

More from NSOpenGLView.h ( from AppKit framework ):

@interface NSOpenGLView : NSView {
  @private
    NSOpenGLContext*     _openGLContext;
    NSOpenGLPixelFormat* _pixelFormat;
    unsigned long        _reserved1;
    unsigned long        _reserved2;
    unsigned long        _reserved3;
}

+ (NSOpenGLPixelFormat*)defaultPixelFormat;

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

- (void)setOpenGLContext:(NSOpenGLContext*)context;
- (NSOpenGLContext*)openGLContext;
- (void)clearGLContext;

- (void)update;		// moved or resized
- (void)reshape;	// scrolled, moved or resized

- (void)setPixelFormat:(NSOpenGLPixelFormat*)pixelFormat;
- (NSOpenGLPixelFormat*)pixelFormat;

#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3
- (void)prepareOpenGL;
#endif
@end
Personal tools