Graphics Reference
In-Depth Information
ID3DllRenderTargetView* RenderTargetViews[l] = { pView };
ID3DllDepthStencilView* DepthTargetView = pDepthView;
pContext->OMSetRenderTargets( 1 , RenderTargetViews, DepthTargetView );
Listing 1.11. Binding the render and depth targets to the pipeline for rendering.
Both the render target and depth stencil target are bound to the pipeline with the same
method call. This method for setting render targets takes an array of render target views, so
even if you are only using a single render target, it is a best practice to use an array to pass
its reference into the function. After the render and depth targets have been bound, we can
clear them to prepare for the coming rendering pass. The body of a method that performs
this process is shown in Listing 1.12. As you can see, the clearing process is also performed
with the device context.
ID3DllRenderTargetView* pRenderTargetViews[D3Dll_SIMULTANE0US_RENDER_TARGET_
COUNT] = {NULL};
ID3DllDepthStencilView* pDepthStencilView = 0;
m_pContext->OMGetRenderTargets( D3D11_SIMULTANE0US_RENDER_TARGET_C0UNT,
pRenderTargetViewsj SpDepthStencilView );
for ( UINT i = 0; i < D3D11_SIMULTANE0US_RENDER_TARGET_C0UNT; ++i )
{
if ( pRenderTargetViews[i] != NULL )
{
float clearColours[] = { color. x, color. y, color. z, color.w }; // RGBA
m_pContext->ClearRenderTargetView( pRenderTargetViews[i] ,
clearColours );
SAFE_RELEASE( pRenderTargetViews[i] );
}
}
if ( pDepthStencilView )
{
m_pContext->ClearDepthStencilView( pDepthStencilView.,
D3Dll_CLEAR_DEPTH, depth, stencil );
}
// Release the depth stencil view
SAFE_RELEASE( pDepthStencilView );
Listing 1.12. Clearing the contents of the bound render and depth targets.
Once the render target and the depth stencil target have been cleared, the applica-
tion can perform whatever rendering operations it needs to. This includes rendering the
Search WWH ::




Custom Search