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 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); }
// Clean up the notifications private void DeAllocate () { Stop (); displayLink = null; NSNotificationCenter.DefaultCenter.RemoveObserver (notificationProxy); }
public CVReturn MyDisplayLinkOutputCallback (CVDisplayLink displayLink, ref CVTimeStamp inNow, ref CVTimeStamp inOutputTime, CVOptionFlags flagsIn, ref CVOptionFlags flagsOut) { CVReturn result = GetFrameForTime (inOutputTime); return result; }
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; }
public void Startup () { DisplayTitle (); displayLink = new CVDisplayLink(); displayLink.SetOutputCallback (DisplayLinkOutputCallback); tickStopWatch = new Stopwatch (); tickStopWatch.Start (); displayLink.Start (); }
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); }