예제 #1
0
		void StopDisplayLink ()
		{
			if (displayLink != null) {
				displayLink.Invalidate ();
				displayLink = null;
			}
		}
예제 #2
0
		void StartDisplayLinkIfNeeded ()
		{
			if (displayLink == null) {
				displayLink = CADisplayLink.Create (() => CubeView.Display ());
				displayLink.AddToRunLoop (NSRunLoop.Main, NSRunLoop.UITrackingRunLoopMode);
			}
		}
예제 #3
0
    public void Start ()
    {
      waveBoundaryPath = new UIBezierPath ();

      waveLayer = new CAShapeLayer ();
      waveLayer.FillColor = new CGColor (0, 0, 0, 1);
      Layer.AddSublayer (waveLayer);
      waveDisplaylink = CADisplayLink.Create (() => GetCurrentWave (waveDisplaylink));
	  waveDisplaylink.AddToRunLoop (NSRunLoop.Main, NSRunLoop.NSDefaultRunLoopMode);
    }
예제 #4
0
		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();
			
			backgroundQueue = new DispatchQueue ("com.videotimeline.backgroundqueue", false);
			displayLink = CADisplayLink.Create (DisplayLinkCallback);
			displayLink.AddToRunLoop (NSRunLoop.Current, NSRunLoopMode.Default);
			displayLink.Paused = true;
			lastCallbackTime = 0.0;
			bufferSemaphore = new SemaphoreSlim (0);
		}
예제 #5
0
 public void StopAnimating()
 {
     if (!IsAnimating)
     {
         return;
     }
     displayLink.Invalidate();
     displayLink = null;
     DestroyFrameBuffer();
     IsAnimating = false;
 }
예제 #6
0
 private void ReleaseDisplayLink()
 {
     if (_isAttachedToLooper)
     {
         //Detach the _displayLink to the MainLoop (uiThread).
         _displayLink?.RemoveFromRunLoop(NSRunLoop.Main, NSRunLoop.NSDefaultRunLoopMode);                //detaches from the UI thread
         _displayLink?.RemoveFromRunLoop(NSRunLoop.Main, NSRunLoop.UITrackingRunLoopMode);
         _displayLink        = null;
         _isAttachedToLooper = false;
     }
 }
예제 #7
0
 public void StopRendering()
 {
     if (!_isRendering)
     {
         return;
     }
     _displayLink.Invalidate();
     _displayLink = null;
     DestroyFrameBuffer();
     _isRendering = false;
 }
예제 #8
0
        public void StartAnimation()
        {
            if (!animating)
            {
                displayLink = CADisplayLink.Create(drawView);
                displayLink.FrameInterval = AnimationFrameInterval;
                displayLink.AddToRunLoop(NSRunLoop.Current, NSRunLoop.NSDefaultRunLoopMode);

                animating = true;
            }
        }
예제 #9
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            backgroundQueue = new DispatchQueue("com.videotimeline.backgroundqueue", false);
            displayLink     = CADisplayLink.Create(DisplayLinkCallback);
            displayLink.AddToRunLoop(NSRunLoop.Current, NSRunLoopMode.Default);
            displayLink.Paused = true;
            lastCallbackTime   = 0.0;
            bufferSemaphore    = new SemaphoreSlim(0);
        }
예제 #10
0
        public CADisplayLinkTimeSource (iPhoneOSGameView view, int frameInterval)
        {
            this.view = view;

            if (displayLink != null)
                displayLink.Invalidate ();

            displayLink = CADisplayLink.Create (this, selRunIteration);
            displayLink.FrameInterval = frameInterval;
            displayLink.Paused = true;
        }
예제 #11
0
 public void StartAnimating()
 {
     if (IsAnimating)
         return;
     CreateFrameBuffer ();
     CADisplayLink displayLink = UIScreen.MainScreen.CreateDisplayLink (this, new Selector ("drawFrame"));
     displayLink.FrameInterval = _frameInterval;
     displayLink.AddToRunLoop (NSRunLoop.Current, NSRunLoop.NSDefaultRunLoopMode);
     _displayLink = displayLink;
     IsAnimating = true;
 }
예제 #12
0
        protected override void Dispose(bool disposing)
        {
            // stop the render loop
            if (_displayLink != null)
            {
                _displayLink.Invalidate();
                _displayLink.Dispose();
                _displayLink = null;
            }

            base.Dispose(disposing);
        }
예제 #13
0
        public void StartRendering()
        {
            LayerColorFormat = EAGLColorFormat.RGBA8;
            CreateFrameBuffer();
            GL.ClearColor(1, 1, 1, 1);
            CADisplayLink displayLink = UIScreen.MainScreen.CreateDisplayLink(this, new Selector("drawFrame"));

            displayLink.FrameInterval = 1;
            displayLink.AddToRunLoop(NSRunLoop.Current, NSRunLoop.NSDefaultRunLoopMode);

            Map.ViewChanged(true);
        }
예제 #14
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            View.BackgroundColor = UIColor.SystemPinkColor;

            // device init
            GraphicsDeviceOptions options = new GraphicsDeviceOptions(false, null, false, ResourceBindingModel.Improved);

#if DEBUG
            options.Debug = true;
#endif
            SwapchainSource      ss  = SwapchainSource.CreateUIView(this.View.Handle);
            SwapchainDescription scd = new SwapchainDescription(
                ss,
                width, height,
                PixelFormat.R32_Float,
                false);

            graphicsDevice = GraphicsDevice.CreateMetal(options);
            swapchain      = graphicsDevice.ResourceFactory.CreateSwapchain(ref scd);
            factory        = graphicsDevice.ResourceFactory;

            // resource init
            CreateSizeDependentResources();
            VertexPosition[] quadVertices =
            {
                new VertexPosition(new Vector3(-1,  1, 0)),
                new VertexPosition(new Vector3(1,   1, 0)),
                new VertexPosition(new Vector3(-1, -1, 0)),
                new VertexPosition(new Vector3(1,  -1, 0))
            };
            uint[] quadIndices = new uint[]
            {
                0,
                1,
                2,
                1,
                3,
                2
            };
            vertexBuffer = factory.CreateBuffer(new BufferDescription(4 * VertexPosition.SizeInBytes, BufferUsage.VertexBuffer));
            indexBuffer  = factory.CreateBuffer(new BufferDescription(6 * sizeof(uint), BufferUsage.IndexBuffer));
            graphicsDevice.UpdateBuffer(vertexBuffer, 0, quadVertices);
            graphicsDevice.UpdateBuffer(indexBuffer, 0, quadIndices);

            commandList = factory.CreateCommandList();

            viewLoaded = true;

            displayLink = CADisplayLink.Create(Render);
            displayLink.PreferredFramesPerSecond = 60;
            displayLink.AddToRunLoop(NSRunLoop.Main, NSRunLoop.NSDefaultRunLoopMode);
        }
예제 #15
0
 public DisplayLinkTimer()
 {
     var link = CADisplayLink.Create(OnLinkTick);
     TimerThread = new Thread(() =>
     {
         link.AddToRunLoop(NSRunLoop.Current, NSRunLoopMode.Common);
         NSRunLoop.Current.Run();
     });
     TimerThread.Start();
     UIApplication.Notifications.ObserveDidEnterBackground((_,__) => link.Paused = true);
     UIApplication.Notifications.ObserveWillEnterForeground((_, __) => link.Paused = false);
 }
예제 #16
0
        private void SetupTimer()
        {
            if (this.updateTimer != null)
            {
                this.updateTimer.Invalidate();
                this.updateTimer.Dispose();
                this.updateTimer = null;
            }

            this.updateTimer = CADisplayLink.Create(this.Refresh);
            this.updateTimer.AddToRunLoop(NSRunLoop.Current, NSRunLoopMode.Default);
        }
예제 #17
0
 public void Open(LiquidFloatingCell[] cells)
 {
     Stop();
     displayLink = CADisplayLink.Create(DidDisplayRefresh);
     displayLink.AddToRunLoop(NSRunLoop.Current, NSRunLoopMode.Common);
     opening = true;
     foreach (var cell in cells)
     {
         cell.Layer.RemoveAllAnimations();
         cell.Layer.EraseShadow();
         openingCells.Add(cell);
     }
 }
예제 #18
0
        public CADisplayLinkTimeSource(iOSGameView view, int preferredFramesPerSecond)
        {
            this.view = view;

            if (displayLink != null)
            {
                displayLink.Invalidate();
            }

            displayLink = CADisplayLink.Create(this, selRunIteration);
            displayLink.PreferredFramesPerSecond = preferredFramesPerSecond;
            displayLink.Paused = true;
        }
        protected void StopAutoScroll()
        {
            if (displayLink == null)
            {
                return;
            }

            displayLink.Paused = true;
            displayLink.Dispose();
            displayLink         = null;
            isAutoScrollingUp   = false;
            isAutoScrollingDown = false;
        }
예제 #20
0
        private void showStartTimerSuccess(string description)
        {
            descriptionLabel.Text = string.IsNullOrEmpty(description) ? "No Description" : description;
            timeLabel.Text        = "";
            timeFrameLabel.Text   = "";

            var start       = DateTimeOffset.Now;
            var displayLink = CADisplayLink.Create(() => {
                var passed     = DateTimeOffset.Now - start;
                timeLabel.Text = secondsToString(passed.Seconds);
            });

            displayLink.AddToRunLoop(NSRunLoop.Current, NSRunLoopMode.Default);
        }
예제 #21
0
 void UpdateAnimation()
 {
     if (ShouldAnimate())
     {
         displayLink = CADisplayLink.Create(TimerFired);
         displayLink.AddToRunLoop(NSRunLoop.Main, NSRunLoopMode.Common);
         displayLink.PreferredFramesPerSecond = 60;
     }
     else
     {
         displayLink?.Invalidate();
         displayLink = null;
     }
 }
 void addInputTraitsObservers()
 {
     // note that KVO doesn't work on textDocumentProxy, so we have to poll
     if (traitPollingTimer != null)
     {
         traitPollingTimer.Invalidate();
     }
     traitPollingTimer = UIScreen.MainScreen.CreateDisplayLink(() => pollTraits());
     if (traitPollingTimer != null)
     {
         traitPollingTimer.AddToRunLoop(NSRunLoop.Current, mode: NSRunLoopMode.Default);
     }
     //Console.WriteLine("addInputTraitsObservers done");
 }
예제 #23
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            constantDataBufferIndex = 0;
            inflightSemaphore       = new Semaphore(max_inflight_buffers, max_inflight_buffers);

            SetupMetal();
            LoadAssets();

            timer = CADisplayLink.Create(Gameloop);
            timer.FrameInterval = 1;
            timer.AddToRunLoop(NSRunLoop.Main, NSRunLoop.NSDefaultRunLoopMode);
        }
예제 #24
0
        public void StartAnimating()
        {
            if (IsAnimating)
            {
                return;
            }

            CreateFrameBuffer();
            displayLink = UIScreen.MainScreen.CreateDisplayLink(this, new Selector("drawFrame"));
            displayLink.FrameInterval = frameInterval;
            displayLink.AddToRunLoop(NSRunLoop.Current, NSRunLoop.NSDefaultRunLoopMode);

            IsAnimating = true;
        }
예제 #25
0
 public void Close(LiquidFloatingCell[] cells)
 {
     Stop();
     opening     = false;
     displayLink = CADisplayLink.Create(DidDisplayRefresh);
     displayLink.AddToRunLoop(NSRunLoop.Current, NSRunLoopMode.Common);
     foreach (var cell in cells)
     {
         cell.Layer.RemoveAllAnimations();
         cell.Layer.EraseShadow();
         openingCells.Add(cell);
         cell.UserInteractionEnabled = false;
     }
 }
 public void Open(LiquidFloatingCell[] cells)
 {
     Stop();
     _displayLink = CADisplayLink.Create(DidDisplayRefresh);
     _displayLink.AddToRunLoop(NSRunLoop.Current, NSRunLoopMode.Common);
     _opening = true;
     foreach (var cell in cells)
     {
         // ISSUE: reference to a compiler-generated method
         cell.Layer.RemoveAllAnimations();
         cell.Layer.EraseShadow();
         _openingCells.Add(cell);
     }
 }
예제 #27
0
        protected override void SetupRenderLoop(bool oneShot)
        {
            // only start if we haven't already
            if (_displayLink != null)
            {
                return;
            }

            // bail out if we are requesting something that the view doesn't want to
            if (!oneShot && !Element.HasRenderLoop)
            {
                return;
            }

            // if this is a one shot request, don't bother with the display link
            if (oneShot)
            {
                var nativeView = Control;
                nativeView?.BeginInvokeOnMainThread(() =>
                {
                    if (nativeView.Handle != IntPtr.Zero)
                    {
                        nativeView.Display();
                    }
                });
                return;
            }

            // create the loop
            _displayLink = CADisplayLink.Create(() =>
            {
                var nativeView = Control;
                var formsView  = Element;

                // stop the render loop if this was a one-shot, or the views are disposed
                if (nativeView == null || formsView == null || nativeView.Handle == IntPtr.Zero ||
                    !formsView.HasRenderLoop)
                {
                    _displayLink.Invalidate();
                    _displayLink.Dispose();
                    _displayLink = null;
                    return;
                }

                // redraw the view
                nativeView.Display();
            });
            _displayLink.AddToRunLoop(NSRunLoop.Current, NSRunLoop.NSDefaultRunLoopMode);
        }
예제 #28
0
        public IOSWindow(IOSAppDelegate appDelegate)
        {
            _displaySize = new Vector2Int(
                (int)UIScreen.MainScreen.NativeBounds.Size.Width,
                (int)UIScreen.MainScreen.NativeBounds.Size.Height
                );

            _stopwatch  = new Stopwatch();
            _stopwatch2 = new Stopwatch();

            // Create the window
            Window = new UIWindow(UIScreen.MainScreen.Bounds);
            Window.RootViewController = new NozNavigationController();
            Window.BackgroundColor    = UIColor.White;
            Window.MakeKeyAndVisible();

            appDelegate.Window = Window;

            // Create GL context
            GLContext = new EAGLContext(EAGLRenderingAPI.OpenGLES3);
            EAGLContext.SetCurrentContext(GLContext);

            // Create teh view
            _view = new NozView(this, Window.Bounds);
            _view.MultipleTouchEnabled   = true;
            _view.UserInteractionEnabled = true;
            Window.AddSubview(_view);

            Graphics.Driver = OpenGLDriver.Create();

            // Create render buffer..
            _renderBufferId = GL.GenRenderBuffer();
            GL.BindRenderBuffer(_renderBufferId);
            GLContext.RenderBufferStorage((uint)GL.Imports.GL_RENDERBUFFER, (CAEAGLLayer)_view.Layer);

            // Create frame buffer
            _frameBufferId = GL.GenFrameBuffer();
            GL.BindFrameBuffer(_frameBufferId);
            GL.FrameBufferRenderBuffer(_renderBufferId);

            var link = CADisplayLink.Create(() =>
            {
                Application.Step();
            });

            link.PreferredFramesPerSecond = 60;

            link.AddToRunLoop(NSRunLoop.Main, NSRunLoopMode.Default);
        }
예제 #29
0
 protected override void Dispose(bool disposing)
 {
     if (this.displayLink != null)
     {
         // ISSUE: reference to a compiler-generated method
         this.displayLink.Invalidate();
         this.displayLink.Dispose();
         this.displayLink = (CADisplayLink)null;
         if (this.Element != null)
         {
             this.Element.remove_DisplayRequested(new EventHandler(this.Display));
         }
     }
     base.Dispose(disposing);
 }
예제 #30
0
        void UpdateValue()
        {
            double now = NSDate.Now.SecondsSinceReferenceDate;

            progress  += now - lastUpdate;
            lastUpdate = now;

            if (progress >= totalTime)
            {
                timer.Invalidate();
                timer    = null;
                progress = totalTime;
            }

            SetTextValue(CurrentValue());
        }
예제 #31
0
        public void StartRendering()
        {
            if (_isRendering)
            {
                return;
            }

            CreateFrameBuffer();
            CADisplayLink displayLink = UIScreen.MainScreen.CreateDisplayLink(this, new Selector("drawFrame"));

            displayLink.FrameInterval = _frameInterval;
            displayLink.AddToRunLoop(NSRunLoop.Current, NSRunLoop.NSDefaultRunLoopMode);
            _displayLink = displayLink;

            _isRendering = true;
        }
        private void CreateDisplayLink()
        {
            if (_displayLink != null)
            {
                _displayLink.RemoveFromRunLoop(NSRunLoop.Main, NSRunLoop.NSDefaultRunLoopMode);
            }

            _displayLink = UIScreen.MainScreen.CreateDisplayLink(_viewController.View as iOSGameView, new Selector("doTick"));

            // FrameInterval represents how many frames must pass before the selector
            // is called again. We calculate this by dividing our target elapsed time by
            // the duration of a frame on iOS (Which is 1/60.0f at the time of writing this).
            _displayLink.FrameInterval = (int)Math.Round(60f * Game.TargetElapsedTime.TotalSeconds);

            _displayLink.AddToRunLoop(NSRunLoop.Main, NSRunLoop.NSDefaultRunLoopMode);
        }
예제 #33
0
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);

            if (context != null)
            {
                context.Dispose();
                context = null;
            }

            if (displayLink != null)
            {
                displayLink.Dispose();
                displayLink = null;
            }
        }
예제 #34
0
        protected override void Dispose(bool disposing)
        {
            if (_displayLink != null)
            {
                _displayLink.Invalidate();
                _displayLink.Dispose();
                _displayLink = null;

                if (Element != null)
                {
                    Element.DisplayRequested -= Display;
                }
            }

            base.Dispose(disposing);
        }
예제 #35
0
        protected override void Dispose(bool disposing)
        {
            if (_displayLink != null)
            {
                _displayLink.Invalidate();
                _displayLink.Dispose();
                _displayLink = null;

                if (Element != null)
                {
                    ((IOpenGlViewController)Element).DisplayRequested -= Display;
                }
            }

            base.Dispose(disposing);
        }
예제 #36
0
        public void StartAnimating()
        {
            if (IsAnimating)
            {
                return;
            }

            base.UpdateFrame += onUpdateFrame;
            base.RenderFrame += onRenderFrame;
            IOSGameWindow.Instance.OnLoad(new EventArgs());

            _displayLink = UIScreen.MainScreen.CreateDisplayLink(this, new Selector("drawFrame"));
            _displayLink.FrameInterval = _frameInterval;
            _displayLink.AddToRunLoop(NSRunLoop.Current, NSRunLoop.NSDefaultRunLoopMode);

            IsAnimating = true;
        }
예제 #37
0
파일: MapView.cs 프로젝트: JoeCooper/ui
		/// <summary>
		/// Dispose the specified disposing.
		/// </summary>
		/// <param name="disposing">If set to <c>true</c> disposing.</param>
		protected override void Dispose(bool disposing)
		{
			base.Dispose(disposing);

			if (_displayLink != null) {
				_displayLink.Invalidate ();
				_displayLink = null;
			}

			OsmSharp.Logging.Log.TraceEvent ("MapView", TraceEventType.Verbose, "Disposing MapView");

			if (_onScreenBuffer != null &&
				_onScreenBuffer.NativeImage != null)
			{
				_onScreenBuffer.NativeImage.Dispose();
			}

			StopRenderingLoop ();
		}
예제 #38
0
		public void DispatchGameLoop ()
		{
			timer = CADisplayLink.Create (Gameloop);
			timer.FrameInterval = 1;
			timer.AddToRunLoop (NSRunLoop.Main, NSRunLoop.NSDefaultRunLoopMode);
		}
예제 #39
0
        public void StartAnimation()
        {
            if(!Animating)
            {
                if(displayLinkSupported)
                {
                    // CADisplayLink is API new to iPhone SDK 3.1. Compiling against earlier versions will result in a warning, but can
                    // be dismissed. If the system version runtime check for CADisplayLink exists in the Constructor. The runtime ensure
                    // this code will not be called in system versions earlier than 3.1.

                    displayLink = CADisplayLink.Create(DrawView);
                    displayLink.FrameInterval = AnimationFrameInterval;
                    displayLink.AddToRunLoop(NSRunLoop.Current, NSRunLoop.NSDefaultRunLoopMode);
                }
                else
                {
                    animationTimer = NSTimer.CreateScheduledTimer((1.0 / 60.0) * AnimationFrameInterval, DrawView);
                }

                Animating = true;
            }
        }
예제 #40
0
        public void StopAnimation()
        {
            if(!Animating)
            {
                if(displayLinkSupported)
                {
                    displayLink.Invalidate();
                    displayLink = null;
                }
                else
                {
                    animationTimer.Invalidate();
                    animationTimer = null;
                }

                Animating = false;
            }
        }
예제 #41
0
        private void CreateFrameBuffer()
        {
            // Setup layer

            eaglLayer = (CAEAGLLayer)this.Layer;
            eaglLayer.Opaque = false;

            bool layerRetainsBacking = false;
            NSString layerColorFormat = EAGLColorFormat.RGBA8;

            eaglLayer.DrawableProperties = NSDictionary.FromObjectsAndKeys(new NSObject[]
                                                                           {
                NSNumber.FromBoolean(layerRetainsBacking),
                layerColorFormat
            }, new NSObject[]
            {
                EAGLDrawableProperty.RetainedBacking,
                EAGLDrawableProperty.ColorFormat
            });

            // Create OpenGL drawing context

            EAGLRenderingAPI api = EAGLRenderingAPI.OpenGLES2;

            context = new EAGLContext(api);

            if (context == null)
            {
                throw new InvalidOperationException("Failed to initialize OpenGLES 2.0 context");
            }

            if (!EAGLContext.SetCurrentContext(context))
            {
                throw new InvalidOperationException("Failed to set current OpenGL context");
            }

            // Create render buffer and assign it to the context

            GL.GenRenderbuffers(1, ref colorRenderBuffer);
            GL.BindRenderbuffer(All.Renderbuffer, colorRenderBuffer);
            context.RenderBufferStorage((uint)All.Renderbuffer, eaglLayer);

            // Create frame buffer

            uint frameBuffer = 0;

            GL.GenFramebuffers(1, ref frameBuffer);
            GL.BindFramebuffer(All.Framebuffer, frameBuffer);
            GL.FramebufferRenderbuffer(All.Framebuffer, All.ColorAttachment0, All.Renderbuffer, colorRenderBuffer);

            // Set viewport
            Size size = new Size((int)Math.Round((double)eaglLayer.Bounds.Size.Width), (int)Math.Round((double)eaglLayer.Bounds.Size.Height));

            GL.Viewport(0, 0, size.Width, size.Height);

            // Create CADisplayLink for animation loop

            displayLink = CADisplayLink.Create(this, new Selector("render"));
            displayLink.FrameInterval = 1;
            displayLink.AddToRunLoop(NSRunLoop.Current, NSRunLoop.NSDefaultRunLoopMode);
        }
예제 #42
0
 public void Invalidate()
 {
     if (displayLink != null) {
         displayLink.Invalidate ();
         displayLink = null;
     }
 }
예제 #43
0
		public void StopAnimation ()
		{
			if (animating) {
				displayLink.Invalidate ();
				displayLink = null;

				animating = false;
			}
		}
 /// <summary>
 /// Stops the updating meter.
 /// </summary>
 private void StopUpdatingMeter()
 {
     mmeterUpdateDisplayLink.Invalidate ();
     mmeterUpdateDisplayLink = null;
 }
예제 #45
0
 protected SkiaView() : base(UIScreen.MainScreen.ApplicationFrame, GetContext())
 {
     (_link = CADisplayLink.Create(() => OnFrame())).AddToRunLoop(NSRunLoop.Main, NSRunLoop.NSDefaultRunLoopMode);
 }
        /// <summary>
        /// Starts the updating meter.
        /// </summary>
        private void StartUpdatingMeter()
        {
            if (mmeterUpdateDisplayLink != null)
                mmeterUpdateDisplayLink.Invalidate ();

            mmeterUpdateDisplayLink = CADisplayLink.Create (UpdateMeters);
            mmeterUpdateDisplayLink.AddToRunLoop (NSRunLoop.Current, NSRunLoopMode.Common);
        }
예제 #47
0
        public void Initialize()
        {
            CAEAGLLayer eaglLayer = (CAEAGLLayer)Layer;

            eaglLayer.Opaque = true;
            eaglLayer.DrawableProperties = NSDictionary.FromObjectsAndKeys(
                new object[] { NSNumber.FromBoolean(false), EAGLColorFormat.RGBA8 },
                new object[] { EAGLDrawableProperty.RetainedBacking, EAGLDrawableProperty.ColorFormat });

            m_context = new EAGLContext(EAGLRenderingAPI.OpenGLES2);

            if(m_context == null || !EAGLContext.SetCurrentContext(m_context))
            {
                throw new ApplicationException("Could not create/set EAGLContext");
            }

            m_renderer = new ES2Renderer();
            m_renderer.InitWithContext(m_context, (CAEAGLLayer)Layer);

            Animating = false;
            displayLinkSupported = false;
            animationFrameInterval = 1;
            displayLink = null;
            animationTimer = null;

            // A system version of 3.1 or greater is required to use CADisplayLink. The NSTimer
            // class is used as fallback when it isn't available.
            var reqSysVer = new NSString("3.1");
            var currSysVer = new NSString(UIDevice.CurrentDevice.SystemVersion);

            if(currSysVer.Compare(reqSysVer, NSStringCompareOptions.NumericSearch) != NSComparisonResult.Ascending)
                displayLinkSupported = true;
        }
예제 #48
0
        public void BeginAnimationWithLazyViews(ScrollingTickerLazyLoadingHandler dataSource,List<NSValue>subviewsSizes,ScrollDirection direction=ScrollDirection.FromRight, float scrollSpeed=0.0f, int loops=0,ScrollingTickerAnimationCompletition completition=null)
        {
            if (isAnimating) EndAnimation(false);

            lazyLoadingHandler = dataSource;
            animationCompletitionHandler = completition;
            numberOfLoops = loops;
            scrollViewDirection = direction;
            scrollViewSpeed = (scrollSpeed == 0 ? kLPScrollingAnimationPixelsPerSecond : scrollSpeed);

            displayLink = CADisplayLink.Create(this,new Selector("tickerDidScroll"));
            displayLink.AddToRunLoop(NSRunLoop.Main,NSRunLoop.NSDefaultRunLoopMode);

            LayoutTickerSubviewsWithItemSizes(subviewsSizes);
            BeginAnimation();
        }
 PlatformThreadingInterface()
 {
     // For some reason it doesn't work when I specify OnFrame method directly
     // ReSharper disable once ConvertClosureToMethodGroup
     (_link = CADisplayLink.Create(() => OnFrame())).AddToRunLoop(NSRunLoop.Main, NSRunLoop.NSDefaultRunLoopMode);
 }
예제 #50
0
        public void BeginAnimationWithViews(List<UIView> views, ScrollDirection direction=ScrollDirection.FromRight, float scrollSpeed=0.0f, int loops=0,ScrollingTickerAnimationCompletition completition=null)
        {
            if (isAnimating) EndAnimation(false);

            lazyLoadingHandler = null;
            animationCompletitionHandler = completition;
            numberOfLoops = loops;
            scrollViewDirection = direction;
            scrollViewSpeed = (scrollSpeed == 0 ? kLPScrollingAnimationPixelsPerSecond : scrollSpeed);

            if (displayLink!=null)
            {
                // Display link is used to catch the current visible area of the scrolling view during the animation
                displayLink.RemoveFromRunLoop(NSRunLoop.Main,NSRunLoop.NSDefaultRunLoopMode);
                displayLink = null;
            }

            LayoutTickerSubviewsWithItems(views);
            BeginAnimation();
        }
예제 #51
0
        private void CreateDisplayLink()
        {
            if (_caDisplayLink != null)
                _caDisplayLink.RemoveFromRunLoop(NSRunLoop.Main, NSRunLoop.NSDefaultRunLoopMode);

            _caDisplayLink = UIScreen.MainScreen.CreateDisplayLink(_viewController.View as iOSGameView, new Selector("doTick"));

            // FrameInterval represents how many frames must pass before the selector
            // is called again. We calculate this by dividing our target elapsed time by
            // the duration of a frame on iOS (Which is 1/60.0f at the time of writing this).
            _caDisplayLink.FrameInterval = (int)Math.Round(60f * Game.TargetElapsedTime.TotalSeconds);

            _caDisplayLink.AddToRunLoop(NSRunLoop.Main, NSRunLoop.NSDefaultRunLoopMode);
        }
예제 #52
0
        private bool PerformPendingExit()
        {
            if (!_isExitPending)
                return false;

            _isExitPending = false;

            if (_caDisplayLink != null) {
                _caDisplayLink.Invalidate();
                _caDisplayLink.Dispose();
                _caDisplayLink = null;
            }

            UIApplication.SharedApplication.SetStatusBarHidden(false, UIStatusBarAnimation.Fade);

            if (_viewController != null)
            {
                _viewController.InterfaceOrientationChanged -= ViewController_InterfaceOrientationChanged;
                _viewController.View.RemoveFromSuperview ();
                _viewController.View.Dispose();
                _viewController.RemoveFromParentViewController ();
                //this might crash ventus?
                _viewController.Dispose();
                _viewController = null;
            }

            if (_mainWindow != null)
            {
                _mainWindow.RemoveFromSuperview();
                _mainWindow.Dispose();
                _mainWindow = null;
            }

            if (Window != null)
            {
                Window = null;
            }

            Net.NetworkSession.Exit();

            StopObservingUIApplication ();
            RaiseAsyncRunLoopEnded ();
            //this.Game=null;
            return true;
        }
예제 #53
0
 public void StopRendering()
 {
     if (!_isRendering)
         return;
     _displayLink.Invalidate ();
     _displayLink = null;
     DestroyFrameBuffer ();
     _isRendering = false;
 }
        /// <summary>
        /// Plaies the action.
        /// </summary>
        /// <param name="item">Item.</param>
        /// <param name="args">Arguments.</param>
        private void PlayAction(object item, EventArgs args)
        {
            m_oldSessionCategory = AVAudioSession.SharedInstance().Category;
            AVAudioSession.SharedInstance ().SetCategory (AVAudioSessionCategory.Playback);

            //
            m_audioPlayer = AVAudioPlayer.FromUrl(NSUrl.FromFilename(m_recordingFilePath));
            m_audioPlayer.WeakDelegate = this;
            m_audioPlayer.MeteringEnabled = true;
            m_audioPlayer.PrepareToPlay();
            m_audioPlayer.Play();

             //UI Update
             {
                this.SetToolbarItems (new UIBarButtonItem[]{ m_pauseButton,m_flexItem1, m_recordButton,m_flexItem2, m_trashButton}, true);

                this.ShowNavigationButton (false);

                 m_recordButton.Enabled = false;
                 m_trashButton.Enabled = false;
             }

             //Start regular update
             {
                m_playerSlider.Value = (float)m_audioPlayer.CurrentTime;
                m_playerSlider.MaxValue = (float)m_audioPlayer.Duration;
                 m_viewPlayerDuration.Frame = this.NavigationController.NavigationBar.Bounds;

                m_labelCurrentTime.Text = NSStringExtensions.TimeStringForTimeInterval (m_audioPlayer.CurrentTime);
                m_labelRemainingTime.Text = NSStringExtensions.TimeStringForTimeInterval((m_ShouldShowRemainingTime) ? (m_audioPlayer.Duration - m_audioPlayer.CurrentTime): m_audioPlayer.Duration);

                m_viewPlayerDuration.SetNeedsLayout();
                m_viewPlayerDuration.LayoutIfNeeded();

                this.NavigationItem.TitleView = m_viewPlayerDuration;

                if (mplayProgressDisplayLink != null)
                    mplayProgressDisplayLink.Invalidate ();

                mplayProgressDisplayLink = CADisplayLink.Create (UpdatePlayProgress);
                mplayProgressDisplayLink.AddToRunLoop (NSRunLoop.Current, NSRunLoopMode.Common);

             }
        }
예제 #55
0
		public void StartAnimation ()
		{
			if (!animating) {
				displayLink = CADisplayLink.Create (drawView);
				displayLink.FrameInterval = AnimationFrameInterval;
				displayLink.AddToRunLoop (NSRunLoop.Current, NSRunLoop.NSDefaultRunLoopMode);

				animating = true;
			}
		}
        /// <summary>
        /// Pauses the action.
        /// </summary>
        /// <param name="item">Item.</param>
        /// <param name="args">Arguments.</param>
        private void PauseAction(object item, EventArgs args)
        {
            //
             //UI Update
             {
                this.SetToolbarItems (new UIBarButtonItem[]{m_playButton,m_flexItem1, m_recordButton,m_flexItem2, m_trashButton }, true);

                this.ShowNavigationButton (true);

                 m_recordButton.Enabled = true;
                 m_trashButton.Enabled = true;
             }
            //
             {
                mplayProgressDisplayLink.Invalidate ();
                mplayProgressDisplayLink = null;
                this.NavigationItem.TitleView = null;
             }
            //
             m_audioPlayer.Delegate = null;
             m_audioPlayer.Stop();
             m_audioPlayer = null;

            AVAudioSession.SharedInstance ().SetCategory(new NSString(m_oldSessionCategory));
        }
예제 #57
0
 public void Stop ()
 {
   waveDisplaylink.Invalidate ();
   waveDisplaylink = null;
 }
예제 #58
0
        public CADisplayLinkTimeSource(iPhoneOSGameView view, int frameInterval)
        {
            this.view = view;

            if (displayLink != null)
                displayLink.Invalidate ();

            displayLink = CADisplayLink.Create (this, selRunIteration);
            displayLink.FrameInterval = frameInterval;
            displayLink.Paused = true;
        }
		public void StopAnimating ()
		{
			if (!IsAnimating)
				return;
			displayLink.Invalidate ();
			displayLink = null;
			DestroyFrameBuffer ();
			IsAnimating = false;
		}
예제 #60
0
 void GetCurrentWave (CADisplayLink displayLink)
 {
   offsetX += WaveSpeed;
   waveLayer.Path = GetCurrentWavePath ();
   waveBoundaryPath.CGPath = waveLayer.Path;
 }