Exemplo n.º 1
0
        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));
        }
Exemplo n.º 2
0
		// 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;
		}
Exemplo n.º 3
0
		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;

		}
Exemplo n.º 4
0
		public CVReturn MyDisplayLinkOutputCallback (CVDisplayLink displayLink, ref CVTimeStamp inNow, ref CVTimeStamp inOutputTime, CVOptionFlags flagsIn, ref CVOptionFlags flagsOut)
		{
			CVReturn result = GetFrameForTime (inOutputTime);

			return result;
		}
Exemplo n.º 5
0
 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);
         
         
 }
Exemplo n.º 6
0
				public override bool CanDrawInCGLContext (CGLContext glContext, CGLPixelFormat pixelFormat, double timeInterval, ref CVTimeStamp timeStamp)
                {
                        if (!animate)
                                previousTime = 0.0;
                        return animate;
                }
Exemplo n.º 7
0
        public CVReturn GetCurrentTime(out CVTimeStamp outTime)
        {
            CVReturn ret = CVDisplayLinkGetCurrentTime(this.Handle, out outTime);

            return(ret);
        }
Exemplo n.º 8
0
		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;
			
		}
Exemplo n.º 9
0
 extern static CVReturn CVDisplayLinkGetCurrentTime(IntPtr displayLink, out CVTimeStamp outTime);
Exemplo n.º 10
0
        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;
        }
Exemplo n.º 11
0
		CVReturn DisplayLinkOutputCallback (CVDisplayLink displayLink, ref CVTimeStamp inNow, ref CVTimeStamp inOutputTime, CVOptionFlags flagsIn, ref CVOptionFlags flagsOut)
		{
			Game.Instance.BeginInvokeOnMainThread ( () => Game.Instance.EmitTick () );
			return CVReturn.Success;
		}
Exemplo n.º 12
0
	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);
	}
Exemplo n.º 13
0
	public CVReturn GetCurrentTime (out CVTimeStamp outTime)
	{
		CVReturn ret = CVDisplayLinkGetCurrentTime (this.Handle, out outTime);
			
		return ret;
	}
Exemplo n.º 14
0
	extern static CVReturn CVDisplayLinkGetCurrentTime (IntPtr displayLink, out CVTimeStamp outTime);