private void SetGraphicsState(GraphicsState state) { switch (state.SamplerState) { case SamplerState.PointWrap: GraphicsDevice.SamplerStates[0] = Microsoft.Xna.Framework.Graphics.SamplerState.PointWrap; break; case SamplerState.PointClamp: GraphicsDevice.SamplerStates[0] = Microsoft.Xna.Framework.Graphics.SamplerState.PointClamp; break; case SamplerState.LinearWrap: GraphicsDevice.SamplerStates[0] = Microsoft.Xna.Framework.Graphics.SamplerState.LinearWrap; break; case SamplerState.LinearClamp: GraphicsDevice.SamplerStates[0] = Microsoft.Xna.Framework.Graphics.SamplerState.LinearClamp; break; case SamplerState.AnisotropicWrap: GraphicsDevice.SamplerStates[0] = Microsoft.Xna.Framework.Graphics.SamplerState.AnisotropicWrap; break; case SamplerState.AnisotropicClamp: GraphicsDevice.SamplerStates[0] = Microsoft.Xna.Framework.Graphics.SamplerState.AnisotropicClamp; break; default: throw new ArgumentOutOfRangeException(); } switch (state.BlendState) { case BlendState.AlphaBlend: GraphicsDevice.BlendState = Microsoft.Xna.Framework.Graphics.BlendState.AlphaBlend; break; case BlendState.Opaque: GraphicsDevice.BlendState = Microsoft.Xna.Framework.Graphics.BlendState.Opaque; break; default: throw new ArgumentOutOfRangeException(); } GraphicsDevice.RasterizerState = (state.UseScissorRect) ? Scissor : NoScissor; if (state.UseScissorRect) { GraphicsDevice.ScissorRectangle = state.ScissorRect.ToMg(); } if (state.Texture == -1) { throw new InvalidOperationException("An attempt was made to render a polygon without a texture."); } _effect.Alpha = 1f; _effect.FogEnabled = false; _effect.LightingEnabled = false; _effect.Projection = Matrix.CreateOrthographicOffCenter(GraphicsDevice.Viewport.Bounds, GraphicsDevice.Viewport.MinDepth, GraphicsDevice.Viewport.MaxDepth); _effect.View = Matrix.Identity; _effect.World = Matrix.Identity; _effect.TextureEnabled = true; _effect.Texture = _textures[state.Texture]; _effect.VertexColorEnabled = true; _prevState = state; }