Beispiel #1
0
        public SkyboxGeneratorContext(SkyboxAsset skybox, IDatabaseFileProviderService fileProviderService)
        {
            Skybox   = skybox ?? throw new ArgumentNullException(nameof(skybox));
            Services = new ServiceRegistry();
            Services.AddService(fileProviderService);
            Content = new ContentManager(Services);
            Services.AddService <IContentManager>(Content);
            Services.AddService(Content);

            GraphicsDevice        = GraphicsDevice.New();
            GraphicsDeviceService = new GraphicsDeviceServiceLocal(Services, GraphicsDevice);
            Services.AddService(GraphicsDeviceService);

            var graphicsContext = new GraphicsContext(GraphicsDevice);

            Services.AddService(graphicsContext);

            EffectSystem          = new EffectSystem(Services);
            EffectSystem.Compiler = EffectCompilerFactory.CreateEffectCompiler(Content.FileProvider, EffectSystem);

            Services.AddService(EffectSystem);
            EffectSystem.Initialize();
            ((IContentable)EffectSystem).LoadContent();
            ((EffectCompilerCache)EffectSystem.Compiler).CompileEffectAsynchronously = false;

            RenderContext     = RenderContext.GetShared(Services);
            RenderDrawContext = new RenderDrawContext(Services, RenderContext, graphicsContext);
        }
Beispiel #2
0
        public SkyboxGeneratorContext(SkyboxAsset skybox)
        {
            if (skybox == null)
            {
                throw new ArgumentNullException(nameof(skybox));
            }

            Skybox   = skybox;
            Services = new ServiceRegistry();
            Content  = new ContentManager(Services);

            GraphicsDevice        = GraphicsDevice.New();
            GraphicsDeviceService = new GraphicsDeviceServiceLocal(Services, GraphicsDevice);

            var graphicsContext = new GraphicsContext(GraphicsDevice);

            Services.AddService(typeof(GraphicsContext), graphicsContext);

            EffectSystem = new EffectSystem(Services);
            EffectSystem.Initialize();
            ((IContentable)EffectSystem).LoadContent();
            ((EffectCompilerCache)EffectSystem.Compiler).CompileEffectAsynchronously = false;

            RenderContext     = RenderContext.GetShared(Services);
            RenderDrawContext = new RenderDrawContext(Services, RenderContext, graphicsContext);
        }
Beispiel #3
0
        public SceneRenderer(GameSettingsAsset gameSettings)
        {
            if (gameSettings == null)
            {
                throw new ArgumentNullException(nameof(gameSettings));
            }

            // Initialize services
            Services       = new ServiceRegistry();
            ContentManager = new ContentManager(Services);
            Services.AddService(typeof(IContentManager), ContentManager);
            Services.AddService(typeof(ContentManager), ContentManager);

            var renderingSettings = gameSettings.GetOrCreate <RenderingSettings>();

            GraphicsDevice = GraphicsDevice.New(DeviceCreationFlags.Debug, new[] { renderingSettings.DefaultGraphicsProfile });

            var graphicsDeviceService = new GraphicsDeviceServiceLocal(Services, GraphicsDevice);

            Services.AddService(typeof(IGraphicsDeviceService), graphicsDeviceService);
            EffectSystem = new EffectSystem(Services);
            Services.AddService(typeof(EffectSystem), EffectSystem);

            GraphicsContext = new GraphicsContext(GraphicsDevice);
            Services.AddService(typeof(GraphicsContext), GraphicsContext);

            SceneSystem = new SceneSystem(Services);
            Services.AddService(typeof(SceneSystem), SceneSystem);

            // Create game systems
            GameSystems = new GameSystemCollection(Services);
            Services.AddService(typeof(IGameSystemCollection), GameSystems);

            var gameFontSystem = new GameFontSystem(Services);

            Services.AddService(typeof(FontSystem), gameFontSystem.FontSystem);
            Services.AddService(typeof(IFontFactory), gameFontSystem.FontSystem);
            GameSystems.Add(gameFontSystem);

            var uiSystem = new UISystem(Services);

            Services.AddService(typeof(UISystem), uiSystem);
            GameSystems.Add(uiSystem);

            GameSystems.Add(EffectSystem);
            GameSystems.Add(SceneSystem);
            GameSystems.Initialize();

            // Fake presenter
            // TODO GRAPHICS REFACTOR: This is needed be for render stage setup
            GraphicsDevice.Presenter = new RenderTargetGraphicsPresenter(GraphicsDevice,
                                                                         Texture.New2D(GraphicsDevice, renderingSettings.DefaultBackBufferWidth, renderingSettings.DefaultBackBufferHeight,
                                                                                       renderingSettings.ColorSpace == ColorSpace.Linear ? PixelFormat.R8G8B8A8_UNorm_SRgb : PixelFormat.R8G8B8A8_UNorm, TextureFlags.ShaderResource | TextureFlags.RenderTarget),
                                                                         PixelFormat.D24_UNorm_S8_UInt);

            GraphicsContext.CommandList.SetRenderTarget(GraphicsDevice.Presenter.DepthStencilBuffer, GraphicsDevice.Presenter.BackBuffer);
        }
Beispiel #4
0
 public SkyboxGeneratorContext()
 {
     Services              = new ServiceRegistry();
     Assets                = new AssetManager(Services);
     GraphicsDevice        = GraphicsDevice.New();
     GraphicsDeviceService = new GraphicsDeviceServiceLocal(Services, GraphicsDevice);
     EffectSystem          = new EffectSystem(Services);
     EffectSystem.Initialize();
     ((IContentable)EffectSystem).LoadContent();
     ((EffectCompilerCache)EffectSystem.Compiler).CompileEffectAsynchronously = false;
     DrawEffectContext = RenderContext.GetShared(Services);
 }
Beispiel #5
0
 public SkyboxGeneratorContext()
 {
     Services = new ServiceRegistry();
     Assets = new AssetManager(Services);
     GraphicsDevice = GraphicsDevice.New();
     GraphicsDeviceService = new GraphicsDeviceServiceLocal(Services, GraphicsDevice);
     EffectSystem = new EffectSystem(Services);
     EffectSystem.Initialize();
     ((IContentable)EffectSystem).LoadContent();
     ((EffectCompilerCache)EffectSystem.Compiler).CompileEffectAsynchronously = false;
     DrawEffectContext = RenderContext.GetShared(Services);
 }