Exemplo n.º 1
0
        public void ReplaceRenderStates(SpriteSortMode sortMode, BlendState blendState, SamplerState samplerState,
                                        DepthStencilState depthStencilState, RasterizerState rasterizerState, Effect effect, Matrix transformMatrix,
                                        Rectangle scissorRectangle)
        {
            bool isNewRender = currentParameters.HasValue == false;

            var newParameters = new BeginParameters();

            newParameters.ChangeRecord = StateChangeInfoListPool.GetNextAvailable();
            newParameters.ChangeRecord.Clear();

            newParameters.SortMode          = sortMode;
            newParameters.BlendState        = blendState;
            newParameters.SamplerState      = samplerState;
            newParameters.DepthStencilState = depthStencilState;
            newParameters.RasterizerState   = rasterizerState;
            newParameters.Effect            = effect;
            newParameters.TransformMatrix   = transformMatrix;

            try
            {
                newParameters.ScissorRectangle = scissorRectangle;
            }
            catch (Exception e)
            {
                throw new Exception("Could not set scissor rectangle to:" + scissorRectangle.ToString(), e);
            }
            if (currentParameters != null)
            {
                beginParametersUsedThisFrame.Add(currentParameters.Value);
            }

            currentParameters = newParameters;

            if (beginEndState == SpriteBatchBeginEndState.Began)
            {
                SpriteBatch.End();
            }

            try
            {
                SpriteBatch.GraphicsDevice.ScissorRectangle = scissorRectangle;
            }
            catch (Exception e)
            {
                throw new Exception("Error trying to set scissor rectangle:" + scissorRectangle.ToString());
            }
            beginEndState = SpriteBatchBeginEndState.Began;
            SpriteBatch.Begin(sortMode,
                              blendState,
                              samplerState, depthStencilState, rasterizerState, effect, transformMatrix);
        }
Exemplo n.º 2
0
        public void Begin()
        {
            var beginParams = new BeginParameters();

            beginParams.ChangeRecord = new List <StateChangeInfo>();

            beginParams.IsDefault = true;
            currentParameters     = beginParams;

            if (beginEndState == SpriteBatchBeginEndState.Began)
            {
                SpriteBatch.End();
            }

            beginEndState = SpriteBatchBeginEndState.Began;
            SpriteBatch.Begin();
        }
Exemplo n.º 3
0
        public void Begin()
        {
            var beginParams = new BeginParameters();

            beginParams.ChangeRecord = StateChangeInfoListPool.GetNextAvailable();
            beginParams.ChangeRecord.Clear();

            beginParams.IsDefault = true;
            currentParameters     = beginParams;

            if (beginEndState == SpriteBatchBeginEndState.Began)
            {
                SpriteBatch.End();
            }

            beginEndState = SpriteBatchBeginEndState.Began;
            SpriteBatch.Begin();
        }
Exemplo n.º 4
0
        internal void End()
        {
            if (currentParameters != null)
            {
                RecordCurrentParameters();

                if (beginEndState == SpriteBatchBeginEndState.Began)
                {
                    SpriteBatch.End();
                    beginEndState = SpriteBatchBeginEndState.Ended;
                }
            }
            else
            {
                if (beginEndState == SpriteBatchBeginEndState.Began)
                {
                    SpriteBatch.End();
                    beginEndState = SpriteBatchBeginEndState.Ended;
                }
            }
        }
Exemplo n.º 5
0
        internal void End()
        {

            if (currentParameters != null)
            {
                RecordCurrentParameters();

                if (beginEndState == SpriteBatchBeginEndState.Began)
                {
                    SpriteBatch.End();
                    beginEndState = SpriteBatchBeginEndState.Ended;
                }
            }
            else
            {

                if (beginEndState == SpriteBatchBeginEndState.Began)
                {
                    SpriteBatch.End();
                    beginEndState = SpriteBatchBeginEndState.Ended;

                }
            }
        }
Exemplo n.º 6
0
        public void ReplaceRenderStates(SpriteSortMode sortMode, BlendState blendState, SamplerState samplerState,
            DepthStencilState depthStencilState, RasterizerState rasterizerState, Effect effect, Matrix transformMatrix,
            Rectangle scissorRectangle)
        {
            bool isNewRender = currentParameters.HasValue == false;

            var newParameters = new BeginParameters();
            newParameters.ChangeRecord = new List<StateChangeInfo>();

            newParameters.SortMode = sortMode;
            newParameters.BlendState = blendState;
            newParameters.SamplerState = samplerState;
            newParameters.DepthStencilState = depthStencilState;
            newParameters.RasterizerState = rasterizerState;
            newParameters.Effect = effect;
            newParameters.TransformMatrix = transformMatrix;

            try
            {
                newParameters.ScissorRectangle = scissorRectangle;
            }
            catch(Exception e)
            {
                throw new Exception("Could not set scissor rectangle to:" + scissorRectangle.ToString(), e);
            }
            if (currentParameters != null)
            {
                beginParametersUsedThisFrame.Add(currentParameters.Value);
            }

            currentParameters = newParameters;

            if (beginEndState == SpriteBatchBeginEndState.Began)
            {
                SpriteBatch.End();
            }

            try
            {
                SpriteBatch.GraphicsDevice.ScissorRectangle = scissorRectangle;
            }
            catch(Exception e)
            {
                throw new Exception("Error trying to set scissor rectangle:" + scissorRectangle.ToString());
            }
            beginEndState = SpriteBatchBeginEndState.Began;
            SpriteBatch.Begin(sortMode, blendState, samplerState, depthStencilState, rasterizerState, effect, transformMatrix);

        }
Exemplo n.º 7
0
        public void Begin()
        {
            var beginParams = new BeginParameters();
            beginParams.ChangeRecord = new List<StateChangeInfo>();

            beginParams.IsDefault = true;
            currentParameters = beginParams;

            if (beginEndState == SpriteBatchBeginEndState.Began)
            {
                SpriteBatch.End();
            }

            beginEndState = SpriteBatchBeginEndState.Began;
            SpriteBatch.Begin();
        }