0
현재 인터페이스 빌더를 사용하는 대신 프로그래밍 방식으로 간단한 코코아 NSWindow를 만들려고합니다 (그렇게해야 할 이유가 있습니다).NSOpenGLView drawRect가 호출되지 않습니다.
int main(int argc, char** argv){
NSWindow *mainwin;
CocoaGLView *mainview;
NSRect scr_frame;
unsigned int style_mask;
NSAutoreleasePool *pool =[[NSAutoreleasePool alloc] init];
[NSApplication sharedApplication];
scr_frame= NSMakeRect(100, 100, 400, 400);
style_mask=NSClosableWindowMask|NSMiniaturizableWindowMask|
NSResizableWindowMask|NSTitledWindowMask;
scr_frame=[NSWindow contentRectForFrameRect:scr_frame
styleMask:style_mask];
mainwin=[[NSWindow alloc]
initWithContentRect:scr_frame
styleMask:style_mask
backing:NSBackingStoreBuffered
defer:NO];
[mainwin makeKeyAndOrderFront:nil];
[mainwin setTitle:@"Visible screen window"];
mainview=[[CocoaGLView alloc] initWithFrame:scr_frame];
[mainwin setContentView:mainview];
[mainview display];
[mainwin setReleasedWhenClosed:YES];
[pool drain];
[NSApp run];
return 0;
}
CocoaGLView는 NSOpenGLView에서 파생되어 다음과 같습니다 :이 빠른 테스트입니다 그것은 일반적으로 작동
@interface CocoaGLView : NSOpenGLView {
//some stuff
}
- (id) initWithFrame: (NSRect) frameRect;
- (void)setFrameSize:(NSSize) aSize;
- (void)drawRect:(NSRect) aRect;
@end
. 창문을 볼 수있어. 심지어 내가 CocoaGLViews drawRect 함수 내에서 그릴 openGL 것들을 볼 수 있지만 그 함수 unfortunatelly 한 번만 호출됩니다, 내가 무엇을 놓친거야?