Example #1
0
 /// <summary>
 /// Creates a new <see cref="RasterizerState"/>, used to control various behaviors of the device's rasterizer.
 /// </summary>
 /// <param name="cullMode">Controls which primitive faces are culled.</param>
 /// <param name="fillMode">The kind of triangle filling to use.</param>
 /// <param name="isDepthClipEnabled">Whether or not primitives are clipped by depth.</param>
 /// <param name="isScissorTestEnabled">Whether or not primitives are clipped by the scissor test.</param>
 /// <returns>A new <see cref="RasterizerState"/>.</returns>
 public RasterizerState CreateRasterizerState(
     FaceCullingMode cullMode,
     TriangleFillMode fillMode,
     bool isDepthClipEnabled,
     bool isScissorTestEnabled)
 {
     return(CreateRasterizerStateCore(cullMode, fillMode, isDepthClipEnabled, isScissorTestEnabled));
 }
Example #2
0
 public override RasterizerState CreateRasterizerState(
     FaceCullingMode cullMode,
     TriangleFillMode fillMode,
     bool isDepthClipEnabled,
     bool isScissorTestEnabled)
 {
     return(new D3DRasterizerState(_device, cullMode, fillMode, isDepthClipEnabled, isScissorTestEnabled));
 }
 protected override RasterizerState CreateRasterizerStateCore(
     FaceCullingMode cullMode,
     TriangleFillMode fillMode,
     bool isDepthClipEnabled,
     bool isScissorTestEnabled)
 {
     return(new OpenGLRasterizerState(cullMode, fillMode, isDepthClipEnabled, isScissorTestEnabled));
 }
 public OpenGLESRasterizerState(
     FaceCullingMode cullMode,
     TriangleFillMode fillMode,
     bool depthClipEnabled,
     bool scissorTestEnabled)
 {
     CullMode             = cullMode;
     FillMode             = fillMode;
     IsDepthClipEnabled   = depthClipEnabled;
     IsScissorTestEnabled = scissorTestEnabled;
 }
 public RasterizerStateCacheKey(
     FaceCullingMode cullMode,
     TriangleFillMode fillMode,
     bool isDepthClipEnabled,
     bool isScissorTestEnabled)
 {
     CullMode             = cullMode;
     FillMode             = fillMode;
     IsDepthClipEnabled   = isDepthClipEnabled;
     IsScissorTestEnabled = isScissorTestEnabled;
 }
        internal static CullFaceMode ConvertCullMode(FaceCullingMode cullMode)
        {
            switch (cullMode)
            {
            case FaceCullingMode.Back:
                return(CullFaceMode.Back);

            case FaceCullingMode.Front:
                return(CullFaceMode.Front);

            default:
                // FaceCullingMode.None should not be converted.
                // It translates to GL.Disable(EnableCap.CullFace).
                throw Illegal.Value <FaceCullingMode>();
            }
        }
Example #7
0
        public VkRasterizerState(FaceCullingMode cullMode, TriangleFillMode fillMode, bool isDepthClipEnabled, bool isScissorTestEnabled)
        {
            CullMode             = cullMode;
            FillMode             = fillMode;
            IsDepthClipEnabled   = isDepthClipEnabled;
            IsScissorTestEnabled = isScissorTestEnabled;

            VkPipelineRasterizationStateCreateInfo rasterizerStateCI = VkPipelineRasterizationStateCreateInfo.New();

            rasterizerStateCI.cullMode         = VkFormats.VeldridToVkCullMode(cullMode);
            rasterizerStateCI.polygonMode      = VkFormats.VeldridToVkFillMode(fillMode);
            rasterizerStateCI.depthClampEnable = !isDepthClipEnabled; // TODO: Same as OpenGL (?)
            rasterizerStateCI.frontFace        = VkFrontFace.Clockwise;

            RasterizerStateCreateInfo = rasterizerStateCI;
        }
Example #8
0
        internal static VkCullModeFlags VeldridToVkCullMode(FaceCullingMode cullMode)
        {
            switch (cullMode)
            {
            case FaceCullingMode.Back:
                return(VkCullModeFlags.Back);

            case FaceCullingMode.Front:
                return(VkCullModeFlags.Front);

            case FaceCullingMode.None:
                return(VkCullModeFlags.None);

            default:
                throw Illegal.Value <FaceCullingMode>();
            }
        }
Example #9
0
        internal static CullMode ConvertCullMode(FaceCullingMode cullMode)
        {
            switch (cullMode)
            {
            case FaceCullingMode.Back:
                return(CullMode.Back);

            case FaceCullingMode.Front:
                return(CullMode.Front);

            case FaceCullingMode.None:
                return(CullMode.None);

            default:
                throw Illegal.Value <FaceCullingMode>();
            }
        }
Example #10
0
 public Renderable()
 {
     hasAlbedoTexture  = 0;
     albedoTexture     = null;
     hasNormalMap      = 0;
     normalMap         = null;
     hasHeightMap      = 0;
     heightMap         = null;
     heightScaleFactor = 1;
     hasAlphaMap       = 0;
     alphaMap          = null;
     hasEnvironmentMap = 0;
     environmentMap    = null;
     reflectivity      = 0;
     faceCullingMode   = FaceCullingMode.BACK_SIDE;
     instances         = 0;
     unlit             = 0;
     projectionMode    = ProjectionMode.Planar;
 }
Example #11
0
        private static void Update(FaceCullingMode mode)
        {
            switch (mode)
            {
            case FaceCullingMode.FRONT_SIDE:
                GL.Enable(EnableCap.CullFace);
                GL.CullFace(CullFaceMode.Front);
                break;

            case FaceCullingMode.BACK_SIDE:
                GL.Enable(EnableCap.CullFace);
                GL.CullFace(CullFaceMode.Back);
                break;

            default:
                GL.Disable(EnableCap.CullFace);
                break;
            }
            ;
        }
Example #12
0
        public D3DRasterizerState(
            Device device,
            FaceCullingMode cullMode,
            TriangleFillMode fillMode,
            bool depthClipEnabled,
            bool scissorTestEnabled)
        {
            _device              = device;
            CullMode             = cullMode;
            FillMode             = fillMode;
            IsDepthClipEnabled   = depthClipEnabled;
            IsScissorTestEnabled = scissorTestEnabled;

            var desc = new RasterizerStateDescription()
            {
                IsDepthClipEnabled = IsDepthClipEnabled,
                IsScissorEnabled   = IsScissorTestEnabled,
                CullMode           = D3DFormats.ConvertCullMode(cullMode),
                FillMode           = D3DFormats.ConvertFillMode(fillMode)
            };

            _deviceState = new SharpDX.Direct3D11.RasterizerState(device, desc);
        }
Example #13
0
 /// <summary>
 /// Creates a new <see cref="RasterizerState"/>, used to control various behaviors of the device's rasterizer.
 /// </summary>
 /// <param name="cullMode">Controls which primitive faces are culled.</param>
 /// <param name="fillMode">The kind of triangle filling to use.</param>
 /// <param name="isDepthClipEnabled">Whether or not primitives are clipped by depth.</param>
 /// <param name="isScissorTestEnabled">Whether or not primitives are clipped by the scissor test.</param>
 /// <returns>A new <see cref="RasterizerState"/>.</returns>
 protected abstract RasterizerState CreateRasterizerStateCore(
     FaceCullingMode cullMode,
     TriangleFillMode fillMode,
     bool isDepthClipEnabled,
     bool isScissorTestEnabled);
 /// <summary>
 /// Initializes a new instance of the <see cref="FaceCullingModeState"/> structure.
 /// </summary>
 /// <param name="faceCullingMode">The face culling mode.</param>
 public FaceCullingModeState(FaceCullingMode faceCullingMode)
 {
     Mode = faceCullingMode;
 }