render states

Direct3D is basically a state machine

不会改变直到我们改变

以下是渲染的设置

1. ID3D11RasterizerState: This interface represents a state group used to configure the rasterization stage of the pipeline.
2. ID3D11BlendState: This interface represents a state group used to configure blending operations. We will discuss these states in
the chapter on blending; by default, blending is disabled, so we do not need to worry about it for now.
3. ID3D11DepthStencilState: This interface represents a state group used to configure the depth and stencil tests. We will discuss
these states in the chapter on the stencil buffer; by default, stenciling is disabled, so we do not need to worry about it for now. The
default depth test settings are set to do the standard depth test as described in

 

HRESULT ID3D11Device::CreateRasterizerState(
    const D3D11_RASTERIZER_DESC *pRasterizerDesc,
    ID3D11RasterizerState **ppRasterizerState);

D3D11_RASTERIZER_DESC定义

typedef struct D3D11_RASTERIZER_DESC {
    D3D11_FILL_MODE FillMode; // Default: D3D11_FILL_SOLID
    D3D11_CULL_MODE CullMode; // Default: D3D11_CULL_BACK
    BOOL FrontCounterClockwise; // Default: false
    INT DepthBias; // Default: 0
    FLOAT DepthBiasClamp; // Default: 0.0f
    FLOAT SlopeScaledDepthBias; // Default: 0.0f
    BOOL DepthClipEnable; // Default: true
    BOOL ScissorEnable; // Default: false
    BOOL MultisampleEnable; // Default: false
    BOOL AntialiasedLineEnable; // Default: false
} D3D11_RASTERIZER_DESC;

example codes 

D3D11_RASTERIZER_DESC rsDesc;
ZeroMemory(&rsDesc, sizeof(D3D11_RASTERIZER_DESC));
rsDesc.FillMode = D3D11_FILL_SOLID;
rsDesc.CullMode = D3D11_CULL_NONE;
rsDesc.FrontCounterClockwise = false;
rsDesc.DepthClipEnable = true;
HR(md3dDevice->CreateRasterizerState(&rsDesc, &mNoCullRS));

切换state

ID3D11RasterizerState* mWireframeRS;
ID3D11RasterizerState* mSolidRS;
...
// Switch between the render state objects in the draw function.
md3dImmediateContext->RSSetState(mSolidRS);
DrawObject();
md3dImmediateContext->RSSetState(mWireframeRS);
DrawObject();

 

posted @ 2015-06-30 00:37  W.Heisenberg  阅读(246)  评论(0编辑  收藏  举报