Game Development Reference
In-Depth Information
}
}
As you can see, the ClearColor property defines both the get and set methods.
The set method is declared protected so that this property can only be set by this
class or subclasses.
The constructor
Now we need to set up a constructor for our GameWindow class. Here is the code:
public GameWindow(string title, int width, int
height, bool fullscreen)
{
// Store parameters in member variables.
m_IsFullScreen = fullscreen;
m_ClearColor = new Color4(1.0f, 0.0f, 0.0f,
0.0f);
// Create the game window that will display
the game.
m_Form = new RenderForm(title);
m_Form.ClientSize = new
System.Drawing.Size(width, height);
// Hook up event handlers so we can receive
events from the form
m_Form.FormClosed += FormClosed;
}
The first two lines of code simply set the basic properties of the window to the values
thathavebeenpassedintotheconstructor.Thenextlinesetsthedefaultcolor,which
is black. This means that each time we draw a new frame, we start with an empty
black screen. The color is an ARGB ( Alpha, Red, Green, and Blue ) value. As you
can see, this line sets all of the color channels to a value of 0.0f (except for alpha)
which gives us the color black. A value of 1.0f for alpha means the color is opaque,
while a value of 0.0f would make it completely transparent. A value of 0.5f would
make the color 50 percent transparent.
Search WWH ::




Custom Search