public void ShouldCorrectlyAssignAllMembers()
        {
            const bool             WIREFRAME_MODE   = true;
            const TriangleCullMode CULL_MODE        = TriangleCullMode.NoCulling;
            const bool             FLIP_FACES       = true;
            const int       DEPTH_BIAS              = 10;
            const float     DEPTH_BIAS_CLAMP        = 400f;
            const float     SLOPE_SCALED_DEPTH_BIAS = -340f;
            const bool      ENABLE_Z_CLIPPING       = false;
            RasterizerState testRSState             = new RasterizerState(
                WIREFRAME_MODE,
                CULL_MODE,
                FLIP_FACES,
                DEPTH_BIAS,
                DEPTH_BIAS_CLAMP,
                SLOPE_SCALED_DEPTH_BIAS,
                ENABLE_Z_CLIPPING
                );

            Assert.AreEqual(WIREFRAME_MODE, testRSState.WireframeMode);
            Assert.AreEqual(CULL_MODE, testRSState.TriangleCulling);
            Assert.AreEqual(FLIP_FACES, testRSState.FlipFaces);
            Assert.AreEqual(DEPTH_BIAS, testRSState.DepthBias);
            Assert.AreEqual(DEPTH_BIAS_CLAMP, testRSState.DepthBiasClamp);
            Assert.AreEqual(SLOPE_SCALED_DEPTH_BIAS, testRSState.SlopeScaledDepthBias);
            Assert.AreEqual(ENABLE_Z_CLIPPING, testRSState.EnableZClipping);

            testRSState.Dispose();
        }
 /// <summary>
 /// Constructs a new RasterizerState.
 /// </summary>
 /// <param name="wireframeMode">True if polygons should not be shaded in (instead only the connecting lines will be drawn).</param>
 /// <param name="triangleCulling">The cull mode applied to drawn polygons.</param>
 /// <param name="flipFaces">Whether or not to 'flip' faces, so that back-facing polygons are treated as forward-facing and vice-versa.</param>
 /// <param name="depthBias">Depth value added to a given pixel.
 /// See https://msdn.microsoft.com/en-us/library/windows/desktop/cc308048%28v=vs.85%29.aspx.</param>
 /// <param name="depthBiasClamp">Maximum depth bias of a pixel.
 /// See https://msdn.microsoft.com/en-us/library/windows/desktop/cc308048%28v=vs.85%29.aspx.</param>
 /// <param name="slopeScaledDepthBias">Scalar on a given pixel's slope.
 /// See https://msdn.microsoft.com/en-us/library/windows/desktop/cc308048%28v=vs.85%29.aspx.</param>
 /// <param name="enableZClipping">Whether or not to enable depth-clipping.</param>
 public RasterizerState(bool wireframeMode, TriangleCullMode triangleCulling, bool flipFaces,
                        int depthBias, float depthBiasClamp, float slopeScaledDepthBias, bool enableZClipping)
     : base(
         CreateRasterizerState(wireframeMode, triangleCulling, flipFaces, depthBias, depthBiasClamp, slopeScaledDepthBias, enableZClipping),
         ResourceUsage.Immutable,
         RSSTATE_SIZE_BYTES
         )
 {
     WireframeMode        = wireframeMode;
     TriangleCulling      = triangleCulling;
     FlipFaces            = flipFaces;
     DepthBias            = depthBias;
     DepthBiasClamp       = depthBiasClamp;
     SlopeScaledDepthBias = slopeScaledDepthBias;
     EnableZClipping      = enableZClipping;
 }
        // Initialize all states blocks of various types used by WWT
        private void initializeStates()
        {
            initializeBlendStates();
            initializeDepthStencilStates();
            initializeRasterizerStates();
            initializeSamplerStates();

            currentCullMode = TriangleCullMode.CullCounterClockwise;
            devContext.Rasterizer.State = standardRasterizerStates[(int)currentCullMode];
        }
 // TODO: Extend this method with more commonly used rasterizer states
 // If the number of possible state combinations becomes large, switch
 // to a limited set of state blocks
 public void setRasterizerState(TriangleCullMode cull, bool multisample = true)
 {
     if (cull != currentCullMode || multisample != currentMultisampleState)
     {
         currentCullMode = cull;
         currentMultisampleState = multisample;
         if (multisample)
         {
             devContext.Rasterizer.State = standardRasterizerStates[(int)currentCullMode];
         }
         else
         {
             devContext.Rasterizer.State = standardRasterizerStates[3];
         }
     }
 }
 /// <summary>
 /// Constructs a new RasterizerState with default parameters for depth-testing.
 /// </summary>
 /// <param name="wireframeMode">True if polygons should not be shaded in (instead only the connecting lines will be drawn).</param>
 /// <param name="triangleCulling">The cull mode applied to drawn polygons.</param>
 /// <param name="flipFaces">Whether or not to 'flip' faces, so that back-facing polygons are treated as forward-facing and vice-versa.</param>
 public RasterizerState(bool wireframeMode, TriangleCullMode triangleCulling, bool flipFaces)
     : this(wireframeMode, triangleCulling, flipFaces, 0, 0f, 0f, true)
 {
 }
        private static unsafe RasterizerStateResourceHandle CreateRasterizerState(bool wireframeMode, TriangleCullMode triangleCulling, bool flipFaces,
                                                                                  int depthBias, float depthBiasClamp, float slopeScaledDepthBias, bool enableZClipping)
        {
            RasterizerStateResourceHandle outResourceHandle;

            InteropUtils.CallNative(NativeMethods.ResourceFactory_CreateRSState,
                                    RenderingModule.Device,
                                    wireframeMode ? FILL_MODE_WIREFRAME : FILL_MODE_SOLID,
                                    (int)triangleCulling,
                                    (InteropBool)flipFaces,
                                    depthBias,
                                    depthBiasClamp,
                                    slopeScaledDepthBias,
                                    (InteropBool)enableZClipping,
                                    (IntPtr)(&outResourceHandle)
                                    ).ThrowOnFailure();

            return(outResourceHandle);
        }