#import
#import
#import
@interface OpenGLView : NSOpenGLView
@end
@implementation OpenGLView
-(id)initWithFrame:(NSRect)frameRect
{
self = [super initWithFrame:frameRect];
return self;
}
-(void)drawRect:(NSRect)dirtyRect
{
glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
glFlush();
}
@end
@interface MyDele : NSObject
@end
@implementation MyDele
-(void) applicationDidFinishLaunching:(NSNotification *)notification
{
NSRect rect = NSMakeRect(35, 35, 1024, 800);
NSWindowStyleMask style = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskResizable;
NSWindow * window = [[NSWindow alloc] initWithContentRect:rect styleMask:style backing:NSBackingStoreBuffered defer:YES];
OpenGLView * view = [[OpenGLView alloc] initWithFrame:rect];
[window setContentView:view];
[NSApp beginModalSessionForWindow:window];
}
-(BOOL) applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)sender
{
return TRUE;
}
@end
int main(int argc, const char ** argv)
{
@autoreleasepool {
MyDele * del = [[MyDele alloc] init];
[[NSApplication sharedApplication] setDelegate: del];
NSApplicationMain(argc, argv);
}
}