static CVReturn OutputCallback(IntPtr displayLink, ref CVTimeStamp inNow, ref CVTimeStamp inOutputTime, CVOptionFlags flagsIn, ref CVOptionFlags flagsOut, IntPtr displayLinkContext) { GCHandle callbackHandle = GCHandle.FromIntPtr(displayLinkContext); DisplayLinkOutputCallback func = (DisplayLinkOutputCallback)callbackHandle.Target; CVDisplayLink delegateDisplayLink = new CVDisplayLink(displayLink, false); return(func(delegateDisplayLink, ref inNow, ref inOutputTime, flagsIn, ref flagsOut)); }
// Private Callback function for CVDisplayLink private CVReturn MyDisplayLinkOutputCallback (CVDisplayLink displayLink, ref CVTimeStamp inNow, ref CVTimeStamp inOutputTime, CVOptionFlags flagsIn, ref CVOptionFlags flagsOut) { //CVReturn result = GetFrameForTime (inOutputTime); CVReturn result = CVReturn.Error; // There is no autorelease pool when this method is called because it will be called from a background thread // It's important to create one or you will leak objects using (NSAutoreleasePool pool = new NSAutoreleasePool ()) { // Update the animation BeginInvokeOnMainThread (RenderScene); result = CVReturn.Success; } return result; }
private CVReturn GetFrameForTime (CVTimeStamp outputTime) { // There is no autorelease pool when this method is called because it will be called from a background thread // It's important to create one or you will leak objects using (NSAutoreleasePool pool = new NSAutoreleasePool ()) { // Update the animation BeginInvokeOnMainThread (DrawView); } return CVReturn.Success; }
public CVReturn MyDisplayLinkOutputCallback (CVDisplayLink displayLink, ref CVTimeStamp inNow, ref CVTimeStamp inOutputTime, CVOptionFlags flagsIn, ref CVOptionFlags flagsOut) { CVReturn result = GetFrameForTime (inOutputTime); return result; }
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 CVReturn GetCurrentTime(out CVTimeStamp outTime) { CVReturn ret = CVDisplayLinkGetCurrentTime(this.Handle, out outTime); return(ret); }
private CVReturn GetFrameForTime (CVTimeStamp outputTime) { // There is no autorelease pool when this method is called because it will be called from a background thread // It's important to create one or you will leak objects using (NSAutoreleasePool pool = new NSAutoreleasePool ()) { // Update the animation double current = DateTime.Now.TimeOfDay.TotalMilliseconds; controller.Scene.advanceTimeBy ((float)(current - controller.RenderTime)); controller.RenderTime = (float)current; BeginInvokeOnMainThread (DrawView); } return CVReturn.Success; }
extern static CVReturn CVDisplayLinkGetCurrentTime(IntPtr displayLink, out CVTimeStamp outTime);
public CVReturn MyDisplayLinkOutputCallback(CVDisplayLink displayLink, ref CVTimeStamp inNow, ref CVTimeStamp inOutputTime, CVOptionFlags flagsIn, ref CVOptionFlags flagsOut) { CVTimeStamp time = inOutputTime; this.InvokeOnMainThread( () => {GetFrameForTime (time);} ); return CVReturn.Success; }
CVReturn DisplayLinkOutputCallback (CVDisplayLink displayLink, ref CVTimeStamp inNow, ref CVTimeStamp inOutputTime, CVOptionFlags flagsIn, ref CVOptionFlags flagsOut) { Game.Instance.BeginInvokeOnMainThread ( () => Game.Instance.EmitTick () ); return CVReturn.Success; }
static CVReturn OutputCallback (IntPtr displayLink, ref CVTimeStamp inNow, ref CVTimeStamp inOutputTime, CVOptionFlags flagsIn, ref CVOptionFlags flagsOut, IntPtr displayLinkContext) { GCHandle callbackHandle = GCHandle.FromIntPtr (displayLinkContext); DisplayLinkOutputCallback func = (DisplayLinkOutputCallback) callbackHandle.Target; CVDisplayLink delegateDisplayLink = new CVDisplayLink(displayLink, false); return func (delegateDisplayLink, ref inNow, ref inOutputTime, flagsIn, ref flagsOut); }
public CVReturn GetCurrentTime (out CVTimeStamp outTime) { CVReturn ret = CVDisplayLinkGetCurrentTime (this.Handle, out outTime); return ret; }
extern static CVReturn CVDisplayLinkGetCurrentTime (IntPtr displayLink, out CVTimeStamp outTime);