Added: assimp implementation
This commit is contained in:
@@ -54,8 +54,39 @@ INT Direct3D::init(HWND hWnd, UINT width, UINT height, BOOL isFullscreen)
|
||||
safeRelease(pBackBuffer);
|
||||
|
||||
// 4. create depth stencil buffer
|
||||
ID3D11Texture2D* pDepthStencilBuffer = nullptr;
|
||||
D3D11_TEXTURE2D_DESC depthStencilBufferDesc = {};
|
||||
depthStencilBufferDesc.BindFlags = D3D11_BIND_DEPTH_STENCIL;
|
||||
depthStencilBufferDesc.Width = width;
|
||||
depthStencilBufferDesc.Height = height;
|
||||
depthStencilBufferDesc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;
|
||||
depthStencilBufferDesc.ArraySize = 1;
|
||||
depthStencilBufferDesc.Usage = D3D11_USAGE_DEFAULT;
|
||||
depthStencilBufferDesc.SampleDesc.Count = 1;
|
||||
|
||||
hr = _pD3DDevice->CreateTexture2D(&depthStencilBufferDesc, nullptr, &pDepthStencilBuffer);
|
||||
CheckFailed(hr, 225);
|
||||
|
||||
hr = _pD3DDevice->CreateDepthStencilView(pDepthStencilBuffer, nullptr, &_pD3DDepthStencilView);
|
||||
CheckFailed(hr, 230);
|
||||
|
||||
safeRelease(pDepthStencilBuffer);
|
||||
|
||||
D3D11_DEPTH_STENCIL_DESC depthStencilDesc = {};
|
||||
depthStencilDesc.DepthEnable = true;
|
||||
depthStencilDesc.DepthFunc = D3D11_COMPARISON_LESS_EQUAL;
|
||||
depthStencilDesc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL;
|
||||
|
||||
hr = _pD3DDevice->CreateDepthStencilState(&depthStencilDesc, &_pD3DDepthStencilState);
|
||||
CheckFailed(hr, 240);
|
||||
|
||||
// 5. create rasterizer state
|
||||
D3D11_RASTERIZER_DESC rasterizerDesc = {};
|
||||
rasterizerDesc.FillMode = D3D11_FILL_SOLID;
|
||||
rasterizerDesc.CullMode = D3D11_CULL_BACK;
|
||||
|
||||
hr = _pD3DDevice->CreateRasterizerState(&rasterizerDesc, &_pD3DRasterizerState);
|
||||
CheckFailed(hr, 250);
|
||||
|
||||
// 6. describe viewport
|
||||
D3D11_VIEWPORT viewport = {};
|
||||
@@ -66,7 +97,9 @@ INT Direct3D::init(HWND hWnd, UINT width, UINT height, BOOL isFullscreen)
|
||||
|
||||
// 7. setup render pipeline (device context)
|
||||
_pD3DDeviceContext->RSSetViewports(1, &viewport);
|
||||
_pD3DDeviceContext->OMSetRenderTargets(1, &_pD3DRenderTargetView, nullptr); // TODO: create depth stencil view and set it for output merger stage
|
||||
_pD3DDeviceContext->OMSetRenderTargets(1, &_pD3DRenderTargetView, _pD3DDepthStencilView);
|
||||
_pD3DDeviceContext->OMSetDepthStencilState(_pD3DDepthStencilState, 0xFFFFFFFF);
|
||||
_pD3DDeviceContext->RSSetState(_pD3DRasterizerState);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -79,6 +112,7 @@ void Direct3D::beginScene()
|
||||
|
||||
// 8. clear the buffers
|
||||
_pD3DDeviceContext->ClearRenderTargetView(_pD3DRenderTargetView, color);
|
||||
_pD3DDeviceContext->ClearDepthStencilView(_pD3DDepthStencilView, D3D11_CLEAR_DEPTH, 1.0f, 0xFFFFFFFF);
|
||||
}
|
||||
|
||||
void Direct3D::endScene()
|
||||
|
||||
Reference in New Issue
Block a user