Esempio n. 1
0
        // draws the currently active screen
        public void Draw(GraphicsDevice gd)
        {
            if (gd == null)
            {
                throw new ArgumentNullException("gd");
            }

            frameRateCount++;

            // if a valid current screen is set
            if (current != null)
            {
                // set the color render target
                gd.SetRenderTarget(colorRT);

                // draw the screen 3D scene
                current.Draw3D(gd);

                // resolve the color render target
                gd.SetRenderTarget(null);

                // blur the glow render target
                //BlurGlowRenterTarget(gd);

                // draw the 3D scene texture
                DrawRenderTargetTexture(gd, colorRT, 1.0f, false);

                // draw the glow texture with additive blending
                DrawRenderTargetTexture(gd, glowRT2, 2.0f, true);

                // begin text mode
                fontManager.BeginText();

                // draw the 2D scene
                current.Draw2D(gd, fontManager);

                // draw fps
                //fontManager.DrawText(
                //    FontType.ArialSmall,
                //    "FPS: " + frameRate,
                //    new Vector2(gd.Viewport.Width - 80, 0), Color.White);

                // end text mode
                fontManager.EndText();
            }

            // if in a transition
            if (fade > 0)
            {
                // compute transtition fade intensity
                float size = fadeTime * 0.5f;
                fadeColor.W = 1.25f * (1.0f - Math.Abs(fade - size) / size);

                // set alpha blend and no depth test or write
                gd.DepthStencilState = DepthStencilState.None;
                gd.BlendState        = BlendState.AlphaBlend;

                // draw transition fade color
                blurManager.RenderScreenQuad(gd, BlurTechnique.Color, null, fadeColor);

                // restore render states
                gd.DepthStencilState = DepthStencilState.Default;
                gd.BlendState        = BlendState.Opaque;
            }
        }