Exemple #1
0
        /// <summary>
        /// Binds the implementation. This is called the first time an unbound state is set to the device or manually by the user in order to
        /// create the underlying state ahead of time (best practice). Once called the state properties are read-only.
        /// </summary>
        public override void BindRasterizerState()
        {
            if (!base.IsBound)
            {
                D3D.RasterizerStateDescription desc = new D3D.RasterizerStateDescription();
                desc.CullMode                 = D3D10Helper.ToD3DCullMode(base.Cull);
                desc.FillMode                 = D3D10Helper.ToD3DFillMode(base.Fill);
                desc.IsMultisampleEnabled     = base.EnableMultiSampleAntiAlias;
                desc.SlopeScaledDepthBias     = base.SlopeScaledDepthBias;
                desc.DepthBias                = base.DepthBias;
                desc.DepthBiasClamp           = 100.0f; //TODO: Whats a good number here?
                desc.IsFrontCounterclockwise  = (base.VertexWinding == VertexWinding.CounterClockwise) ? true : false;
                desc.IsScissorEnabled         = base.EnableScissorTest;
                desc.IsAntialiasedLineEnabled = base.EnableMultiSampleAntiAlias;

                _rs          = D3D.RasterizerState.FromDescription(_graphicsDevice, desc);
                base.IsBound = true;

                //Add to tracker
                _renderer.Resources.AddTrackedObject(_rs.ComPointer, this);
            }
        }
 public void SetRasterizer(D3D.FillMode fillMode)
 {
     D3D.RasterizerStateDescription rsd = new D3D.RasterizerStateDescription()
     {
         CullMode = D3D.CullMode.Back,
         FillMode = fillMode
     };
     D3D.RasterizerState rsdState = D3D.RasterizerState.FromDescription(Device, rsd);
     Device.Rasterizer.State = rsdState;
 }