Exemplo n.º 1
0
 public void Dispose()
 {
     FX.Dispose();
     foreach (var vGeo in geos)
     {
         vGeo.Dispose();
     }
     VoxelMap.Dispose();
 }
Exemplo n.º 2
0
        internal static void Draw(SpriteBatch spriteBatch)
        {
            if (postProcessing != null)
            {
                // Initialize a RenderTarget2D to accumulate all RenderTargets.
                RenderTarget2D accumulation = new RenderTarget2D(spriteBatch.GraphicsDevice, WindowManager.WindowWidth, WindowManager.WindowHeight);

                // Setup the GraphicsDevice with the new accumulation RenderTarget2D.
                spriteBatch.GraphicsDevice.SetRenderTarget(accumulation);
                spriteBatch.GraphicsDevice.Clear(Color.Transparent);

                // Draw all the saved RenderTargets onto the accumulation RenderTarget2D.
                spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, null);
                {
                    for (int i = 0; i < renderTargets.Count; i++)
                    {
                        spriteBatch.Draw(renderTargets[i], Vector2.Zero, Color.White);
                    }
                }
                spriteBatch.End();

                // Reset the GraphicsDevice's RenderTarget.
                spriteBatch.GraphicsDevice.SetRenderTarget(null);
                spriteBatch.GraphicsDevice.Clear(Color.Transparent);

                // Apply the shader.
                spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, postProcessing.Effect, null);
                {
                    spriteBatch.Draw(accumulation, Vector2.Zero, Color.White);
                }
                spriteBatch.End();

                // Dispose of all RenderTargets.
                accumulation.Dispose();
                for (int i = 0; i < renderTargets.Count; i++)
                {
                    renderTargets[i].Dispose();
                }
                renderTargets.Clear();

                // Dispose of shader.
                postProcessing.Dispose();
                postProcessing = null;
            }
            else
            {
                // Draw all the saved RenderTargets.
                spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, null);
                {
                    for (int i = 0; i < renderTargets.Count; i++)
                    {
                        spriteBatch.Draw(renderTargets[i], Vector2.Zero, Color.White);
                        //spriteBatch.Draw(
                        //    renderTargets[i],
                        //    new Vector2(WindowManager.WindowWidth / 2, WindowManager.WindowHeight / 2),
                        //    new Microsoft.Xna.Framework.Rectangle(0, 0, WindowManager.WindowWidth, WindowManager.WindowHeight),
                        //    Color.White,
                        //    0,
                        //    new Vector2(WindowManager.WindowWidth / 2, WindowManager.WindowHeight / 2),
                        //    1,
                        //    SpriteEffects.None,
                        //    0
                        //    );
                    }
                }
                spriteBatch.End();
            }

            // Dispose of all RenderTargets.
            for (int i = 0; i < renderTargets.Count; i++)
            {
                renderTargets[i].Dispose();
            }
            renderTargets.Clear();
        }