Cascade.Game1.Draw C# (CSharp) Метод

Draw() защищенный Метод

This is called when the game should draw itself.
protected Draw ( GameTime gameTime ) : void
gameTime Microsoft.Xna.Framework.GameTime Provides a snapshot of timing values.
Результат void
        protected override void Draw(GameTime gameTime)
        {

            
            GraphicsDevice.SetRenderTarget(depthTarget);
            GraphicsDevice.Clear(Color.Red);

            GraphicsDevice.SetRenderTarget(colorTarget);
            GraphicsDevice.Clear(Color.Transparent);

            GraphicsDevice.SetRenderTargets(colorTarget, depthTarget);

            //GraphicsDevice.Clear(Color.Black);
            RasterizerState rast = new RasterizerState()
            {
                CullMode = CullMode.None,
                FillMode = FillMode.Solid,
                DepthBias = 0
            };
            DepthStencilState depth = new DepthStencilState()
            {
                DepthBufferEnable = true,
                DepthBufferWriteEnable = false
            };
            GraphicsDevice.DepthStencilState = DepthStencilState.None;
            GraphicsDevice.RasterizerState = rast;

            //Set matrices for panels
            Global.Effect.View = Matrix.CreateTranslation(0, 0, 0);
            Global.Effect.Projection = Matrix.CreateOrthographicOffCenter(0, 1280, 720, 0, 0, 1);
            Global.Effect.World = Matrix.CreateTranslation(0, 0, 0);
            Global.Effect.Alpha = 1;
            Global.Effect.CurrentTechnique.Passes[0].Apply();
            Global.Effect.Parameters["depth"].SetValue(0);
            //panelManager.Draw(GraphicsDevice, graphics, spriteBatch, null, 1280, 720);

            //Set matrices for particles
            Global.Effect.View = Matrix.CreateTranslation(0, 0, 0);
           // Global.Effect.Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45), 16f / 9f, 1, 1000000);
            Global.Effect.World = Matrix.CreateTranslation(0, 0, 0);
           
            Global.ParticleManager.Draw(GraphicsDevice, graphics, spriteBatch, colorTarget, Global.ScreenSize.X, Global.ScreenSize.Y);

            //sprite batch stuff
            GraphicsDevice.BlendState = BlendState.AlphaBlend;
            GraphicsDevice.SetRenderTarget(finalTarget);
            GraphicsDevice.Clear(new Color(170, 220, 240));
            //Global.SpriteEffect.Parameters["depthTexture"].SetValue(depthTarget);
            Matrix sbMatrix = Matrix.CreateOrthographicOffCenter(0, Global.ScreenSize.X, Global.ScreenSize.Y, 0, 0, 1);
            Global.SpriteEffect.Parameters["MatrixTransform"].SetValue(sbMatrix);
            Global.Effect.World = Matrix.CreateTranslation(Vector3.Zero);
            Global.Effect.Alpha = 1;
            GraphicsDevice.RasterizerState = RasterizerState.CullNone;
            Global.Effect.Color = Color.White;
            foreach (var pass in Global.Effect.CurrentTechnique.Passes)
            {
                pass.Apply();
                //spriteBatch.Draw(colorTarget, new Rectangle(0, 0, (int)Global.ScreenSize.X, (int)Global.ScreenSize.Y), Color.White);
                for (int i = 0; i < MusicManager.PanelManagers.Count; i++)
                {
                    MusicManager.PanelManagers[i].Draw(GraphicsDevice, graphics, spriteBatch, null, 1280, 720);
                }
            }

            spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, null, null, null);
            Global.SpriteEffect.SetTechnique("Normal");
            foreach (var pass in Global.SpriteEffect.CurrentTechnique.Passes)
            {
                pass.Apply();
                spriteBatch.Draw(colorTarget, new Rectangle(0, 0, (int)Global.ScreenSize.X, (int)Global.ScreenSize.Y), Color.White);
            }
            
            

            GraphicsDevice.SetRenderTarget(null);
            GraphicsDevice.Clear(Color.Black);
            Global.SpriteEffect.SetTechnique("Normal");
            foreach (var pass in Global.SpriteEffect.CurrentTechnique.Passes)
            {
                pass.Apply();
                spriteBatch.Draw(finalTarget, new Rectangle(0, 0, (int)Global.ScreenSize.X, (int)Global.ScreenSize.Y), Color.White);
                float y = 0;
                Vector2 size = Fonts.Output.MeasureString(Global.Output);
                if (size.Y > 500)
                    y = -(size.Y - 500);
                spriteBatch.DrawString(Fonts.Output, Global.Output, new Vector2(0, y), Color.Black);
            }
            

            
            spriteBatch.End();

            base.Draw(gameTime);
        }
    }