Graphics Reference
In-Depth Information
11. Start debugging the project ( F5 ). If all is well, the application will run and show a
window like the following screenshot. Nothing very exciting yet but we now have a
working device and swap chain.
Output from the empty project
How it works…
We've created a standard Windows Forms Application to simplify the example so
that the project can be built on Windows 7, Windows 8, and Windows 8.1.
Adding the SharpDX.dll reference to your project provides access to all the common
enumerations and structures that have been generated in SharpDX from the Direct3D
SDK header files, along with a number of base classes and helpers such as a matrix
implementation and the RenderLoop we have used. Adding the SharpDX.DXGI.dll
reference provides access to the DXGI API (where we get our SwapChain from), and finally
SharpDX.Direct3D11.dll provides us with access to the Direct3D 11 types.
The using directives added are fairly self-explanatory except perhaps the SharpDX.
Windows namespace. This contains the implementation for RenderLoop and also a
System.Windows.Form descendant that provides some helpful events for Direct3D
applications (for example, when to pause/resume rendering).
When adding the using directives, there are sometimes conflicts in type names between
namespaces. In this instance there is a definition for the Device class in the namespaces
SharpDX.DXGI and SharpDX.Direct3D11 . Rather than having to always use fully qualified
type names, we can instead explicitly state which type should be used with a device using an
alias directive as we have done with:
using Device = SharpDX.Direct3D11.Device;
Our Direct3D recipes will typically be split into three stages:
F Initialization: This is where we will create the Direct3D device and resources
F Render loop: This is where we will execute our rendering commands and logic
F Finalization: This is where we will cleanup and free any resources
The previous code listing has each of the key lines of code highlighted so that you can easily
follow along.
 
Search WWH ::




Custom Search