예제 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="holder"></param>
        /// <param name="format"></param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        void ISurfaceHolderCallback.SurfaceChanged(ISurfaceHolder holder, Format format, int width, int height)
        {
            if ((int)Build.VERSION.SdkInt >= 19)
            {
                if (!_isSurfaceChanged)
                {
                    _isSurfaceChanged  = true;
                    _prevSurfaceWidth  = width;
                    _prevSurfaceHeight = height;
                }
                else
                {
                    if (!ScreenReciever.ScreenLocked && Game.Instance.Platform.IsActive && (_prevSurfaceHeight != height || _prevSurfaceWidth != width))
                    {
                        _prevSurfaceWidth  = width;
                        _prevSurfaceHeight = height;

                        base.SurfaceDestroyed(holder);
                        base.SurfaceCreated(holder);
                    }
                }
            }


            if (width < height && (_game.graphicsDeviceManager.SupportedOrientations & DisplayOrientation.Portrait) == 0)
            {
                return;
            }

            var manager = _game.graphicsDeviceManager;

            manager.PreferredBackBufferHeight = height;
            manager.PreferredBackBufferWidth  = width;

            if (manager.GraphicsDevice != null)
            {
                manager.GraphicsDevice.Viewport = new Viewport(0, 0, width, height);
            }

            _gameWindow.ChangeClientBounds(new Rectangle(0, 0, width, height));
            manager.ApplyChanges();

            SurfaceChanged(holder, format, width, height);

            if (_game.GraphicsDevice != null)
            {
                _game.graphicsDeviceManager.ResetClientBounds();
            }
        }