Game Development Reference
In-Depth Information
Rendering a triangle
In this section we will set up a basic Direct3D application and render a simple triangle
on the screen. We will start by creating a new project called Triangle . In this pro-
ject, we will first create a new class named TriangleGameWindow.cs . We will need
to make it inherit from our GameWindow base class and implement IDisposable , of
course.
Note
You will need to get the downloadable code for this topic to complete this chapter,
particularly for the second demo we will create in this chapter.
Now that we have a new game window class, the next item of business is to get Dir-
ect3D set up and ready to go. We will need to add some using statements to the top
of the file first though. These allow us to use Direct3D in our code. The following are
the new statements that we need:
using SlimDX.D3DCompiler;
using SlimDX.Direct3D11;
using SlimDX.DirectInput;
using SlimDX.DXGI
using SlimDX;
Next, we need to create our member variables. They are as follows:
SlimDX.Direct3D11.Device m_Device;
SlimDX.Direct3D11.DeviceContext m_DeviceContext;
RenderTargetView m_RenderTargetView;
SwapChain m_SwapChain;
Viewport m_Viewport;
InputLayout m_InputLayout;
VertexShader m_VertexShader;
Search WWH ::




Custom Search