コード例 #1
0
        /// <summary>
        ///   Initializes a new instance of the <see cref="GraphicsDeviceManager"/> class.
        /// </summary>
        /// <param name="game">The game.</param>
        /// <exception cref="ArgumentNullException"><paramref name="game"/> cannot be a <c>null</c> reference.</exception>
        internal GraphicsDeviceManager(GameBase game)
        {
            this.game = game;
            if (this.game is null)
            {
                throw new ArgumentNullException(nameof(game));
            }

            lockDeviceCreation = new object();

            // Defines all default values
            SynchronizeWithVerticalRetrace = true;
            PreferredColorSpace            = ColorSpace.Linear;
            PreferredBackBufferFormat      = PixelFormat.R8G8B8A8_UNorm;
            PreferredDepthStencilFormat    = PixelFormat.D24_UNorm_S8_UInt;
            preferredBackBufferWidth       = DefaultBackBufferWidth;
            preferredBackBufferHeight      = DefaultBackBufferHeight;
            preferredRefreshRate           = new Rational(60, 1);
            PreferredMultisampleCount      = MultisampleCount.None;
            PreferredGraphicsProfile       = new[]
            {
                GraphicsProfile.Level_11_2,
                GraphicsProfile.Level_11_1,
                GraphicsProfile.Level_11_0
            };

            graphicsDeviceFactory = game.Services.GetService <IGraphicsDeviceFactory>();
            if (graphicsDeviceFactory is null)
            {
                throw new InvalidOperationException("IGraphicsDeviceFactory is not registered as a service");
            }

            game.WindowCreated += GameOnWindowCreated;
        }
コード例 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GraphicsDeviceManager" /> class.
        /// </summary>
        /// <param name="game">The game.</param>
        /// <exception cref="System.ArgumentNullException">The game instance cannot be null.</exception>
        public GraphicsDeviceManager(Game game)
        {
            this.game = game;
            if (this.game == null)
            {
                throw new ArgumentNullException("game");
            }

            // Defines all default values
            SynchronizeWithVerticalRetrace = true;
            PreferredBackBufferFormat      = DXGI.Format.R8G8B8A8_UNorm;
            PreferredDepthStencilFormat    = DepthFormat.Depth24Stencil8;
            preferredBackBufferWidth       = DefaultBackBufferWidth;
            preferredBackBufferHeight      = DefaultBackBufferHeight;
            preferredRefreshRate           = new Rational(60, 1);
            PreferMultiSampling            = false;
            PreferredGraphicsProfile       = new[]
            {
#if WP8
                // By default on WP8, only run in 9.3 to make sure
                // that we are not going to use 11.1 features when
                // running from the debugger.
                FeatureLevel.Level_9_3,
#else
#if DIRECTX11_1
                FeatureLevel.Level_11_1,
#endif
                FeatureLevel.Level_11_0,
                FeatureLevel.Level_10_1,
                FeatureLevel.Level_10_0,
                FeatureLevel.Level_9_3,
                FeatureLevel.Level_9_2,
                FeatureLevel.Level_9_1,
#endif
            };

            // Register the services to the registry
            game.Services.AddService(typeof(IGraphicsDeviceManager), this);
            game.Services.AddService(typeof(IGraphicsDeviceService), this);

            graphicsDeviceFactory = (IGraphicsDeviceFactory)game.Services.GetService(typeof(IGraphicsDeviceFactory));
            if (graphicsDeviceFactory == null)
            {
                throw new InvalidOperationException("IGraphicsDeviceFactory is not registered as a service");
            }

            game.WindowCreated += GameOnWindowCreated;
        }
コード例 #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GraphicsDeviceManager" /> class.
        /// </summary>
        /// <param name="game">The game.</param>
        /// <exception cref="System.ArgumentNullException">The game instance cannot be null.</exception>
        internal GraphicsDeviceManager(GameBase game)
        {
            this.game = game;
            if (this.game == null)
            {
                throw new ArgumentNullException("game");
            }

            lockDeviceCreation = new object();

            // Defines all default values
            SynchronizeWithVerticalRetrace = true;
            PreferredColorSpace            = ColorSpace.Linear;
            PreferredBackBufferFormat      = PixelFormat.R8G8B8A8_UNorm;;
            PreferredDepthStencilFormat    = PixelFormat.D24_UNorm_S8_UInt;
            preferredBackBufferWidth       = DefaultBackBufferWidth;
            preferredBackBufferHeight      = DefaultBackBufferHeight;
            preferredRefreshRate           = new Rational(60, 1);
            PreferredMultiSampleLevel      = MSAALevel.None;
            PreferredGraphicsProfile       = new[]
            {
#if SILICONSTUDIO_PLATFORM_WINDOWS_PHONE
                GraphicsProfile.Level_9_3,
#else
                GraphicsProfile.Level_11_1,
                GraphicsProfile.Level_11_0,
                GraphicsProfile.Level_10_1,
                GraphicsProfile.Level_10_0,
                GraphicsProfile.Level_9_3,
                GraphicsProfile.Level_9_2,
                GraphicsProfile.Level_9_1,
#endif
            };

            // Register the services to the registry
            game.Services.AddService(typeof(IGraphicsDeviceManager), this);
            game.Services.AddService(typeof(IGraphicsDeviceService), this);

            graphicsDeviceFactory = (IGraphicsDeviceFactory)game.Services.GetService(typeof(IGraphicsDeviceFactory));
            if (graphicsDeviceFactory == null)
            {
                throw new InvalidOperationException("IGraphicsDeviceFactory is not registered as a service");
            }

            game.WindowCreated += GameOnWindowCreated;
        }
コード例 #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GraphicsDeviceManager" /> class.
        /// </summary>
        /// <param name="game">The game.</param>
        /// <exception cref="System.ArgumentNullException">The game instance cannot be null.</exception>
        public GraphicsDeviceManager(Game game)
        {
            this.game = game;
            if (this.game == null)
            {
                throw new ArgumentNullException("game");
            }

            // Defines all default values
            SynchronizeWithVerticalRetrace = true;
            PreferredBackBufferFormat = DXGI.Format.R8G8B8A8_UNorm;
            PreferredDepthStencilFormat = DepthFormat.Depth24Stencil8;
            preferredBackBufferWidth = DefaultBackBufferWidth;
            preferredBackBufferHeight = DefaultBackBufferHeight;
            PreferMultiSampling = false;
            PreferredGraphicsProfile = new[]
                {
#if WP8
                    // By default on WP8, only run in 9.3 to make sure
                    // that we are not going to use 11.1 features when
                    // running from the debugger.
                    FeatureLevel.Level_9_3, 
#else
#if DIRECTX11_1
                    FeatureLevel.Level_11_1, 
#endif
                    FeatureLevel.Level_11_0, 
                    FeatureLevel.Level_10_1, 
                    FeatureLevel.Level_10_0, 
                    FeatureLevel.Level_9_3, 
                    FeatureLevel.Level_9_2, 
                    FeatureLevel.Level_9_1, 
#endif
                };

            // Register the services to the registry
            game.Services.AddService(typeof(IGraphicsDeviceManager), this);
            game.Services.AddService(typeof(IGraphicsDeviceService), this);

            graphicsDeviceFactory = (IGraphicsDeviceFactory)game.Services.GetService(typeof(IGraphicsDeviceFactory));
            if (graphicsDeviceFactory == null)
            {
                throw new InvalidOperationException("IGraphicsDeviceFactory is not registered as a service");
            }

            game.WindowCreated += GameOnWindowCreated;
        }
コード例 #5
0
ファイル: GraphicsDeviceManager.cs プロジェクト: cg123/xenko
        /// <summary>
        /// Initializes a new instance of the <see cref="GraphicsDeviceManager" /> class.
        /// </summary>
        /// <param name="game">The game.</param>
        /// <exception cref="System.ArgumentNullException">The game instance cannot be null.</exception>
        internal GraphicsDeviceManager(GameBase game)
        {
            this.game = game;
            if (this.game == null)
            {
                throw new ArgumentNullException("game");
            }

            lockDeviceCreation = new object();

            // Defines all default values
            SynchronizeWithVerticalRetrace = true;
            PreferredColorSpace = ColorSpace.Linear;
            PreferredBackBufferFormat = PixelFormat.R8G8B8A8_UNorm;;
            PreferredDepthStencilFormat = PixelFormat.D24_UNorm_S8_UInt;
            preferredBackBufferWidth = DefaultBackBufferWidth;
            preferredBackBufferHeight = DefaultBackBufferHeight;
            preferredRefreshRate = new Rational(60, 1);
            PreferredMultiSampleLevel = MSAALevel.None;
            PreferredGraphicsProfile = new[]
                {
#if SILICONSTUDIO_PLATFORM_WINDOWS_PHONE
                    GraphicsProfile.Level_9_3, 
#else
                    GraphicsProfile.Level_11_1, 
                    GraphicsProfile.Level_11_0, 
                    GraphicsProfile.Level_10_1, 
                    GraphicsProfile.Level_10_0, 
                    GraphicsProfile.Level_9_3, 
                    GraphicsProfile.Level_9_2, 
                    GraphicsProfile.Level_9_1, 
#endif
                };

            // Register the services to the registry
            game.Services.AddService(typeof(IGraphicsDeviceManager), this);
            game.Services.AddService(typeof(IGraphicsDeviceService), this);

            graphicsDeviceFactory = (IGraphicsDeviceFactory)game.Services.GetService(typeof(IGraphicsDeviceFactory));
            if (graphicsDeviceFactory == null)
            {
                throw new InvalidOperationException("IGraphicsDeviceFactory is not registered as a service");
            }

            game.WindowCreated += GameOnWindowCreated;
        }
コード例 #6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GraphicsDeviceManager" /> class.
        /// </summary>
        /// <param name="game">The game.</param>
        /// <exception cref="System.ArgumentNullException">The game instance cannot be null.</exception>
        public GraphicsDeviceManager(Game game)
        {
            this.game = game;
            if (this.game == null)
            {
                throw new ArgumentNullException("game");
            }

            // Defines all default values
            SynchronizeWithVerticalRetrace = true;
            PreferredBackBufferFormat = DXGI.Format.R8G8B8A8_UNorm;
            PreferredDepthStencilFormat = DepthFormat.Depth24Stencil8;
            preferredBackBufferWidth = DefaultBackBufferWidth;
            preferredBackBufferHeight = DefaultBackBufferHeight;
            PreferMultiSampling = false;
            PreferredGraphicsProfile = new []
                {
#if DIRECTX11_1
                    FeatureLevel.Level_11_1, 
#endif
                    FeatureLevel.Level_11_0, 
                    FeatureLevel.Level_10_1, 
                    FeatureLevel.Level_10_0, 
                    FeatureLevel.Level_9_3, 
                    FeatureLevel.Level_9_2, 
                    FeatureLevel.Level_9_1, 
                };

            isFullScreen = game.Window.IsFullScreenMandatory;

            // Register the services to the registry
            game.Services.AddService(typeof(IGraphicsDeviceManager), this);
            game.Services.AddService(typeof(IGraphicsDeviceService), this);

            graphicsDeviceFactory = (IGraphicsDeviceFactory)game.Services.GetService(typeof(IGraphicsDeviceFactory));
            if (graphicsDeviceFactory == null)
            {
                throw new InvalidOperationException("IGraphicsDeviceFactory is not registered as a service");
            }

            game.Window.ClientSizeChanged += Window_ClientSizeChanged;
            game.Window.OrientationChanged += Window_OrientationChanged;
        }