D3D11如何将纹理中alpha值为0的像素渲染成透明的?

How does D3D11 render pixels with an alpha value of 0 in the texture as transparent?

问题已解决:在渲染“alpha”贴图前进行OMGetBlendState(_blend_state...设置,渲染后恢复默认blendstate

HRESULT CGraphRender::DrawTexture(const std::shared_ptr<CDrawTextureShader>& texture, const RECT& dst_rect, const BOOL& is_blend_alpha)
{
    CComPtr<ID3D11DeviceContext> immediate_context;
    _d3d_device->GetImmediateContext(&immediate_context);
    if (!immediate_context)
    {
        return E_UNEXPECTED;
    }

    if (is_blend_alpha)
    {
        CComPtr<ID3D11BlendState> old_blend_state;
        FLOAT   old_blend_factor[4] = { 0.f };
        UINT    old_sample_mask = 0;

        immediate_context->OMGetBlendState(&old_blend_state, old_blend_factor, &old_sample_mask);

        float blend_factor[4] = { 1.f, 1.f, 1.f, 1.f };
        immediate_context->OMSetBlendState(_blend_state, blend_factor, 0xffffffff);

        HRESULT hr = texture->Render(immediate_context, dst_rect);

        immediate_context->OMSetBlendState(old_blend_state, old_blend_factor, old_sample_mask);

        return hr;
    }
    else
    {
        return texture->Render(immediate_context, dst_rect);
    }
}