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();

 

转载于:https://www.cnblogs.com/W-Heisenberg/p/4609254.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值