Exemple #1
0
        static BlendState()
        {
            Additive = new BlendState()
            {
                ColorSourceBlend = Blend.SourceAlpha,
                AlphaSourceBlend = Blend.SourceAlpha,
                ColorDestinationBlend = Blend.One,
                AlphaDestinationBlend = Blend.One
            };

            AlphaBlend = new BlendState()
            {
                ColorSourceBlend = Blend.One,
                AlphaSourceBlend = Blend.One,
                ColorDestinationBlend = Blend.InverseSourceAlpha,
                AlphaDestinationBlend = Blend.InverseSourceAlpha
            };

            NonPremultiplied = new BlendState()
            {
                ColorSourceBlend = Blend.SourceAlpha,
                AlphaSourceBlend = Blend.SourceAlpha,
                ColorDestinationBlend = Blend.InverseSourceAlpha,
                AlphaDestinationBlend = Blend.InverseSourceAlpha
            };

            Opaque = new BlendState()
            {
                ColorSourceBlend = Blend.One,
                AlphaSourceBlend = Blend.One,
                ColorDestinationBlend = Blend.Zero,
                AlphaDestinationBlend = Blend.Zero
            };
        }
Exemple #2
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            BlendState  = BlendState.New(GraphicsDevice, BlendOption.SourceAlpha, BlendOption.InverseSourceAlpha, BlendOperation.Add, BlendOption.One, BlendOption.InverseSourceAlpha, BlendOperation.Add);

            DrawHelper.Load(this);

            Window.ClientSizeChanged += Window_ClientSizeChanged;

            screenManager.Resize(Viewport.Width, Viewport.Height);
            //screenManager.CloseAllAndThenOpen(new WorldScreen(screenManager));
            screenManager.CloseAllAndThenOpen(new EditorScreen(screenManager));
        }
Exemple #3
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            BlendState = BlendState.New(GraphicsDevice, BlendOption.SourceAlpha, BlendOption.InverseSourceAlpha, BlendOperation.Add, BlendOption.One, BlendOption.InverseSourceAlpha, BlendOperation.Add);

            DrawHelper.Load(this);

            Window.ClientSizeChanged += Window_ClientSizeChanged;

            screenManager.Resize(Viewport.Width, Viewport.Height);
            //screenManager.CloseAllAndThenOpen(new WorldScreen(screenManager));
            screenManager.CloseAllAndThenOpen(new EditorScreen(screenManager));
        }
Exemple #4
0
        public void Clear()
        {
            if (clearBlendState == null)
            {
                BlendStateDescription desc = new BlendStateDescription();
                desc.RenderTarget[0].IsBlendEnabled = false;
                desc.RenderTarget[1].IsBlendEnabled = false;
                desc.RenderTarget[2].IsBlendEnabled = false;

                clearBlendState = context.Device.BlendStates.Opaque; // SharpDX.Toolkit.Graphics.BlendState.New(context.Device, desc);
            }

            context.Device.SetVertexBuffer(vb);
            context.Device.SetVertexInputLayout(VertexInputLayout.FromBuffer(0, vb));
            context.Device.SetDepthStencilState(context.Device.DepthStencilStates.None);
            context.Device.SetBlendState(clearBlendState);
            context.Device.SetRasterizerState(context.Device.RasterizerStates.CullNone);
            gbufferEffect.Techniques["Clear"].Passes[0].Apply();
            context.Device.Draw(PrimitiveType.TriangleList, 6);
        }
Exemple #5
0
        public DX11GUI(SharpDX.DXGI.SwapChain _swapChain)
        {
            try
            {
                Device device = _swapChain.GetDevice <Device>();
                graphics = GraphicsDevice.New(device);
                sprb     = new SpriteBatch(graphics);

                blState = SharpDX.Toolkit.Graphics.BlendState.New(
                    graphics,
                    BlendOption.SourceAlpha,
                    BlendOption.InverseSourceAlpha,
                    BlendOperation.Add,
                    BlendOption.One,
                    BlendOption.Zero,
                    BlendOperation.Add);
            }
            catch (Exception ex)
            {
                initcrash = true;
                Core.Log("DX11 GUI initcrash: " + ex.Message);
            }
        }
        protected override void LoadContent()
        {
            myFont = Content.Load<SpriteFont>(contentPath + "Arial16.tkfnt");

            pointerTexture = Content.Load<Texture2D>(contentPath + "pointer.png");

            mySpriteBatch = new SpriteBatch(GraphicsDevice);

            blendStateDescription.AlphaToCoverageEnable = true;
            blendState = BlendState.New(GraphicsDevice, blendStateDescription, Color.White, multiSampleMask);

            base.LoadContent();
        }
 /// <summary>
 /// Begins a sprite batch rendering using the specified sorting mode and blend state, sampler, depth stencil and rasterizer state objects, plus a custom effect. Passing null for any of the state objects selects the default default state objects (BlendState.AlphaBlend, DepthStencilState.None, RasterizerState.CullCounterClockwise, SamplerState.LinearClamp). Passing a null effect selects the default SpriteBatch Class shader.
 /// </summary>
 /// <param name="sortMode">Sprite drawing order.</param>
 /// <param name="blendState">Blending options.</param>
 /// <param name="samplerState">Texture sampling options.</param>
 /// <param name="depthStencilState">Depth and stencil options.</param>
 /// <param name="rasterizerState">Rasterization options.</param>
 /// <param name="effect">Effect state options.</param>
 public void Begin(SpriteSortMode sortMode, BlendState blendState, SamplerState samplerState, DepthStencilState depthStencilState, RasterizerState rasterizerState, Effect effect)
 {
     Begin(sortMode, blendState, samplerState, depthStencilState, rasterizerState, effect, Matrix.Identity);
 }
 /// <summary>
 /// Begins a sprite batch rendering using the specified sorting mode and blend state. Other states are sets to default (DepthStencilState.None, SamplerState.LinearClamp, RasterizerState.CullCounterClockwise). If you pass a null blend state, the default is BlendState.AlphaBlend.
 /// </summary>
 /// <param name="sortMode">Sprite drawing order.</param>
 /// <param name="blendState">Blending options.</param>
 public void Begin(SpriteSortMode sortMode, BlendState blendState)
 {
     Begin(sortMode, blendState, null, null, null, null, Matrix.Identity);
 }
        public VoxelRenderer(GraphicsDevice graphicsDevice, ContentManager contentManager)
        {
            _cubeVertexBuffer = Buffer.Vertex.New(
                graphicsDevice,
                new[]
                    {
                        // 3D coordinates              UV Texture coordinates
                        new CubeVertex() { Position = new Vector3(-1.0f, -1.0f, -1.0f), Normal = -Vector3.UnitZ, Texcoord = new Vector2(0.0f, 1.0f) }, // Front
                        new CubeVertex() { Position = new Vector3(-1.0f,  1.0f, -1.0f), Normal = -Vector3.UnitZ, Texcoord = new Vector2(0.0f, 0.0f) },
                        new CubeVertex() { Position = new Vector3(1.0f,  1.0f, -1.0f ), Normal = -Vector3.UnitZ, Texcoord = new Vector2(1.0f, 0.0f) },
                        new CubeVertex() { Position = new Vector3(-1.0f, -1.0f, -1.0f), Normal = -Vector3.UnitZ, Texcoord = new Vector2(0.0f, 1.0f) },
                        new CubeVertex() { Position = new Vector3(1.0f,  1.0f, -1.0f ), Normal = -Vector3.UnitZ, Texcoord = new Vector2(1.0f, 0.0f) },
                        new CubeVertex() { Position = new Vector3(1.0f, -1.0f, -1.0f ), Normal = -Vector3.UnitZ, Texcoord = new Vector2(1.0f, 1.0f) },
                        new CubeVertex() { Position = new Vector3(-1.0f, -1.0f,  1.0f), Normal = Vector3.UnitZ, Texcoord = new Vector2(1.0f, 0.0f) }, // BACK
                        new CubeVertex() { Position = new Vector3(1.0f,  1.0f,  1.0f ), Normal = Vector3.UnitZ, Texcoord = new Vector2(0.0f, 1.0f) },
                        new CubeVertex() { Position = new Vector3(-1.0f,  1.0f,  1.0f), Normal = Vector3.UnitZ, Texcoord = new Vector2(1.0f, 1.0f) },
                        new CubeVertex() { Position = new Vector3(-1.0f, -1.0f,  1.0f), Normal = Vector3.UnitZ, Texcoord = new Vector2(1.0f, 0.0f) },
                        new CubeVertex() { Position = new Vector3(1.0f, -1.0f,  1.0f ), Normal = Vector3.UnitZ, Texcoord = new Vector2(0.0f, 0.0f) },
                        new CubeVertex() { Position = new Vector3(1.0f,  1.0f,  1.0f ), Normal = Vector3.UnitZ, Texcoord = new Vector2(0.0f, 1.0f) },
                        new CubeVertex() { Position = new Vector3(-1.0f, 1.0f, -1.0f ), Normal = Vector3.UnitY, Texcoord = new Vector2(0.0f, 1.0f) }, // Top
                        new CubeVertex() { Position = new Vector3(-1.0f, 1.0f,  1.0f ), Normal = Vector3.UnitY, Texcoord = new Vector2(0.0f, 0.0f) },
                        new CubeVertex() { Position = new Vector3(1.0f, 1.0f,  1.0f  ), Normal = Vector3.UnitY, Texcoord = new Vector2(1.0f, 0.0f) },
                        new CubeVertex() { Position = new Vector3(-1.0f, 1.0f, -1.0f ), Normal = Vector3.UnitY, Texcoord = new Vector2(0.0f, 1.0f) },
                        new CubeVertex() { Position = new Vector3(1.0f, 1.0f,  1.0f  ), Normal = Vector3.UnitY, Texcoord = new Vector2(1.0f, 0.0f) },
                        new CubeVertex() { Position = new Vector3(1.0f, 1.0f, -1.0f  ), Normal = Vector3.UnitY, Texcoord = new Vector2(1.0f, 1.0f) },
                        new CubeVertex() { Position = new Vector3(-1.0f,-1.0f, -1.0f ), Normal = -Vector3.UnitY, Texcoord = new Vector2(1.0f, 0.0f) }, // Bottom
                        new CubeVertex() { Position = new Vector3(1.0f,-1.0f,  1.0f  ), Normal = -Vector3.UnitY, Texcoord = new Vector2(0.0f, 1.0f) },
                        new CubeVertex() { Position = new Vector3(-1.0f,-1.0f,  1.0f ), Normal = -Vector3.UnitY, Texcoord = new Vector2(1.0f, 1.0f) },
                        new CubeVertex() { Position = new Vector3(-1.0f,-1.0f, -1.0f ), Normal = -Vector3.UnitY, Texcoord = new Vector2(1.0f, 0.0f) },
                        new CubeVertex() { Position = new Vector3(1.0f,-1.0f, -1.0f  ), Normal = -Vector3.UnitY, Texcoord = new Vector2(0.0f, 0.0f) },
                        new CubeVertex() { Position = new Vector3(1.0f,-1.0f,  1.0f  ), Normal = -Vector3.UnitY, Texcoord = new Vector2(0.0f, 1.0f) },
                        new CubeVertex() { Position = new Vector3(-1.0f, -1.0f, -1.0f), Normal = -Vector3.UnitX, Texcoord = new Vector2(0.0f, 1.0f) }, // Left
                        new CubeVertex() { Position = new Vector3(-1.0f, -1.0f,  1.0f), Normal = -Vector3.UnitX, Texcoord = new Vector2(0.0f, 0.0f) },
                        new CubeVertex() { Position = new Vector3(-1.0f,  1.0f,  1.0f), Normal = -Vector3.UnitX, Texcoord = new Vector2(1.0f, 0.0f) },
                        new CubeVertex() { Position = new Vector3(-1.0f, -1.0f, -1.0f), Normal = -Vector3.UnitX, Texcoord = new Vector2(0.0f, 1.0f) },
                        new CubeVertex() { Position = new Vector3(-1.0f,  1.0f,  1.0f), Normal = -Vector3.UnitX, Texcoord = new Vector2(1.0f, 0.0f) },
                        new CubeVertex() { Position = new Vector3(-1.0f,  1.0f, -1.0f), Normal = -Vector3.UnitX, Texcoord = new Vector2(1.0f, 1.0f) },
                        new CubeVertex() { Position = new Vector3(1.0f, -1.0f, -1.0f ), Normal = Vector3.UnitX, Texcoord = new Vector2(1.0f, 0.0f) }, // Right
                        new CubeVertex() { Position = new Vector3(1.0f,  1.0f,  1.0f ), Normal = Vector3.UnitX, Texcoord = new Vector2(0.0f, 1.0f) },
                        new CubeVertex() { Position = new Vector3(1.0f, -1.0f,  1.0f ), Normal = Vector3.UnitX, Texcoord = new Vector2(1.0f, 1.0f) },
                        new CubeVertex() { Position = new Vector3(1.0f, -1.0f, -1.0f ), Normal = Vector3.UnitX, Texcoord = new Vector2(1.0f, 0.0f) },
                        new CubeVertex() { Position = new Vector3(1.0f,  1.0f, -1.0f ), Normal = Vector3.UnitX, Texcoord = new Vector2(0.0f, 0.0f) },
                        new CubeVertex() { Position = new Vector3(1.0f,  1.0f,  1.0f ), Normal = Vector3.UnitX, Texcoord = new Vector2(0.0f, 1.0f) }
                    }, SharpDX.Direct3D11.ResourceUsage.Immutable);

            // Create an input layout from the vertices
            _vertexInputLayout = VertexInputLayout.New(
                VertexBufferLayout.New(0, new VertexElement[]{new VertexElement("POSITION_CUBE", 0, SharpDX.DXGI.Format.R32G32B32_Float, 0),
                                                              new VertexElement("NORMAL", 0, SharpDX.DXGI.Format.R32G32B32_Float, sizeof(float) * 3),
                                                              new VertexElement("TEXCOORD", 0, SharpDX.DXGI.Format.R32G32_Float, sizeof(float) * 6)}, 0),
                VertexBufferLayout.New(1, new VertexElement[]{new VertexElement("POSITION_INSTANCE", SharpDX.DXGI.Format.R32_SInt)}, 1));

            // Create instance buffer for every VoxelInfo
            _voxelTypeRenderingData = new VoxelTypeInstanceData[TypeInformation.GetNumTypes()-1];
            for (int i = 0; i < _voxelTypeRenderingData.Length; ++i)
                _voxelTypeRenderingData[i] = new VoxelTypeInstanceData(graphicsDevice, (VoxelType)(i+1));
            LoadTextures(contentManager);

            // load shader
            EffectCompilerFlags compilerFlags = EffectCompilerFlags.None;
            #if DEBUG
            compilerFlags |= EffectCompilerFlags.Debug;
            #endif
            var voxelShaderCompileResult = EffectCompiler.CompileFromFile("Content/voxel.fx", compilerFlags);
            if (voxelShaderCompileResult.HasErrors)
            {
                System.Console.WriteLine(voxelShaderCompileResult.Logger.Messages);
                System.Diagnostics.Debugger.Break();
            }
            _voxelEffect = new SharpDX.Toolkit.Graphics.Effect(graphicsDevice, voxelShaderCompileResult.EffectData);

            // setup states
            var rasterizerStateDesc = SharpDX.Direct3D11.RasterizerStateDescription.Default();
            rasterizerStateDesc.CullMode = SharpDX.Direct3D11.CullMode.Back;
            _backfaceCullingState = RasterizerState.New(graphicsDevice, "CullModeBack", rasterizerStateDesc);
            rasterizerStateDesc.CullMode = SharpDX.Direct3D11.CullMode.None;
            _noneCullingState = RasterizerState.New(graphicsDevice, "CullModeNone", rasterizerStateDesc);

            var depthStencilStateDesc = SharpDX.Direct3D11.DepthStencilStateDescription.Default();
            depthStencilStateDesc.IsDepthEnabled = true;
            _depthStencilStateState = DepthStencilState.New(graphicsDevice, "NormalZBufferUse", depthStencilStateDesc);

            var samplerStateDesc = SharpDX.Direct3D11.SamplerStateDescription.Default();
            samplerStateDesc.AddressV = SharpDX.Direct3D11.TextureAddressMode.Mirror;
            samplerStateDesc.AddressU = SharpDX.Direct3D11.TextureAddressMode.Mirror;
            samplerStateDesc.Filter = SharpDX.Direct3D11.Filter.MinMagMipPoint;
            _pointSamplerState = SamplerState.New(graphicsDevice, "PointSampler", samplerStateDesc);
            _voxelEffect.Parameters["PointSampler"].SetResource(_pointSamplerState);

            var blendStateDesc = SharpDX.Direct3D11.BlendStateDescription.Default();
            _blendStateOpaque = BlendState.New(graphicsDevice, "Opaque", blendStateDesc);
            blendStateDesc.RenderTarget[0].IsBlendEnabled = true;
            blendStateDesc.RenderTarget[0].SourceBlend = SharpDX.Direct3D11.BlendOption.SourceAlpha;
            blendStateDesc.RenderTarget[0].DestinationBlend = SharpDX.Direct3D11.BlendOption.InverseSourceAlpha;
            blendStateDesc.RenderTarget[0].BlendOperation = SharpDX.Direct3D11.BlendOperation.Add;
            _blendStateTransparent = BlendState.New(graphicsDevice, "AlphaBlend", blendStateDesc);

            // vertexbuffer for a single instance
            _singleInstanceBuffer = Buffer.Vertex.New<Int32>(graphicsDevice, 1, SharpDX.Direct3D11.ResourceUsage.Dynamic);
        }
        protected override void LoadContent()
        {
            base.LoadContent();

            _basicEffect = ToDisposeContent(new BasicEffect(GraphicsDevice));

            _basicEffect.EnableDefaultLighting();
            _basicEffect.SpecularPower = 64;
            var desc = _basicEffect.Sampler.Description;
            desc.Filter = Filter.ComparisonMinMagMipPoint;
            desc.MaximumAnisotropy = 8;
            desc.AddressU = TextureAddressMode.Wrap;
            desc.AddressV = TextureAddressMode.Wrap;
            desc.AddressW = TextureAddressMode.Wrap;
            desc.MaximumLod = float.MaxValue;
            desc.MinimumLod = 0;
            _basicEffect.Sampler = SamplerState.New(GraphicsDevice, desc);

            _manTexture = Content.Load<Texture2D>("textures/mobs/man");
            _man = ToDisposeContent(MeshGenerator.CreateTextureMesh(_manTexture));
            _manTransform = Matrix.Scaling(.6f, 1.6f, .05f)*Matrix.Translation(-.4f, 1.4f, 1);

            _bookshelfTexture = Content.Load<Texture2D>("textures/walls/decorations/bookshelf");
            _bookshelf = ToDisposeContent(MeshGenerator.CreateTextureMesh(_bookshelfTexture));
            _bookshelfTransform = Matrix.Scaling(1.54f, 1f, .5f) * Matrix.Translation(-3.9f, 1f, -5f);

            _windowTexture = Content.Load<Texture2D>("textures/walls/decorations/window outside");
            _window = ToDisposeContent(MeshGenerator.CreateTextureMesh(_windowTexture));
            _windowTransform = Matrix.Scaling(1.5f, 1.5f, .03f) * Matrix.Translation(3f, 1.75f, -5f);

            _curtainTexture = Content.Load<Texture2D>("textures/walls/decorations/red curtain open");
            _curtain = ToDisposeContent(MeshGenerator.CreateTextureMesh(_curtainTexture));
            _curtainTransform = Matrix.Scaling(1.5f, 1.5f, .1f) * Matrix.Translation(3.1f, 1.75f, -5f);

            _curtain2Texture = Content.Load<Texture2D>("textures/walls/decorations/red curtain open inverse");
            _curtain2 = ToDisposeContent(MeshGenerator.CreateTextureMesh(_curtain2Texture));
            _curtain2Transform = Matrix.Scaling(1.5f, 1.5f, .1f) * Matrix.Translation(2.9f, 1.75f, -5f);

            _borderTexture = Content.Load<Texture2D>("textures/floors/moss border");
            _border = ToDisposeContent(MeshGenerator.CreateTextureMesh(_borderTexture));
            _borderTransform = Matrix.RotationX(-MathUtil.PiOverTwo)*Matrix.Scaling(10, 0.1f, 10) * Matrix.Translation(-5, 0, -5);

            _plane = ToDisposeContent(GeometricPrimitive.Plane.New(GraphicsDevice, 10, 10, 1, new Vector2(2)));
            _planeTexture = Content.Load<Texture2D>("textures/floors/floorboards 1 large dds");
            _planeTransform = Matrix.RotationX(-MathUtil.PiOverTwo)*Matrix.Translation(0, 0, 0);

            _carpetTexture = Content.Load<Texture2D>("textures/floors/carpets/carpet brown");
            _carpet = ToDisposeContent(MeshGenerator.CreateTextureMesh(_carpetTexture));
            _carpetTransform = Matrix.Scaling(4f, 2f, .05f) * Matrix.RotationX(-MathUtil.PiOverTwo) * Matrix.Translation(-2, 0f, 0);

            _pumpkinTexture = Content.Load<Texture2D>("textures/misc/pumkin");
            _pumpkin = ToDisposeContent(MeshGenerator.CreateTextureMesh(_pumpkinTexture));
            _pumpkinTransform = Matrix.Scaling(1f, 1f, .5f) * Matrix.Translation(3, 0.9f, -2);

            _wall = ToDisposeContent(GeometricPrimitive.Plane.New(GraphicsDevice, 10, 2, 1, new Vector2(4, 1f)));
            _wallTexture = Content.Load<Texture2D>("textures/walls/wall testure warped");
            _wallTransform1 = Matrix.Translation(0, 1, -5);
            _wallTransform2 = _wallTransform1*Matrix.RotationY(-MathUtil.PiOverTwo);
            _wallTransform3 = _wallTransform2*Matrix.RotationY(-MathUtil.PiOverTwo);
            _wallTransform4 = _wallTransform3*Matrix.RotationY(-MathUtil.PiOverTwo);

            _doorTexture = Content.Load<Texture2D>("textures/walls/doors/door");
            _door = ToDisposeContent(MeshGenerator.CreateTextureMesh(_doorTexture));
            _doorTransform1 = Matrix.Scaling(1f, 1.8f, .1f)*Matrix.Translation(-0.46f, 1.8f, -5)*
                             Matrix.RotationY(-MathUtil.PiOverTwo);
            _doorTransform2 = _doorTransform1*Matrix.RotationY(-MathUtil.PiOverTwo);
            _doorTransform3 = _doorTransform2 * Matrix.RotationY(-MathUtil.PiOverTwo);
            _doorTransform4 = _doorTransform3 * Matrix.RotationY(-MathUtil.PiOverTwo);

            var blendStateDesc = new BlendStateDescription
            {
                AlphaToCoverageEnable = true,
                IndependentBlendEnable = false
            };
            blendStateDesc.RenderTarget[0].IsBlendEnabled = true;
            blendStateDesc.RenderTarget[0].RenderTargetWriteMask = ColorWriteMaskFlags.All;
            blendStateDesc.RenderTarget[0].SourceBlend = BlendOption.SourceAlpha;
            blendStateDesc.RenderTarget[0].DestinationBlend = BlendOption.InverseSourceAlpha;
            blendStateDesc.RenderTarget[0].BlendOperation = BlendOperation.Add;
            blendStateDesc.RenderTarget[0].SourceAlphaBlend = BlendOption.SourceAlpha;
            blendStateDesc.RenderTarget[0].DestinationAlphaBlend = BlendOption.DestinationAlpha;
            blendStateDesc.RenderTarget[0].AlphaBlendOperation = BlendOperation.Add;
            blendStateDesc.RenderTarget[0].SourceBlend = BlendOption.One;
            _blend = BlendState.New(GraphicsDevice, blendStateDesc);
        }
        public static void BeginSpriteBatch(BlendState blendState)
        {
            System.Diagnostics.Debug.Assert(System.Threading.Thread.CurrentThread == AllowedThread);

            if (m_spriteBatchUsageCount == 0)
            {
                if (m_stencilLevel > 0)
                {
                    StartStencilMask(m_stencilLevel);
                }
                else
                {
                    //  Deferred means that draw call will be send to GPU not on every Draw(), but only at the End() or if we change
                    //  a texture between Begin/End. It's faster than Immediate mode.
                    m_spriteBatch.Begin(SpriteSortMode.Deferred,
                                        blendState,
                                        SamplerState.LinearClamp,
                                        MyStateObjects.GuiDefault_DepthStencilState,
                                        RasterizerState.CullNone);
                }
            }
            m_spriteBatchUsageCount++;
        }