/// <summary> /// Requests that each screen drawable component render. /// </summary> /// <param name="gameTime">The game time.</param> /// <param name="spriteBatch">The <see cref="ScreenSpriteBatch"/> to render with.</param> internal void DrawScreenDrawableComponents(GameTime gameTime, ScreenSpriteBatch spriteBatch) { foreach (var curr in this.screenDrawableComponents) { curr.Draw(gameTime, spriteBatch); } }
/// <summary> /// Called when the <see cref="SpriteBase"/> components need to be drawn. Override this method with component-specific drawing code. /// </summary> /// <remarks> /// You should never call this function; it is called by XNA. /// </remarks> /// <param name="gameTime">Time passed since the last call to Draw.</param> public override void Draw(GameTime gameTime) { // Get the items that need rendering var spritesToDraw = this.gameWorld.GetSpriteObjectsInArea(this.GetCameraRenderBounds()).OrderBy(s => s.LayerDepth); if (!this.disablePostProcesses) { // Render options map this.GraphicsDevice.SetRenderTarget(this.renderTargets.OptionsMap); // Set the correct render target this.GraphicsDevice.Clear(Color.Transparent); // Initialize the render target this.gameWorld.DrawSpriteOptions(spritesToDraw, gameTime, this); // Render on options map this.spriteBatch.End(); this.GraphicsDevice.SetRenderTarget(null); // Resolve the render target } // Render color map this.GraphicsDevice.SetRenderTarget(this.renderTargets.ColorMap); // Set the correct render target this.GraphicsDevice.Clear(Color.Transparent); // Initialize the render target this.gameWorld.DrawSpriteColor(spritesToDraw, gameTime, this); // Render on color map this.spriteBatch.End(); this.GraphicsDevice.SetRenderTarget(null); // Resolve the render target if (!this.disablePostProcesses) { // Render normal map this.GraphicsDevice.SetRenderTarget(this.renderTargets.NormalMap); // Set the correct render target this.GraphicsDevice.Clear(Color.Transparent); // Initialize the render target this.gameWorld.DrawSpriteNormal(spritesToDraw, gameTime, this); // Render on normal map this.spriteBatch.End(); this.GraphicsDevice.SetRenderTarget(null); // Resolve the render target // Render lighting and post-processing effects this.GraphicsDevice.SetRenderTarget(this.renderTargets.LightMap); // Set the correct render target this.GraphicsDevice.Clear(Color.Transparent); // Initialize the render target this.GraphicsDevice.SetRenderTarget(null); // Resolve the render target this.RenderPostProcesses(gameTime); // Render post processing effects this.GraphicsDevice.SetRenderTarget(null); // Resolve the render target } else { this.GraphicsDevice.SetRenderTarget(this.renderTargets.LightMap); // Set the correct render target this.GraphicsDevice.Clear(Color.White); // Initialize the render target this.GraphicsDevice.SetRenderTarget(null); // Resolve the render target } // Merge render targets this.GraphicsDevice.Clear(Color.Transparent); this.mergeRenderTargets.ConfigureShader(this); this.mergeRenderTargets.ApplyPass(0); this.DirectScreenPaint(); // TODO: Draw any non-lit textures var rsdSpriteBatch = new ScreenSpriteBatch(this); rsdSpriteBatch.Begin(); this.gameWorld.DrawScreenDrawableComponents(gameTime, rsdSpriteBatch); rsdSpriteBatch.End(); base.Draw(gameTime); }
/// <summary> /// Called by the <see cref="DeferredRenderSystem"/> when this <see cref="ScreenDrawableComponent"/> /// component needs to draw. /// Override this method with component-specific drawing code. /// </summary> /// <param name="gameTime">Time passed since the last call to DrawColorMap.</param> /// <param name="spriteBatch"><see cref="ScreenSpriteBatch"/> to render with.</param> public abstract void Draw(GameTime gameTime, ScreenSpriteBatch spriteBatch);