Hello,
I'm new to this board, so I'm sorry if I break any topic rules.
First of all I want to say, that I am programming a 3d game in C++ with DirectX 11.
Now I have an issue, that I can't fix after 10 times of reading the whole code.
So I'll copy the realative code somewhere here below.
I located the error, or some relative part of it in the line, where it says "devcon->OMSetRenderTargets(1, &backbuffer, depthStencilView);".
The issue is from the, like the title says, depth view. Before I wrote this, the programm worked perfectly and when I set the render target WITHOUT the depth implementaion, it is working.
CODE:
... (THIS IS FROM THE INITIALIZATION PART)
D3D11_TEXTURE2D_DESC depthStencilDesc;
depthStencilDesc.Width = windowSizeX;
depthStencilDesc.Height = windowSizeY;
depthStencilDesc.MipLevels = 1;
depthStencilDesc.ArraySize = 1;
depthStencilDesc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;
depthStencilDesc.SampleDesc.Count = 4;
depthStencilDesc.SampleDesc.Quality = 0;
depthStencilDesc.Usage = D3D11_USAGE_DEFAULT;
depthStencilDesc.BindFlags = D3D11_BIND_DEPTH_STENCIL;
depthStencilDesc.CPUAccessFlags = 0;
depthStencilDesc.MiscFlags = 0;
hResult = dev->CreateTexture2D(&depthStencilDesc, NULL, &depthStencilBuffer);
if (FAILED(hResult))
exit(hResult);
D3D11_DEPTH_STENCIL_VIEW_DESC descDSV;
ZeroMemory(&descDSV, sizeof(descDSV));
descDSV.Format = depthStencilDesc.Format;
descDSV.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2DMS;
descDSV.Texture2D.MipSlice = 0;;
hResult = dev->CreateDepthStencilView(depthStencilBuffer, NULL, &depthStencilView);
if (FAILED(hResult))
exit(hResult);
devcon->OMSetRenderTargets(1, &backbuffer, depthStencilView);
D3D11_VIEWPORT viewport;
ZeroMemory(&viewport, sizeof(D3D11_VIEWPORT));
viewport.TopLeftX = 0;
viewport.TopLeftY = 0;
viewport.Width = windowSizeX;
viewport.Height = windowSizeY;
viewport.MinDepth = 0.0F;
viewport.MaxDepth = 1.0F;
devcon->RSSetViewports(1, &viewport);
...
... (THIS IS FROM THE MAIN LOOP)
devcon->ClearDepthStencilView(depthStencilView, D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL, 1.0f, 0.0f);
...
So the COM-objects are released and thats it.
I'm also sorry for syntax mistakes in this text. They are because english is not my motherlanguage.
Please help with that.
Domenik Papst