/// <summary>
        /// Initializes a new instance of the <see cref="D3D11DepthStencilDesc"/> struct.
        /// </summary>
        /// <param name="isDepthEnabled">Enable depth testing.</param>
        /// <param name="depthWriteMask">Identify a portion of the depth-stencil buffer that can be modified by depth data.</param>
        /// <param name="depthFunction">A function that compares depth data against existing depth data.</param>
        /// <param name="isStencilEnabled">Enable stencil testing.</param>
        /// <param name="stencilReadMask">Identify a portion of the depth-stencil buffer for reading stencil data.</param>
        /// <param name="stencilWriteMask">Identify a portion of the depth-stencil buffer for writing stencil data.</param>
        /// <param name="frontStencilFailOperation">The stencil operation to perform when stencil testing fails for pixels whose surface normal is facing towards the camera.</param>
        /// <param name="frontStencilDepthFailOperation">The stencil operation to perform when stencil testing passes and depth testing fails for pixels whose surface normal is facing towards the camera.</param>
        /// <param name="frontStencilPassOperation">The stencil operation to perform when stencil testing and depth testing both pass for pixels whose surface normal is facing towards the camera.</param>
        /// <param name="frontStencilFunction">A function that compares stencil data against existing stencil data for pixels whose surface normal is facing towards the camera.</param>
        /// <param name="backStencilFailOperation">The stencil operation to perform when stencil testing fails for pixels whose surface normal is facing away from the camera.</param>
        /// <param name="backStencilDepthFailOperation">The stencil operation to perform when stencil testing passes and depth testing fails for pixels whose surface normal is facing away from the camera.</param>
        /// <param name="backStencilPassOperation">The stencil operation to perform when stencil testing and depth testing both pass for pixels whose surface normal is facing away from the camera.</param>
        /// <param name="backStencilFunction">A function that compares stencil data against existing stencil data for pixels whose surface normal is facing away from the camera.</param>
        public D3D11DepthStencilDesc(
            bool isDepthEnabled,
            D3D11DepthWriteMask depthWriteMask,
            D3D11ComparisonFunction depthFunction,
            bool isStencilEnabled,
            byte stencilReadMask,
            byte stencilWriteMask,
            D3D11StencilOperation frontStencilFailOperation,
            D3D11StencilOperation frontStencilDepthFailOperation,
            D3D11StencilOperation frontStencilPassOperation,
            D3D11ComparisonFunction frontStencilFunction,
            D3D11StencilOperation backStencilFailOperation,
            D3D11StencilOperation backStencilDepthFailOperation,
            D3D11StencilOperation backStencilPassOperation,
            D3D11ComparisonFunction backStencilFunction)
        {
            this.isDepthEnabled   = isDepthEnabled;
            this.depthWriteMask   = depthWriteMask;
            this.depthFunction    = depthFunction;
            this.isStencilEnabled = isStencilEnabled;
            this.stencilReadMask  = stencilReadMask;
            this.stencilWriteMask = stencilWriteMask;

            this.frontFace = new D3D11DepthStencilOperationDesc
            {
                StencilFailOperation      = frontStencilFailOperation,
                StencilDepthFailOperation = frontStencilDepthFailOperation,
                StencilPassOperation      = frontStencilPassOperation,
                StencilFunction           = frontStencilFunction
            };

            this.backFace = new D3D11DepthStencilOperationDesc
            {
                StencilFailOperation      = backStencilFailOperation,
                StencilDepthFailOperation = backStencilDepthFailOperation,
                StencilPassOperation      = backStencilPassOperation,
                StencilFunction           = backStencilFunction
            };
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="D3D11SamplerDesc"/> struct.
        /// </summary>
        /// <param name="filter">The filtering method to use when sampling a texture.</param>
        /// <param name="addressU">The method to use for resolving a u texture coordinate that is outside the 0 to 1 range.</param>
        /// <param name="addressV">The method to use for resolving a v texture coordinate that is outside the 0 to 1 range.</param>
        /// <param name="addressW">The method to use for resolving a w texture coordinate that is outside the 0 to 1 range.</param>
        /// <param name="mipLodBias">The offset from the calculated mipmap level.</param>
        /// <param name="maxAnisotropy">The clamping value used if <see cref="D3D11Filter.Anisotropic"/> or <see cref="D3D11Filter.ComparisonAnisotropic"/> is specified in <c>Filter</c>.</param>
        /// <param name="comparisonFunction">A function that compares sampled data against existing sampled data.</param>
        /// <param name="borderColor">The border color to use if <see cref="D3D11TextureAddressMode.Border"/> is specified for <c>AddressU</c>, <c>AddressV</c>, or <c>AddressW</c>.</param>
        /// <param name="minLod">The lower end of the mipmap range to clamp access to, where 0 is the largest and most detailed mipmap level and any level higher than that is less detailed.</param>
        /// <param name="maxLod">The upper end of the mipmap range to clamp access to, where 0 is the largest and most detailed mipmap level and any level higher than that is less detailed.</param>
        public D3D11SamplerDesc(
            D3D11Filter filter,
            D3D11TextureAddressMode addressU,
            D3D11TextureAddressMode addressV,
            D3D11TextureAddressMode addressW,
            float mipLodBias,
            uint maxAnisotropy,
            D3D11ComparisonFunction comparisonFunction,
            float[] borderColor,
            float minLod,
            float maxLod)
        {
            if (borderColor != null && borderColor.Length != 4)
            {
                throw new ArgumentOutOfRangeException("borderColor");
            }

            this.filter             = filter;
            this.addressU           = addressU;
            this.addressV           = addressV;
            this.addressW           = addressW;
            this.mipLodBias         = mipLodBias;
            this.maxAnisotropy      = maxAnisotropy;
            this.comparisonFunction = comparisonFunction;

            if (borderColor == null)
            {
                borderColor = new float[] { 1.0f, 1.0f, 1.0f, 1.0f };
            }

            this.borderColorR = borderColor[0];
            this.borderColorG = borderColor[1];
            this.borderColorB = borderColor[2];
            this.borderColorA = borderColor[3];

            this.minLod = minLod;
            this.maxLod = maxLod;
        }