public DepthStencilStateDesc(DepthStencilStateTypes type) { try { bool enable = false; REIGN_D3D11_DEPTH_WRITE_MASK mask = REIGN_D3D11_DEPTH_WRITE_MASK.ZERO; REIGN_D3D11_COMPARISON_FUNC func = REIGN_D3D11_COMPARISON_FUNC.ALWAYS; switch (type) { case DepthStencilStateTypes.None: enable = false; mask = REIGN_D3D11_DEPTH_WRITE_MASK.ZERO; func = REIGN_D3D11_COMPARISON_FUNC.ALWAYS; break; case DepthStencilStateTypes.ReadWrite_Less: enable = true; mask = REIGN_D3D11_DEPTH_WRITE_MASK.ALL; func = REIGN_D3D11_COMPARISON_FUNC.LESS; break; default: Debug.ThrowError("DepthStencilStateDesc", "Unsuported DepthStencilStateType"); break; } com = new DepthStencilStateDescCom(enable, mask, func); } catch (Exception e) { Dispose(); throw e; } }
public void Dispose() { if (com != null) { com.Dispose(); com = null; } }
public DepthStencilStateDesc(DepthStencilStateTypes type) { REIGN_D3DZBUFFERTYPE depthReadEnable = REIGN_D3DZBUFFERTYPE._FALSE; bool depthWriteEnable = false; REIGN_D3DCMPFUNC depthFunc = REIGN_D3DCMPFUNC.ALWAYS; bool stencilEnable = false; REIGN_D3DCMPFUNC stencilFunc = REIGN_D3DCMPFUNC.ALWAYS; REIGN_D3DSTENCILOP stencilFailOp = REIGN_D3DSTENCILOP.DECR, stencilDepthFailOp = REIGN_D3DSTENCILOP.DECR, stencilPassOp = REIGN_D3DSTENCILOP.DECR; switch (type) { case DepthStencilStateTypes.None: depthReadEnable = REIGN_D3DZBUFFERTYPE._FALSE; depthWriteEnable = false; depthFunc = REIGN_D3DCMPFUNC.LESS; stencilEnable = false; stencilFunc = REIGN_D3DCMPFUNC.NEVER; stencilFailOp = REIGN_D3DSTENCILOP.KEEP; stencilDepthFailOp = REIGN_D3DSTENCILOP.KEEP; stencilPassOp = REIGN_D3DSTENCILOP.KEEP; break; case DepthStencilStateTypes.ReadWrite_Less: depthReadEnable = REIGN_D3DZBUFFERTYPE._TRUE; depthWriteEnable = true; depthFunc = REIGN_D3DCMPFUNC.LESS; stencilEnable = false; stencilFunc = REIGN_D3DCMPFUNC.NEVER; stencilFailOp = REIGN_D3DSTENCILOP.KEEP; stencilDepthFailOp = REIGN_D3DSTENCILOP.KEEP; stencilPassOp = REIGN_D3DSTENCILOP.KEEP; break; default: Debug.ThrowError("DepthStencilStateDesc", "Unsuported DepthStencilStateType"); break; } com = new DepthStencilStateDescCom(depthReadEnable, depthWriteEnable, depthFunc, stencilEnable, stencilFunc, stencilFailOp, stencilDepthFailOp, stencilPassOp); }