コード例 #1
0
ファイル: Debug.cs プロジェクト: fqlx/SpaceGame
        public void ToggleFullScreen(ref GraphicsDeviceManager graphics, NS_Camera.FirstPersonCamera camera, float CAMERA_FOVX, float CAMERA_ZNEAR, float CAMERA_ZFAR)
        {
            int newWidth = 0;
            int newHeight = 0;

            graphics.IsFullScreen = !graphics.IsFullScreen;

            if (graphics.IsFullScreen)
            {
                newWidth = graphics.GraphicsDevice.DisplayMode.Width;
                newHeight = graphics.GraphicsDevice.DisplayMode.Height;
            }
            else
            {
                newWidth = graphics.GraphicsDevice.DisplayMode.Width / 2;
                newHeight = graphics.GraphicsDevice.DisplayMode.Height / 2;
            }

            graphics.PreferredBackBufferWidth = newWidth;
            graphics.PreferredBackBufferHeight = newHeight;
            graphics.PreferMultiSampling = true;
            graphics.ApplyChanges();

            float aspectRatio = (float)newWidth / (float)newHeight;

            camera.Perspective(CAMERA_FOVX, aspectRatio, CAMERA_ZNEAR, CAMERA_ZFAR);
        }