Graphics Reference
In-Depth Information
3.
Build the project ( F6 ) just to be sure everything is setup correctly before continuing.
4.
Within the Main() method, replace the existing device initialization with the
following code:
// Create the device and swapchain
Device1 device;
SwapChain1 swapChain;
// First create a regular D3D11 device
using (var device11 = new Device(
SharpDX.Direct3D.DriverType.Hardware,
DeviceCreationFlags.None,
new [] {
SharpDX.Direct3D.FeatureLevel.Level_11_1,
SharpDX.Direct3D.FeatureLevel.Level_11_0,
}))
{
// Query device for the Device1 interface (ID3D11Device1)
device = device11.QueryInterfaceOrNull<Device1>();
if (device == null)
throw new NotSupportedException(
"SharpDX.Direct3D11.Device1 is not supported");
}
We are explicitly excluding feature levels below 11_0 as we will be
using SM5 and other Direct3D 11 features.
Retrieving the Direct3D 11.2 interfaces is performed in the exact
same way except with SharpDX.Direct3D11.Device2 .
5.
With the device created, we now need to initialize our swap chain as shown in
the following code:
// Rather than create a new DXGI Factory we reuse the
// one that has been used internally to create the device
using (var dxgi = device.QueryInterface<SharpDX.DXGI.Device2>())
using (var adapter = dxgi.Adapter)
using (var factory = adapter.GetParent<Factory2>())
{
var desc1 = new SwapChainDescription1()
{
Width = form.ClientSize.Width,
Height = form.ClientSize.Height,
 
Search WWH ::




Custom Search