I have few questions regarding swapchain resizing:
First question:
I made resizing just like in MSDN article, but seems it works not fully correct.
After resizing back of my model begin to be visible from front. You can look this at screenshots
[attachment=19533:before_res.png]
[attachment=19534:after_res.png]
[attachment=19535:result.png]
first screenshot - before resizing
second - after
third - how it displays in another angle.
Looks like stencil operation not working. Here is the code of my swapchain resizing:
void D3D11::ResizeSwapChain()
{
if (swapChain)
{
DeinitializeD2D11();
RECT rc;
GetClientRect(hwnd, &rc);
UINT width = rc.right - rc.left;
UINT height = rc.bottom - rc.top;
d3d11_DeviceContext->OMSetRenderTargets(0, 0, 0);
// Release all outstanding references to the swap chain's buffers.
d3d11_RenderTargetView->Release();
HRESULT hr;
// Preserve the existing buffer count and format.
// Automatically choose the width and height to match the client rect for HWNDs.
hr = swapChain->ResizeBuffers(0, 0, 0, DXGI_FORMAT_UNKNOWN, 0);
// Perform error handling here!
// Get buffer and create a render-target-view.
ID3D11Texture2D* pBuffer;
hr = swapChain->GetBuffer(0, __uuidof(ID3D11Texture2D),
(void**)&pBuffer);
// Perform error handling here!
hr = d3d11_Device->CreateRenderTargetView(pBuffer, NULL,
&d3d11_RenderTargetView);
// Perform error handling here!
pBuffer->Release();
d3d11_DeviceContext->OMSetRenderTargets(1, &d3d11_RenderTargetView, NULL);
// Set up the viewport.
D3D11_VIEWPORT viewPort;
viewPort.Width = (float)width;
viewPort.Height = (float)height;
viewPort.MinDepth = 0.0f;
viewPort.MaxDepth = 1.0f;
viewPort.TopLeftX = 0.0f;
viewPort.TopLeftY = 0.0f;
d3d11_DeviceContext->RSSetViewports(1, &viewPort);
InitializeD2D11();
}
}
And second question:
if I created swapchain with 2 or more buffers, is this code correct in this case or I need do some changes to correctly resize all buffers?