public override Id InitWithFrame(NSRect frameRect) { //uint[] attribsNice = new uint[] { (uint)NSOpenGLPixelFormatAttribute.NSOpenGLPFAAccelerated, (uint)NSOpenGLPixelFormatAttribute.NSOpenGLPFADoubleBuffer, (uint)NSOpenGLPixelFormatAttribute.NSOpenGLPFADepthSize, 24, (uint)NSOpenGLPixelFormatAttribute.NSOpenGLPFAAlphaSize, 8, (uint)NSOpenGLPixelFormatAttribute.NSOpenGLPFAColorSize, 32, (uint)NSOpenGLPixelFormatAttribute.NSOpenGLPFANoRecovery, (uint)CGLPixelFormatAttribute.kCGLPFASampleBuffers, 1, (uint)NSOpenGLPixelFormatAttribute.kCGLPFASamples, 2, 0 }; uint[] attribsJaggy = new uint[] { (uint)NSOpenGLPixelFormatAttribute.NSOpenGLPFAAccelerated, (uint)NSOpenGLPixelFormatAttribute.NSOpenGLPFADoubleBuffer, (uint)NSOpenGLPixelFormatAttribute.NSOpenGLPFADepthSize, 24, (uint)NSOpenGLPixelFormatAttribute.NSOpenGLPFAAlphaSize, 8, (uint)NSOpenGLPixelFormatAttribute.NSOpenGLPFAColorSize, 32, (uint)NSOpenGLPixelFormatAttribute.NSOpenGLPFANoRecovery, 0 }; NSOpenGLPixelFormat fmt = new NSOpenGLPixelFormat (attribsJaggy); this.SendMessage<IntPtr>("initWithFrame:pixelFormat:", frameRect, fmt); fmt.Release (); return this; }
public Id InitWithFrameShareContext(NSRect frameRect, NSOpenGLContext context) { Object[] attribs = new Object[] { NSOpenGLPixelFormatAttribute.NSOpenGLPFAAccelerated, NSOpenGLPixelFormatAttribute.NSOpenGLPFANoRecovery, NSOpenGLPixelFormatAttribute.NSOpenGLPFADoubleBuffer, NSOpenGLPixelFormatAttribute.NSOpenGLPFAColorSize, 24, NSOpenGLPixelFormatAttribute.NSOpenGLPFADepthSize, 16, 0 }; this.pixelFormat = new NSOpenGLPixelFormat (attribs); // NSOpenGLView does not handle context sharing, so we draw to a custom NSView instead this.openGLContext = new NSOpenGLContext (this.pixelFormat, context); this.SendMessageSuper<IntPtr> (MyOpenGLViewClass, "initWithFrame:", frameRect); this.openGLContext.MakeCurrentContext (); // Synchronize buffer swaps with vertical refresh rate this.OpenGLContext.SetValuesForParameter (new[] { 1 }, NSOpenGLContextParameter.NSOpenGLCPSwapInterval); this.SetupDisplayLink (); // Look for changes in view size // Note, -reshape will not be called automatically on size changes because NSView does not export it to override NSNotificationCenter.DefaultCenter.AddObserverSelectorNameObject (this, ObjectiveCRuntime.Selector ("reshape"), NSView.NSViewGlobalFrameDidChangeNotification, this); return this; }