예제 #1
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;
        }
        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();
        }
예제 #3
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();
        }