예제 #1
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            orientationListener = new OrientationListener(this);
            if (orientationListener.CanDetectOrientation())
            {
                orientationListener.Enable();
            }

            // hide window title
            this.RequestedOrientation = ScreenOrientation.Landscape;
            RequestWindowFeature(WindowFeatures.NoTitle);

            // make app fullscreen
            Window.SetFlags(WindowManagerFlags.Fullscreen, WindowManagerFlags.Fullscreen);

            // Create our OpenGL view, and display it
            view = new GLView(this);

            SetContentView(view);

            view.Run();

            //Accelerometer.SetupAccelerometer(this);
        }
예제 #2
0
        private async void GLView_PaintSurface(object sender, SKPaintGLSurfaceEventArgs e)
        {
            if (Game == null)
            {
                Game = new GameManager(e.BackendRenderTarget.Width, e.BackendRenderTarget.Height);
            }

            var current = DateTime.Now;

            lag     += current - previous;
            previous = current;

            var ticksThisDraw = 0;

            while (lag >= update_interval)
            {
                Game.Tick();
                lag -= update_interval;

                ticksThisDraw++;
                if (ticksThisDraw >= 40)
                {
                    lag = TimeSpan.Zero;
                }
            }

            Game.Draw(e.Surface.Canvas);

            await Task.Delay(10);

            GLView.InvalidateSurface();
        }
예제 #3
0
 void ReleaseDesignerOutlets()
 {
     if (glView != null) {
         glView.Dispose ();
         glView = null;
     }
 }
예제 #4
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            CrashHandlerActivity.Register(this);

            Window.AddFlags(WindowManagerFlags.KeepScreenOn);

            try {
                View decorView = Window.DecorView;
                decorView.SystemUiVisibility |= (StatusBarVisibility)SystemUiFlags.LayoutStable;
                decorView.SystemUiVisibility |= (StatusBarVisibility)SystemUiFlags.LayoutFullscreen;
                decorView.SystemUiVisibility |= (StatusBarVisibility)SystemUiFlags.Immersive;

                //if ((int)Build.VERSION.SdkInt < 18)
                //    RequestedOrientation = ScreenOrientation.SensorLandscape;

                Window.ClearFlags(WindowManagerFlags.TranslucentStatus);
                Window.AddFlags(WindowManagerFlags.DrawsSystemBarBackgrounds);

                if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop)
                {
                    Window.SetStatusBarColor(Color.Argb(0x22, 0x00, 0x00, 0x00));
                }
            } catch /*(Exception ex)*/ {
#if DEBUG
                throw;
#endif
            }

            // Create our OpenGL view, and display it
            view = new GLView(this);
            SetContentView(view);
        }
예제 #5
0
 void ReleaseDesignerOutlets()
 {
     if (glView != null)
     {
         glView.Dispose();
         glView = null;
     }
 }
예제 #6
0
        public GameForm(GLView sharedContextView, IEnumerable<FPGameObject> gameObjects)
        {
            InitializeComponent();
            gameView.SharedContextView = sharedContextView;

            pressedKeys = new HashSet<int>();
            game = new FPGame(gameView.Width, gameView.Height, gameObjects);
        }
예제 #7
0
        private void GLView_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
        {
            ChaosTime.UpdateTime();
            ChaosPhysics.Frame();
            GL.Viewport(0, 0, GLView.Width, GLView.Height);
            GL.Clear(ClearBufferMask.ColorBufferBit);
            GL.Clear(ClearBufferMask.DepthBufferBit);
            //GL.UseProgram(shaders["default"]);

            GL.BindVertexArray(VAO);
            GL.DrawArrays(PrimitiveType.Triangles, 0, 3);

            GLView.SwapBuffers();
        }
예제 #8
0
        public OpenGLView(GLView gl_view)
        {
            this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            this.SetStyle(ControlStyles.UserPaint, true);
            this.SetStyle(ControlStyles.ResizeRedraw, true);
            this.SetStyle(ControlStyles.OptimizedDoubleBuffer, false);
            //this.SetStyle(ControlStyles.DoubleBuffer, true);

            InitializeComponent();

            this.view = gl_view;
            //System.Windows.Forms.Application.Idle += new EventHandler(UpdateElapsed);
            timer = new Timer();
            timer.Interval = (int)(1000 / 60.0f);
            timer.Tick += new EventHandler(UpdateElapsed);
            timer.Start();

            //System.Windows.Forms.Application.Idle += new EventHandler(UpdateElapsed);

            //DispatcherTimer timer = new DispatcherTimer(DispatcherPriority.Render); // Happens on render
            //timer.Tick += UpdateElapsed; // Fire your "tick" handler directly here!
            //timer.Interval = new TimeSpan(0, 0, 0, 0, 15); // Asking for 66.6 fps here, since WPF really renders at about 60-62 FPS anyways, there's no need to ask for more
            //timer.Start();
        }
예제 #9
0
        public override void SetModelAndView(GLModel model, GLView view)
        {
            base.SetModelAndView(model, view);

            OnSetContext(view.GLContext);
        }
예제 #10
0
 private void WindowsFormsHost_Initialized(object sender, EventArgs e)
 {
     GLView.MakeCurrent();
 }
예제 #11
0
        protected override void OnClosed(EventArgs e)
        {
            base.OnClosed(e);

            GLView.Dispose();
        }