Graphics Reference
In-Depth Information
Initialization
First is the creation of a window so that we have a valid handle to provide while creating the
SwapChain object. We then declare the device and swapChain variables that will store
the output of our call to the static method Device.CreateDeviceAndSwapChain .
The creation of the device and swap chain takes place next. This is the first highlighted line
in the code listing.
Here we are telling the API to create a Direct3D 11 device using the hardware
driver, with no specific flags (the native enumeration for DeviceCreationFlags is
D3D11_CREATE_DEVICE_FLAG) and to use the feature levels available between 11.1
and 10.0. Because we have not used the Device.CreateDeviceAndSwapChain override
that accepts a SharpDX.DXGI.Adapter object instance, the device will be constructed
using the first adapter found.
This is a common theme with the SharpDX constructors and method overrides, often
implementing default behavior or excluding invalid combinations of parameters to simplify
their usage, while still providing the option of more detailed control that is necessary with
such a complex API.
SwapChainDescription (natively DXGI_SWAP_CHAIN_DESC ) is describing a back
buffer that is the same size as the window with a fullscreen refresh rate of 60 Hz. We have
specified a format of SharpDX.DXGI.Format.R8G8B8A8_UNorm , meaning each pixel
will be made up of 32-bits consisting of four 8-bit unsigned normalized values (for example,
values between 0.0-1.0 represent the range 0-255) representing Red, Green, Blue, and Alpha
respectively. UNorm refers to the fact that each of the values stored are normalized to 8-bit
values between 0.0 and 1.0, for example, a red component stored in an unsigned byte of 255
is 1 and 127 becomes 0.5. A texture format ending in _UInt on the other hand is storing
unsigned integer values, and _Float is using floating point values. Formats ending in _SRgb
store gamma-corrected values, the hardware will linearize these values when reading and
convert back to the sRGB format when writing out pixels.
The back buffer can only be created using a limited number of the available resource formats.
The feature level also impacts the formats that can be used. Supported back buffer formats
for feature level >= 11.0 are:
SharpDX.DXGI.Format.R8G8B8A8_UNorm
SharpDX.DXGI.Format.R8G8B8A8_UNorm_SRgb
SharpDX.DXGI.Format.B8G8R8A8_UNorm
SharpDX.DXGI.Format.B8G8R8A8_UNorm_SRgb
SharpDX.DXGI.Format.R16G16B16A16_Float
SharpDX.DXGI.Format.R10G10B10A2_UNorm
SharpDX.DXGI.Format.R10G10B10_Xr_Bias_A2_UNorm
 
Search WWH ::




Custom Search