private void SetupDisplayLink() { if (displayLink != null) { return; } // Create a display link capable of being used with all active displays displayLink = new CVDisplayLink(); // Set the renderer output callback function displayLink.SetOutputCallback(MyDisplayLinkOutputCallback); // Set the display link for the current renderer CGLContext cglContext = openGLContext.CGLContext; CGLPixelFormat cglPixelFormat = PixelFormat.CGLPixelFormat; displayLink.SetCurrentDisplay(cglContext, cglPixelFormat); }
public override void DrawInCGLContext (MonoMac.OpenGL.CGLContext glContext, CGLPixelFormat pixelFormat, double timeInterval, ref CVTimeStamp timeStamp) { GL.ClearColor (NSColor.Clear.UsingColorSpace (NSColorSpace.CalibratedRGB)); GL.Clear (ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); GL.Enable (EnableCap.DepthTest); GL.Hint (HintTarget.LineSmoothHint, HintMode.Nicest); GL.Hint (HintTarget.PolygonSmoothHint, HintMode.Nicest); if (previousTime == 0) previousTime = timeInterval; rotation += 15.0 * (timeInterval - previousTime); GL.LoadIdentity (); double comp = 1 / Math.Sqrt (3.0); GL.Rotate (rotation, comp, comp, comp); drawCube (); GL.Flush (); previousTime = timeInterval; GL.Disable (EnableCap.DepthTest); GL.Hint (HintTarget.LineSmoothHint, HintMode.DontCare); GL.Hint (HintTarget.PolygonSmoothHint, HintMode.DontCare); }
public override bool CanDrawInCGLContext (CGLContext glContext, CGLPixelFormat pixelFormat, double timeInterval, ref CVTimeStamp timeStamp) { if (!animate) previousTime = 0.0; return animate; }
public override CGLPixelFormat CopyCGLPixelFormatForDisplayMask (uint mask) { // make sure to add a null value var attribs = new object [] { CGLPixelFormatAttribute.Accelerated, CGLPixelFormatAttribute.DoubleBuffer, CGLPixelFormatAttribute.ColorSize, 24, CGLPixelFormatAttribute.DepthSize, 16 }; CGLPixelFormat pixelFormat = new CGLPixelFormat (attribs); return pixelFormat; }
public CVReturn SetCurrentDisplay (CGLContext cglContext, CGLPixelFormat cglPixelFormat) { return CVDisplayLinkSetCurrentCGDisplayFromOpenGLContext (this.handle, cglContext.Handle, cglPixelFormat.Handle); }
public override CGLPixelFormat CopyCGLPixelFormatForDisplayMask (uint mask) { // make sure to add a null value CGLPixelFormatAttribute[] attribs = new CGLPixelFormatAttribute[] { CGLPixelFormatAttribute.Accelerated, CGLPixelFormatAttribute.DoubleBuffer, CGLPixelFormatAttribute.ColorSize, (CGLPixelFormatAttribute)24, CGLPixelFormatAttribute.DepthSize, (CGLPixelFormatAttribute)16 }; int numPixs = -1; CGLPixelFormat pixelFormat = new CGLPixelFormat (attribs, out numPixs); return pixelFormat; }