Game Development Reference
In-Depth Information
mented them again in this class. It also implements the
IDisposable
interface, just
as the
GameWindow
class does. Also, don't forget to add a reference to SlimDX to
this project if you haven't already.
We need to add some
using
statements to the top of this class file as well. They
are all the same
using
statements that the
GameWindow
class has, plus one more.
The new one is
SlimDX.Direct2D
. They are as follows:
using System.Windows.Forms;
using System.Diagnostics;
using System.Drawing;
using System;
using SlimDX;
using SlimDX.Direct2D;
using SlimDX.Windows;
Next, we need to create a handful of member variables:
WindowRenderTarget m_RenderTarget;
Factory m_Factory;
PathGeometry m_Geometry;
SolidColorBrush m_BrushRed;
SolidColorBrush m_BrushGreen;
SolidColorBrush m_BrushBlue;
The first variable is a
WindowRenderTarget
object. The term
render target
is
used to refer to the surface we are going to draw on. In this case, it is our game win-
dow.However,thisisnotalwaysthecase.Gamescanrendertootherplacesaswell.
For example, rendering into a texture object is used to create various effects. One
example would be a simple security camera effect. Say, we have a security camera
in one room and a monitor in another room. We want the monitor to display what our
security camera sees. To do this, we can render the camera's view into a texture,
which can then be used to texture the screen of the monitor. Of course, this has to
be re-done in every frame so that the monitor screen shows what the camera is cur-
rently seeing. This idea is useful in 2D too.