Exemple #1
0
 /// <summary>
 /// Releases unmanaged and - optionally - managed resources
 /// </summary>
 /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
 protected override void Dispose(bool disposing)
 {
     if (!IsDisposed)
     {
         //Dispose of managed resources
         if (disposing)
         {
             if (_rs != null)
             {
                 if (_renderer != null)
                 {
                     _renderer.Resources.RemoveTrackedObject(_rs.ComPointer);
                 }
                 _rs.Dispose();
                 _rs = null;
             }
         }
         base.Dispose(disposing);
     }
 }
Exemple #2
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);
            }
        }