Graphics Reference
In-Depth Information
It is not necessary for the viewport to be of the same size as the render
target, as vertices will be scaled to fit the viewport dimensions. If the
view port is smaller than the target, then the output will only render to a
subregion of the render target and appears zoomed-out. If the view port
is larger than the target, then a portion of the output render will not be
visible and the visible region will appear zoomed-in.
7.
Next, we create the depth buffer and a depth stencil view (DSV). After creating
the DSV, we set the DSV and RTV as the render targets of the OM.
// Create a descriptor for the depth/stencil buffer.
// Allocate a 2-D texture as the depth/stencil buffer.
// Create a DSV to use on bind.
this.DepthBuffer = ToDispose(new Texture2D(device, new
Texture2DDescription()
{
Format = SharpDX.DXGI.Format.D24_UNorm_S8_UInt ,
ArraySize = 1,
MipLevels = 1,
Width = (int)RenderTargetSize.Width,
Height = (int)RenderTargetSize.Height,
SampleDescription = SwapChain.Description.SampleDescription ,
BindFlags = BindFlags.DepthStencil ,
}));
this.DepthStencilView = ToDispose(new DepthStencilView(
device,
DepthBuffer,
new DepthStencilViewDescription()
{
Dimension =
(SwapChain.Description.SampleDescription.Count > 1 ||
SwapChain.Description.SampleDescription.Quality > 0)
? DepthStencilViewDimension.Texture2DMultisampled :
DepthStencilViewDimension.Texture2D
}));
// Set the OutputMerger targets
context.OutputMerger.SetTargets(DepthStencilView,
RenderTargetView);
 
Search WWH ::




Custom Search