1
我想從紋理創建渲染目標視圖,以用於多個目標渲染。我目前能夠爲後臺緩衝區創建渲染目標視圖 - 所有這些都很好地工作。此外,我可以創建紋理。但是,當我嘗試從它構建視圖時,出現錯誤。Direct3D:從紋理創建渲染目標視圖
首先,這裏的代碼:
D3D11_TEXTURE2D_DESC textureDesc;
ZeroMemory(&textureDesc, sizeof(textureDesc));
textureDesc.ArraySize = 1;
textureDesc.BindFlags = D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE;
textureDesc.CPUAccessFlags = 0;
textureDesc.Format = DXGI_FORMAT_R32_FLOAT;
textureDesc.Height = m_renderTargetSize.Height;
textureDesc.Width = m_renderTargetSize.Width;
textureDesc.MipLevels = 1;
textureDesc.MiscFlags = 0;
textureDesc.SampleDesc.Count = 1;
textureDesc.SampleDesc.Quality = 0;
textureDesc.Usage = D3D11_USAGE_DEFAULT;
ComPtr<ID3D11Texture2D> texture;
DX::ThrowIfFailed(
m_d3dDevice->CreateTexture2D(
&textureDesc,
nullptr,
&texture
)
);
D3D11_RENDER_TARGET_VIEW_DESC renderTargetViewDescription;
ZeroMemory(&renderTargetViewDescription, sizeof(renderTargetViewDescription));
renderTargetViewDescription.Format = textureDesc.Format;
DX::ThrowIfFailed(
m_d3dDevice->CreateRenderTargetView(
texture,
&renderTargetViewDescription,
&m_renderTargetView[1]
)
);
我正在從與調用行的編譯器下面的錯誤CreateRenderTargetView
:
Error: no suitable conversion function from "Microsoft::WRL::ComPtr" to "ID3D11Resource *" exists.
According to MSDN,ID3D11Texture2D從ID3D11Resource繼承。我必須先以某種方式上傳嗎?
我正在使用DirectX 11,並使用vc110進行編譯。