Пример #1
0
            /// <summary>
            /// クリップを開始します。
            /// </summary>
            /// <param name="scissorRectangle">ScissorRectangle。</param>
            /// <param name="inherite">
            /// true (既存のクリップ領域のサブセットとして用いる場合)、
            /// false (指定のクリップ領域をそのまま用いる場合)。
            /// </param>
            /// <param name="spriteBatchActive">
            /// true (SpriteBatch がアクティブな場合)、false (それ以外の場合)。
            /// </param>
            public void Begin(ref Rectangle scissorRectangle, bool inherite, bool spriteBatchActive)
            {
                this.spriteBatchActive = spriteBatchActive;

                var spriteBatch    = uiManager.spriteBatch;
                var graphicsDevice = spriteBatch.GraphicsDevice;

                // これまでの SpriteBatch を一旦終えます。
                if (spriteBatchActive)
                {
                    uiManager.EndSpriteBetch();
                }

                // これまでの ScissorRectangle をスタックへ退避させます。
                var previousScissorRectangle = graphicsDevice.ScissorRectangle;

                scissorRectangleStack.Push(previousScissorRectangle);

                // Viewport からはみ出ないように調整します (はみ出ると例外が発生します)。
                var       viewportBounds = graphicsDevice.Viewport.Bounds;
                Rectangle viewIntersectBounds;

                Rectangle.Intersect(ref viewportBounds, ref scissorRectangle, out viewIntersectBounds);

                Rectangle finalScissorRectangle;

                if (inherite)
                {
                    // 親の ScissorRectangle を考慮した領域を計算します。
                    Rectangle.Intersect(ref viewIntersectBounds, ref previousScissorRectangle, out finalScissorRectangle);
                }
                else
                {
                    // 親の ScissorRectangle を考慮しません。
                    finalScissorRectangle = viewIntersectBounds;
                }

                // サイズを持つ場合にだけ設定するようにします。
                if (0 < finalScissorRectangle.Width && 0 < finalScissorRectangle.Height)
                {
                    graphicsDevice.ScissorRectangle = finalScissorRectangle;
                }

                // 設定された ScissorRectangle で SpriteBatch を再開します。
                if (spriteBatchActive)
                {
                    uiManager.BeingSpriteBatch();
                }
            }
Пример #2
0
            public void End()
            {
                // SpriteBatch を再開します。
                uiManager.BeingSpriteBatch();

                Active = false;
            }
Пример #3
0
 // I/F
 public void Flush()
 {
     uiManager.EndSpriteBetch();
     uiManager.BeingSpriteBatch();
 }