Ejemplo n.º 1
0
        private void ApplyChanges()
        {
            if (_graphicsDevice == null)
            {
                return;
            }

            var gdi = new GraphicsDeviceInfo
            {
                Adapter = _graphicsDevice.Adapter,
                PresentationParameters = _graphicsDevice.PresentationParameters.Clone()
            };

            gdi.PresentationParameters.BackBufferFormat = PreferredBackBufferFormat;

            gdi.PresentationParameters.BackBufferWidth  = PreferredBackBufferWidth;
            gdi.PresentationParameters.BackBufferHeight = PreferredBackBufferHeight;

            gdi.PresentationParameters.DepthStencilFormat   = PreferredDepthStencilFormat;
            gdi.PresentationParameters.IsFullScreen         = IsFullScreen;
            gdi.PresentationParameters.PresentationInterval = SynchronizeWithVerticalRetrace
                                                                                  ? PresentInterval.One
                                                                                  : PresentInterval.Immediate;

            // TODO: ??? OnPreparingDeviceSettings(this, new PreparingDeviceSettingsEventArgs(gdi));

            Window.BeginScreenDeviceChange(gdi.PresentationParameters.IsFullScreen);
            Window.EndScreenDeviceChange(gdi.Adapter.DeviceName,
                                         gdi.PresentationParameters.BackBufferWidth,
                                         gdi.PresentationParameters.BackBufferHeight);

            // FIXME: This should be before EndScreenDeviceChange! -flibit
            _graphicsDevice.Reset(gdi.PresentationParameters, gdi.Adapter);
        }
Ejemplo n.º 2
0
        private void CreateGraphicsDevice()
        {
            if (_graphicsDevice != null)
            {
                return;
            }

            var gdi = new GraphicsDeviceInfo
            {
                Adapter = Platform.GetGraphicsAdapters().First(),
                PresentationParameters = new PresentationParameters
                {
                    DeviceWindowHandle = Window.Handle,
                    DepthStencilFormat = PreferredDepthStencilFormat,
                    IsFullScreen       = false
                }
            };

            // TODO: ??? OnPreparingDeviceSettings(this, new PreparingDeviceSettingsEventArgs(gdi));

            PreferredBackBufferFormat   = gdi.PresentationParameters.BackBufferFormat;
            PreferredDepthStencilFormat = gdi.PresentationParameters.DepthStencilFormat;

            _graphicsDevice = _graphicsDeviceFactory(gdi.Adapter, gdi.PresentationParameters);

            _graphicsDevice.Disposing += OnDeviceDisposing;
            // TODO: ...
            //_graphicsDevice.DeviceResetting += OnDeviceResetting;
            //_graphicsDevice.DeviceReset += OnDeviceReset;

            ApplyChanges();

            // TODO: ??? OnDeviceCreated(this, EventArgs.Empty);
        }