Example #1
0
        /// <summary>
        /// Constructs a new screen manager component.
        /// </summary>
        public ScreenManager(Game game)
            : base(game)
        {
            // we must set EnabledGestures before we can query for them, but
            // we don't assume the game wants to read them.
            TouchPanel.EnabledGestures = GestureType.None;

            // Create the lighting system.
            sunBurnCoreSystem = new SunBurnCoreSystem(game.Services, game.Content);
            sceneState        = new SceneState();

            // Create the scene interface. Acts as a service provider containing all scene managers
            // and returning them by type (including custom managers). Also acts as a component
            // container where calls to manager methods on the SceneInterface (such as BeginFrameRendering,
            // Unload, ...) are automatically called on all contained managers.
            //
            // This design allows managers to be plugged-in like modular components and for managers
            // to easily be added, removed, or replaced with custom implementations.
            //
            sceneInterface = new SceneInterface();
            sceneInterface.CreateDefaultManagers(RenderingSystemType.Forward, CollisionSystemType.Physics, true);

            // Create the frame buffers used for rendering (sized to the backbuffer) and
            // assign them to the ResourceManager so we don't have to worry about cleanup.
            frameBuffers = new FrameBuffers(DetailPreference.High, DetailPreference.Medium);
            sceneInterface.ResourceManager.AssignOwnership(frameBuffers);
        }
Example #2
0
        protected GameState(string name, Application application, bool useApplicationContent, int bufferWidth, int bufferHeight, DetailPreference precisionMode, DetailPreference lightingRange)
        {
            if (string.IsNullOrEmpty(name))
                throw new ArgumentException("No valid name was provided to the GameState", "name");

            if (application == null)
                throw new ArgumentNullException("application", "No valid Application instance provided to the GameState");

            Name = name;
            Application = application;


            if (useApplicationContent)
            {
                Content = new ContentCatalogue(application);
            }
            else
            {
                _localContentManager = new ContentManager(application.Services, application.Content.RootDirectory);
                Content = new ContentCatalogue(application, _localContentManager);
            }
            // We create the IContentOwner List that will get populated with Content to be loaded with the GameState creation
            ContentToLoad = new List<IContentHost>();

            // create the SceneInterface instance from the Application
            SunBurn = Application.SunBurn;

            // create the Framebuffers and assigns the ownership to the SceneInterface
            _frameBuffers = new FrameBuffers(bufferWidth, bufferHeight, precisionMode, lightingRange);
            SunBurn.ResourceManager.AssignOwnership(_frameBuffers);
        }
Example #3
0
        protected GameState(string name, Application application, bool useApplicationContent, int bufferWidth, int bufferHeight, DetailPreference precisionMode, DetailPreference lightingRange)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentException("No valid name was provided to the GameState", "name");
            }

            if (application == null)
            {
                throw new ArgumentNullException("application", "No valid Application instance provided to the GameState");
            }

            Name        = name;
            Application = application;


            if (useApplicationContent)
            {
                Content = new ContentCatalogue(application);
            }
            else
            {
                _localContentManager = new ContentManager(application.Services, application.Content.RootDirectory);
                Content = new ContentCatalogue(application, _localContentManager);
            }
            // We create the IContentOwner List that will get populated with Content to be loaded with the GameState creation
            ContentToLoad = new List <IContentHost>();

            // create the SceneInterface instance from the Application
            SunBurn = Application.SunBurn;

            // create the Framebuffers and assigns the ownership to the SceneInterface
            _frameBuffers = new FrameBuffers(bufferWidth, bufferHeight, precisionMode, lightingRange);
            SunBurn.ResourceManager.AssignOwnership(_frameBuffers);
        }
Example #4
0
        private void CreateFrameBuffers(int bufferWidth, int bufferHeight, DetailPreference precisionMode, DetailPreference lightingRange)
        {
            //if (_frameBuffers != null)
            //    _frameBuffers.Unload();

            _frameBuffers = new FrameBuffers(bufferWidth, bufferHeight, precisionMode, lightingRange);
            SunBurn.ResourceManager.AssignOwnership(_frameBuffers);
        }
Example #5
0
 private void CreateFrameBuffers(int bufferWidth, int bufferHeight, DetailPreference precisionMode, DetailPreference lightingRange)
 {
     if (_frameBuffers != null)
         _frameBuffers.Unload();
     
     _frameBuffers = new FrameBuffers(bufferWidth, bufferHeight, precisionMode, lightingRange);
     SunBurn.ResourceManager.AssignOwnership(_frameBuffers);
 }
Example #6
0
        //The resize method is called at least once before any rendering, so it's
        //a safe place to initialize output size related vulkan objects like the
        //frame buffers.
        protected override void OnResize()
        {
            base.OnResize();

            frameBuffers?.Dispose();
            frameBuffers = renderPass.CreateFrameBuffers(swapChain);

            buildCommandBuffers();
        }
Example #7
0
        protected override void OnResize()
        {
            base.OnResize();

            updateViewRequested = true;

            frameBuffers?.Dispose();
            frameBuffers = pipeline.RenderPass.CreateFrameBuffers(swapChain);

            buildCommandBuffers();
        }
Example #8
0
        protected override void OnResize()
        {
            base.OnResize();

            dev.WaitIdle();
            updateMatrices();

            frameBuffers?.Dispose();
            frameBuffers = pipeline.RenderPass.CreateFrameBuffers(swapChain);

            buildCommandBuffers();
        }
Example #9
0
        /// <summary>
        ///   Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
        /// </summary>
        /// <filterpriority>2</filterpriority>
        public void Dispose()
        {
            Layers.Clear();

            if (_localContentManager != null)
            {
                _localContentManager.Unload();
                //_localContentManager.Dispose();
                //_localContentManager = null;
            }

            FrameBuffers.Unload();
        }
        public void Resize()
        {
            frameBuffers?.Dispose();
            frameBuffers = new FrameBuffers();

            createGBuff();

            for (int i = 0; i < swapChain.ImageCount; ++i)
            {
                frameBuffers.Add(new FrameBuffer(renderPass, swapChain.Width, swapChain.Height, new Image [] {
                    swapChain.images[i], null, gbColorRough, gbEmitMetal, gbN_AO, gbPos, hdrImg
                }));
            }
            //frameBuffers = renderPass.CreateFrameBuffers (swapChain);
        }
Example #11
0
        protected override void OnResize()
        {
            base.OnResize();

            dev.WaitIdle();

            renderer.Resize(Width, Height);

            UpdateView();

            frameBuffers?.Dispose();
            frameBuffers = plToneMap.RenderPass.CreateFrameBuffers(swapChain);

            DescriptorSetWrites dsUpdate = new DescriptorSetWrites(plToneMap.Layout.DescriptorSetLayouts[0].Bindings[0]);

            dsUpdate.Write(dev, descriptorSet, renderer.hdrImgResolved.Descriptor);

            buildCommandBuffers();

            dev.WaitIdle();
        }
Example #12
0
        public SimpleGameScreen()
        {
            sceneState = new SceneState();

            // Create the scene interface. Acts as a service provider containing all scene managers
            // and returning them by type (including custom managers). Also acts as a component
            // container where calls to manager methods on the SceneInterface (such as BeginFrameRendering,
            // Unload, ...) are automatically called on all contained managers.
            //
            // This design allows managers to be plugged-in like modular components and for managers
            // to easily be added, removed, or replaced with custom implementations.
            //
            sceneInterface = new SceneInterface();
            sceneInterface.CreateDefaultManagers(RenderingSystemType.Forward, CollisionSystemType.Physics, true);

            BaseGameProgram.Instance.OnInitializeSceneInterface(sceneInterface);

            // Create the frame buffers used for rendering (sized to the backbuffer) and
            // assign them to the ResourceManager so we don't have to worry about cleanup.
            frameBuffers = new FrameBuffers(DetailPreference.High, DetailPreference.High);
            sceneInterface.ResourceManager.AssignOwnership(frameBuffers);
        }
Example #13
0
        /// <summary>
        /// 
        /// </summary>
        protected Game_cl()
            : base()
        {
            mGraphics = new GraphicsDeviceManager(this);

            Content.RootDirectory = "Content";

            // Required for lighting system.
            Components.Add(new SplashScreenGameComponent(this, mGraphics));

            // Create the lighting system.
            mLightingSystemManager = new LightingSystemManager(Services, Content);

            mSceneState = new SceneState();
            mEnvironment = new SceneEnvironment();

            mSceneInterface = new SceneInterface(mGraphics);
            mSceneInterface.CreateDefaultManagers(false);
            mSceneInterface.AddManager(new ObjectManager_cl());

            // Create the sprite manager used to create and organize sprite containers for 2D rendering.
            mSpriteManager = new SpriteManager(mGraphics);
            mSceneInterface.AddManager(mSpriteManager);

            mFrameBuffers = new FrameBuffers(mGraphics, DetailPreference.Low, DetailPreference.Low);
            mSceneInterface.ResourceManager.AssignOwnership(mFrameBuffers);
            mStaticSceneEffects = new List<SceneEffect>();

            //mView = Matrix.CreateLookAt(Vector3.Zero, Vector3.Forward, Vector3.Up);
            //mProjection = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver2, GraphicsDevice.Viewport.AspectRatio, 0.1f, 1000f);

            mCameraEntity = new Entity_cl();

            #if WORLD_EDITOR
            mWorldEditor = new WorldEditor_cl();
            #endif

            mManagers = new List<BaseManager_cl>();
            mRandom = new Random();
            mTimer = new FNA.Core.Timer_cl();

            mBaseInstance = this;
            mIsPlayingGame = true;
        }
Example #14
0
        public StarterGame()
        {
            // Default XNA setup.
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            // Required for lighting system.
            graphics.PreferredDepthStencilFormat = DepthFormat.Depth24Stencil8;

            // Required for lighting system.
            splashScreenGameComponent = new SplashScreenGameComponent(this);
            Components.Add(splashScreenGameComponent);

            // Create the lighting system.
            sunBurnCoreSystem = new SunBurnCoreSystem(Services, Content);
            sceneState = new SceneState();

            // Create the scene interface. Acts as a service provider containing all scene managers
            // and returning them by type (including custom managers). Also acts as a component
            // container where calls to manager methods on the SceneInterface (such as BeginFrameRendering,
            // Unload, ...) are automatically called on all contained managers.
            //
            // This design allows managers to be plugged-in like modular components and for managers
            // to easily be added, removed, or replaced with custom implementations.
            //
            SceneInterface = new SceneInterface();
            SceneInterface.CreateDefaultManagers(RenderingSystemType.Forward, CollisionSystemType.Physics, true);

            SpriteManager = new SpriteManager(SceneInterface);
            SceneInterface.AddManager(SpriteManager);

            // Create the frame buffers used for rendering (sized to the backbuffer) and
            // assign them to the ResourceManager so we don't have to worry about cleanup.
            frameBuffers = new FrameBuffers(DetailPreference.High, DetailPreference.Medium);
            SceneInterface.ResourceManager.AssignOwnership(frameBuffers);

            physicsManager.RegisterPhysicsBody(Character);
            collisionManager.RegisterCollisionBody(Character);

            // Post console messages letting the user know how to open the SunBurn Editor.
            SceneInterface.ShowConsole = true;
            SystemConsole.AddMessage("Welcome to the SunBurn Engine.", 4);
            SystemConsole.AddMessage("Use an Xbox controller or the W, A, S, D keys to navigate the scene.", 8);
            SystemConsole.AddMessage("Press F11 to open the SunBurn Editor.", 12);
        }
Example #15
0
 /// <summary>
 /// Initializes the Camera and SunBurn SceneState to be used for rendering
 /// </summary>
 /// <param name="gameTime"/>
 /// <param name="frameBuffers"/>
 public void BeginFrameRendering(GameTime gameTime, FrameBuffers frameBuffers)
 {
     SceneState.BeginFrameRendering(ViewMatrix, ProjectionMatrix, gameTime, SceneEnvironment, frameBuffers, true);
 }
Example #16
0
        /// <summary>
        /// Constructs a new screen manager component.
        /// </summary>
        public ScreenManager(Game game)
            : base(game)
        {
            // we must set EnabledGestures before we can query for them, but
            // we don't assume the game wants to read them.
            TouchPanel.EnabledGestures = GestureType.None;

            // Create the lighting system.
            sunBurnCoreSystem = new SunBurnCoreSystem(game.Services, game.Content);
            sceneState = new SceneState();

            // Create the scene interface. Acts as a service provider containing all scene managers
            // and returning them by type (including custom managers). Also acts as a component
            // container where calls to manager methods on the SceneInterface (such as BeginFrameRendering,
            // Unload, ...) are automatically called on all contained managers.
            //
            // This design allows managers to be plugged-in like modular components and for managers
            // to easily be added, removed, or replaced with custom implementations.
            //
            sceneInterface = new SceneInterface();
            sceneInterface.CreateDefaultManagers(RenderingSystemType.Forward, CollisionSystemType.Physics, true);

            // Create the frame buffers used for rendering (sized to the backbuffer) and
            // assign them to the ResourceManager so we don't have to worry about cleanup.
            frameBuffers = new FrameBuffers(DetailPreference.High, DetailPreference.Medium);
            sceneInterface.ResourceManager.AssignOwnership(frameBuffers);

            // Post console messages letting the user know how to open the SunBurn Editor.
            sceneInterface.ShowConsole = true;
            SystemConsole.AddMessage("Welcome to the SunBurn Engine.", 4);
            SystemConsole.AddMessage("Use an Xbox controller or the W, A, S, D keys to navigate the scene.", 8);
            SystemConsole.AddMessage("Press F11 to open the SunBurn Editor.", 12);
        }
Example #17
0
 /// <summary>
 /// Initializes the Camera and SunBurn SceneState to be used for rendering
 /// </summary>
 /// <param name="gameTime"/>
 /// <param name="frameBuffers"/>
 public void BeginFrameRendering(GameTime gameTime, FrameBuffers frameBuffers)
 {
     SceneState.BeginFrameRendering(Position, Distance, AspectRatio, gameTime, SceneEnvironment, frameBuffers,
                                    true);
 }
Example #18
0
 /// <summary>
 /// Initializes the Camera and SunBurn SceneState to be used for rendering
 /// </summary>
 /// <param name="gameTime"/>
 /// <param name="frameBuffers"/>
 public void BeginFrameRendering(GameTime gameTime, FrameBuffers frameBuffers)
 {
     SceneState.BeginFrameRendering(Position, Distance, AspectRatio, gameTime, SceneEnvironment, frameBuffers,
                                    true);
 }
Example #19
0
 /// <summary>
 /// Initializes the Camera and SunBurn SceneState to be used for rendering
 /// </summary>
 /// <param name="gameTime"/>
 /// <param name="frameBuffers"/>
 public void BeginFrameRendering(GameTime gameTime, FrameBuffers frameBuffers)
 {
     SceneState.BeginFrameRendering(ViewMatrix, ProjectionMatrix, gameTime, SceneEnvironment, frameBuffers, true);
 }