Graphics Reference
In-Depth Information
How to do it…
Here, we will walk through the steps necessary to work with the sample rendering framework.
1. Add a reference to
Common.csproj
within your Direct3D application project.
2. In addition to the SharpDX References we added to our project in the
Building a
Direct3D 11 application with C# and SharpDX
recipe in
Chapter 1
,
Getting Started
with Direct3D
, we will now also include
.\External\bin\SharpDX.Direct2D1.
dll
for supporting 2D text rendering. References to
System.Drawing
and
System.Windows.Forms
are also required for desktop applications.
3. Create a new class file that will house a descendent of the
D3DApplicationDesktop
class. Let's call this new class
D3DApp
. The following
code snippet shows the class declaration and the required
using
directives:
using System;
...
using System.Windows.Forms;
// SharpDX namespaces
using SharpDX;
using SharpDX.DXGI;
using SharpDX.Direct3D11;
using Common;
// Resolve class name conflicts by explicitly stating
// which class they refer to:
using Buffer = SharpDX.Direct3D11.Buffer;
...
public class D3DApp : D3DApplicationDesktop
{
public PrimitivesApp(System.Windows.Forms.Form window)
: base(window)
{ }
...
}
4.
Apart from the constructor shown previously, our
D3DApp
class must also implement
the
public void Run()
method for the abstract
D3DApplicationDesktop
class. This will typically contain the main application message loop and rendering
loop like the following code snippet:
public override void Run()
{