Graphics Reference
In-Depth Information
We do not want to implement any multisampling of pixels at this time, so we have provided
the default sampler mode for no anti-aliasing, that is, one sample and a quality of zero: new
SampleDescription(1, 0) .
The buffer usage flag is set to indicate that the buffer will be used as a back buffer and as a
render-target output resource. The bitwise OR operator can be applied to all flags in Direct3D.
The number of back buffers for the swap chain is set to one and there are no flags that
we need to add to modify the swap chain behavior.
With IsWindowed = true , we have indicated that the output will be windowed to begin
with and we have passed the handle of the form we created earlier for the output window.
The swap effect used is SwapEffect.Discard , which will result in the back buffer
contents being discarded after each swapChain.Present .
Windows Store apps must use a swap effect of SwapEffect.
FlipSequential , which in turn limits the valid resource formats
for the back buffer to one of the following:
SharpDX.DXGI.Format.R8G8B8A8_UNorm
SharpDX.DXGI.Format.B8G8R8A8_UNorm
SharpDX.DXGI.Format.R16G16B16A16_Float
With the device and swap chain initialized, we now retrieve a reference to the back buffer so
that we can create RenderTargetView . You can see here that we are not creating any new
objects. We are simply querying the existing objects for a reference to the applicable Direct3D
interfaces. We do still have to dispose of these correctly as the underlying COM reference
counters will have been incremented.
Render loop
The next highlighted piece of code is the SharpDX.Windows.RenderLoop.Run helper
function. This takes our form and delegate or Action as input, with delegate executed
within a loop. The loop takes care of all application messages, and will listen for any
application close events and exit the loop automatically, for example, if the form is closed.
The render loop blocks the thread so that any code located after the call to RenderLoop.Run
will not be executed until the loop has exited.
 
Search WWH ::




Custom Search