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

            // Set the android global context
            if (PlatformAndroid.Context == null)
            {
                PlatformAndroid.Context = this;
            }

            // Set the format of the window color buffer (avoid conversions)
            // TODO: PDX-364: depth format is currently hard coded (need to investigate how it can be transmitted)
            Window.SetFormat(Format.Rgba8888);

            // Remove the title bar
            RequestWindowFeature(WindowFeatures.NoTitle);

            // Unpack the files contained in the apk
            //await VirtualFileSystem.UnpackAPK();

            // Create the Android OpenGl view
            gameView = new AndroidXenkoGameView(this);

            // setup the application view and xenko game context
            SetupGameViewAndGameContext();

            // set up a listener to the android ringer mode (Normal/Silent/Vibrate)
            ringerModeIntentReceiver = new RingerModeIntentReceiver((AudioManager)GetSystemService(AudioService));
            RegisterReceiver(ringerModeIntentReceiver, new IntentFilter(AudioManager.RingerModeChangedAction));

            SetFullscreenView();
            InitializeFullscreenViewCallback();
        }
Beispiel #2
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set the android global context
            if (PlatformAndroid.Context == null)
            {
                PlatformAndroid.Context = this;
            }

            // Remove the title bar
            RequestWindowFeature(WindowFeatures.NoTitle);

            // Unpack the files contained in the apk
            //await VirtualFileSystem.UnpackAPK();

            // Create the Android OpenGl view
            GameView = new AndroidXenkoGameView(this);

            // setup the application view and xenko game context
            SetupGameViewAndGameContext();

            // set up a listener to the android ringer mode (Normal/Silent/Vibrate)
            ringerModeIntentReceiver = new RingerModeIntentReceiver((AudioManager)GetSystemService(AudioService));
            RegisterReceiver(ringerModeIntentReceiver, new IntentFilter(AudioManager.RingerModeChangedAction));

            SetFullscreenView();
            InitializeFullscreenViewCallback();
        }
Beispiel #3
0
        internal override void Initialize(GameContext gameContext)
        {
            GameContext = gameContext;

            xenkoGameForm = (AndroidXenkoGameView)gameContext.Control;
            nativeWindow  = new WindowHandle(AppContextType.Android, xenkoGameForm);

            xenkoGameForm.Load        += gameForm_Resume;
            xenkoGameForm.OnPause     += gameForm_OnPause;
            xenkoGameForm.Unload      += gameForm_Unload;
            xenkoGameForm.RenderFrame += gameForm_RenderFrame;

            // Setup the initial size of the window
            var width = gameContext.RequestedWidth;

            if (width == 0)
            {
                width = xenkoGameForm.Width;
            }

            var height = gameContext.RequestedHeight;

            if (height == 0)
            {
                height = xenkoGameForm.Height;
            }

            // Transmit requested back buffer and depth stencil formats to OpenTK
            xenkoGameForm.RequestedBackBufferFormat = gameContext.RequestedBackBufferFormat;
            xenkoGameForm.RequestedGraphicsProfile  = gameContext.RequestedGraphicsProfile;

            xenkoGameForm.Size = new Size(width, height);

            //xenkoGameForm.Resize += OnClientSizeChanged;
        }
Beispiel #4
0
        public KeyboardAndroid(InputSourceAndroid source, AndroidXenkoGameView gameView)
        {
            Source        = source;
            this.gameView = gameView;
            var listener = new Listener(this);

            gameView.SetOnKeyListener(listener);
        }
Beispiel #5
0
        public PointerAndroid(InputSourceAndroid source, AndroidXenkoGameView uiControl)
        {
            Source         = source;
            this.uiControl = uiControl;
            var listener = new Listener(this);

            uiControl.Resize += OnResize;
            uiControl.SetOnTouchListener(listener);

            OnResize(this, null);
        }
Beispiel #6
0
        public override void Initialize(InputManager inputManager)
        {
            var context = inputManager.Game.Context as GameContextAndroid;

            uiControl = context.Control;

            // Create android pointer and keyboard
            keyboard = new KeyboardAndroid(this, uiControl);
            pointer  = new PointerAndroid(this, uiControl);
            RegisterDevice(keyboard);
            RegisterDevice(pointer);

            // Create android sensors
            if ((accelerometerListener = TryGetSensorListener(SensorType.Accelerometer)) != null)
            {
                accelerometerSensor = new AccelerometerSensor(this, "Android");
                RegisterDevice(accelerometerSensor);
            }

            if ((linearAccelerationListener = TryGetSensorListener(SensorType.LinearAcceleration)) != null)
            {
                userAccelerationSensor = new UserAccelerationSensor(this, "Android");
                RegisterDevice(userAccelerationSensor);
            }

            if ((gyroscopeListener = TryGetSensorListener(SensorType.Gyroscope)) != null)
            {
                gyroscopeSensor = new GyroscopeSensor(this, "Android");
                RegisterDevice(gyroscopeSensor);
            }

            if ((gravityListener = TryGetSensorListener(SensorType.Gravity)) != null)
            {
                gravitySensor = new GravitySensor(this, "Android");
                RegisterDevice(gravitySensor);
            }

            if ((orientationListener = TryGetSensorListener(SensorType.RotationVector)) != null)
            {
                orientationSensor = new OrientationSensor(this, "Android");
                compassSensor     = new CompassSensor(this, "Android");
                RegisterDevice(orientationSensor);
                RegisterDevice(compassSensor);
            }
        }
Beispiel #7
0
        protected override void Destroy()
        {
            if (xenkoGameForm != null)
            {
                xenkoGameForm.Load        -= gameForm_Resume;
                xenkoGameForm.OnPause     -= gameForm_OnPause;
                xenkoGameForm.Unload      -= gameForm_Unload;
                xenkoGameForm.RenderFrame -= gameForm_RenderFrame;

                if (xenkoGameForm.GraphicsContext != null)
                {
                    xenkoGameForm.GraphicsContext.MakeCurrent(null);
                    xenkoGameForm.GraphicsContext.Dispose();
                }
                ((AndroidWindow)xenkoGameForm.WindowInfo).TerminateDisplay();
                //xenkoGameForm.Close(); // bug in xamarin
                xenkoGameForm.Holder.RemoveCallback(xenkoGameForm);
                xenkoGameForm.Dispose();
                xenkoGameForm = null;
            }

            base.Destroy();
        }