/// <summary> /// This is called when the game should draw itself. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue); RenderTarget2D render = new RenderTarget2D(GraphicsDevice, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight); RenderTarget2D render1 = new RenderTarget2D(GraphicsDevice, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight); GraphicsDevice.SetRenderTarget(render); //spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.None, RasterizerState.CullCounterClockwise, TextureLoader.Std); spriteBatch.Begin(); switch (GameState.getState()) { case "Menu": menu.Draw(spriteBatch, render); break; case "Game": core.Draw(spriteBatch, render); break; } spriteBatch.End(); GraphicsDevice.SetRenderTarget(render1); spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Opaque, SamplerState.LinearClamp, DepthStencilState.None, RasterizerState.CullCounterClockwise, TextureLoader.Std); spriteBatch.Draw(render, new Vector2(0, 0), Color.White); spriteBatch.End(); GraphicsDevice.SetRenderTarget(null); TextureLoader.Bloom.Parameters[0].SetValue(render1); spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Opaque, SamplerState.LinearClamp, DepthStencilState.None, RasterizerState.CullCounterClockwise, TextureLoader.Bloom); spriteBatch.Draw(render1, new Vector2(0, 0), Color.White); spriteBatch.End(); render.Dispose(); render1.Dispose(); base.Draw(gameTime); }
/// <summary> /// This is called when the game should draw itself. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue); if (GameState.getState() == "Menu" && menu != null) { spriteBatch.Begin(); menu.Draw(spriteBatch); spriteBatch.End(); } else if (GameState.getState() == "Game" && core != null) { core.Draw(spriteBatch); } base.Draw(gameTime); }