Getting multiple screen buffers from swap-chain

2

I want to create multiple render target view and i tried it but i can't get buffer more than 2.

I've already set DXGI_SWAP_CHAIN_DESC's BufferCount value as BufferSize

UINT const BufferSize = 4;
ID3D11Texture2D* BufferTemp;

ID3D11RenderTargetView** RenderTargetView = new ID3D11RenderTargetView*[BufferSize];
for (UINT i = 0; i < BufferSize; i++) {
    ZeroMemory(&BufferTemp, sizeof(BufferTemp));

    SwapChain->GetBuffer(i, __uuidof(ID3D11Texture2D), (void**)&BufferTemp);

    Device->CreateRenderTargetView(BufferTemp, 0, &RenderTargetView[i]);
}

In the actual code, I've initialized HRESULT value, and it said S_OK at the first loop, but after that it said 0x887a0001.

c++
directx
directx-11
dxgi
asked on Stack Overflow Apr 28, 2019 by KidCozy • edited Apr 28, 2019 by user7860670

1 Answer

0

If this swap chain is using DXGI_SWAP_EFFECT_DISCARD effect then GetBuffer method can only access the first buffer. That is you can only get view of the only buffer you can draw on.

answered on Stack Overflow Apr 28, 2019 by user7860670 • edited Apr 28, 2019 by user7860670

User contributions licensed under CC BY-SA 3.0