Advertisement
programmerbro

main.m

Dec 23rd, 2011
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #import "MyOpenGLView.h"
  2.  
  3. int main(int argc, const char *argv[])
  4. {
  5.     NSApplicationLoad();
  6.  
  7.     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
  8.     NSLog(@"Pool allocated");
  9.    
  10.     NSRect mainDisplayRect = [[NSScreen mainScreen] frame];
  11.     NSWindow *fullScreenWindow = [[[NSWindow alloc] initWithContentRect: mainDisplayRect styleMask: NSBorderlessWindowMask backing: NSBackingStoreBuffered defer: YES] autorelease];
  12.     NSLog(@"window allocated");
  13.    
  14.     [fullScreenWindow setLevel: NSMainMenuWindowLevel+1];
  15.     NSLog(@"Level set");
  16.    
  17.     [fullScreenWindow setOpaque: YES];
  18.     [fullScreenWindow setHidesOnDeactivate: YES];
  19.    
  20.     NSOpenGLPixelFormatAttribute attrs[] =
  21.     {
  22.         NSOpenGLPFADoubleBuffer,
  23.         NSOpenGLPFAFullScreen,
  24.         0
  25.     };
  26.     NSLog(@"Attributes set");
  27.    
  28.     NSOpenGLPixelFormat* pixelFormat = [[[NSOpenGLPixelFormat alloc] initWithAttributes: attrs] autorelease];
  29.     NSRect viewRect = NSMakeRect(0.0, 0.0, mainDisplayRect.size.width, mainDisplayRect.size.height);
  30.     MyOpenGLView *fullScreenView = [[[MyOpenGLView alloc] initWithFrame: viewRect pixelFormat: pixelFormat] autorelease];
  31.     [fullScreenWindow setContentView: fullScreenView];
  32.    
  33.     [fullScreenWindow makeKeyAndOrderFront: fullScreenWindow];
  34.    
  35.     [pool drain];
  36.     NSLog(@"Pool drained");
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement