codemattic
2002.08.11, 02:10 PM
I have a subclass of an NSOpenGLView - which I placed in a window in IB. Now there is some member variables I need to initialize when the view is created. Ive tried alternately the methods listed below. None seems to get called. My workaround is to have a method called -setup, and every other method (-drawRect, -reshape, etc) first checks if the view has been initialized, and if not calls setup first before doing anything. It works - but its inelegant - and Id like to know why I cant initialize properly. help.
thanks,
Codemattic
@interface MyOpenGLView : NSOpenGLView {
// some member variables go here
}
- (id)init;
- (id)initWithFrame:(NSRect)frame;
- (id)initWithFrame:(NSRect)frame pixelFormat:(NSOpenGLPixelFormat*)format;
@end
@implementation MyOpenGLView
- (id)init {
NSLog(@"init");
self = [super init];
if (self) {
// Initialization code here.
}
return self;
}
- (id)initWithFrame:(NSRect)frame {
NSLog(@"initWithFrame:");
self = [super initWithFrame:frame];
if (self) {
// Initialization code here.
}
return self;
}
- (id)initWithFrame:(NSRect)frame pixelFormat:(NSOpenGLPixelFormat*)format {
NSLog(@"initWithFrame:pixelformat:");
self = [super initWithFrame:frame pixelFormat:format];
if (self) {
// Initialization code here.
}
return self;
}
@end
thanks,
Codemattic
@interface MyOpenGLView : NSOpenGLView {
// some member variables go here
}
- (id)init;
- (id)initWithFrame:(NSRect)frame;
- (id)initWithFrame:(NSRect)frame pixelFormat:(NSOpenGLPixelFormat*)format;
@end
@implementation MyOpenGLView
- (id)init {
NSLog(@"init");
self = [super init];
if (self) {
// Initialization code here.
}
return self;
}
- (id)initWithFrame:(NSRect)frame {
NSLog(@"initWithFrame:");
self = [super initWithFrame:frame];
if (self) {
// Initialization code here.
}
return self;
}
- (id)initWithFrame:(NSRect)frame pixelFormat:(NSOpenGLPixelFormat*)format {
NSLog(@"initWithFrame:pixelformat:");
self = [super initWithFrame:frame pixelFormat:format];
if (self) {
// Initialization code here.
}
return self;
}
@end