Пример #1
0
        protected GraphicsDeviceTestBase(GraphicsBackend backend, bool validation = false)
        {
            switch (backend)
            {
            case GraphicsBackend.Direct3D11:
                if (!D3D11GraphicsDeviceFactory.IsSupported())
                {
                    throw new GraphicsException($"Backend {backend} is not supported");
                }

                _graphicsDeviceFactory = new D3D11GraphicsDeviceFactory(validation);
                break;

            case GraphicsBackend.Direct3D12:
                if (!D3D12GraphicsDeviceFactory.IsSupported())
                {
                    throw new GraphicsException($"Backend {backend} is not supported");
                }

                _graphicsDeviceFactory = new D3D12GraphicsDeviceFactory(validation);
                break;

            default:
                throw new GraphicsException($"Backend {backend} is not supported");
            }

            _graphicsDevice = _graphicsDeviceFactory.CreateDevice(PowerPreference.Default);
        }
Пример #2
0
 public static RenderEngine Create(IRenderableWindow window,
                                   IInputManager inputManager, IContextState context, EngineNotificator notificator)
 {
     GraphicsDeviceFactory.CreateOutputHandleDevice(window);
     return(new RenderEngine(GraphicsDeviceFactory.CreateOutputHandleDevice(window),
                             window, inputManager, context, notificator));
 }
Пример #3
0
        public void Run()
        {
            if (IsRunning)
            {
                throw new InvalidOperationException("Cannot run this instance while it is already running");
            }

            try
            {
                // Create GPU device first.
                _graphicsDeviceFactory = CreateGraphicsFactory(validation: true);
                _graphicsDevice        = _graphicsDeviceFactory.CreateDevice(PowerPreference.Default);
                MainView.SetDevice(_graphicsDevice);

                // Enter main loop.
                _host.Run();

                if (!_host.IsAsyncLoop)
                {
                    // If the previous call was blocking, then we can call Endrun
                    EndRun();
                }
                else
                {
                    // EndRun will be executed on Exit
                    _endRunRequired = true;
                }
            }
            finally
            {
                if (!_endRunRequired)
                {
                    IsRunning = false;
                }
            }
        }
Пример #4
0
 public static RenderEngine Create(IFrameRenderableSurface surface,
                                   IInputManager inputManager, IContextState context, EngineNotificator notificator)
 {
     return(new RenderEngine(GraphicsDeviceFactory.CreateOutputTargetView(surface),
                             surface, inputManager, context, notificator));
 }