Esempio n. 1
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);
        }