Exemplo n.º 1
0
        private void Prepare(DrawState nextState)
        {
            if (this.currState == nextState)
            {
                return;
            }

            Flush();

            switch (nextState)
            {
            case DrawState.None: break;

            case DrawState.Geometry: break;

            case DrawState.Sprite:
                RasterizerState rasterizer = isClipped ? this.clippingRasterizeState : null;
                spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, SamplerState.LinearClamp, DepthStencilState.None, rasterizer, effect: currentActiveEffect);
                break;

            case DrawState.D2D:
                d2dRenderer.Begin();
                if (isClipped)
                {
                    d2dRenderer.PushClip(this.GraphicsDevice.ScissorRectangle);
                }
                break;
            }

            this.currState = nextState;
        }
Exemplo n.º 2
0
        protected override void Draw()
        {
            base.Draw();

            if (this.ShowInfo && this.XnaFont != null)
            {
                UpdateInfoText();
                sprite.Begin();
                sprite.DrawStringEx(this.XnaFont, this.sbInfo, Vector2.Zero, Color.Black);
                sprite.End();
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Begins the rendering with custom effect
        /// </summary>
        /// <param name="effect">The effect.</param>
        public override void Begin(EffectBase effect)
        {
            isClipped = false;
            isSpriteRenderInProgress = true;
            UpdateCurrentEffect(effect);
            if (previousState != null)
            {
                spriteBatch.GraphicsDevice.RasterizerState = previousState;
                previousState = null;
            }

            if (clipRectanges.Count == 0)
            {
                spriteBatch.Begin(blendState: BlendState.NonPremultiplied, effect: currentActiveEffect);
            }
            else
            {
                Rectangle previousClip = clipRectanges.Pop();
                BeginClipped(previousClip);
            }
        }