Game Development Reference
In-Depth Information
public override void UpdateScene(double
frameTime)
{
base.UpdateScene(frameTime);
}
As you can see, we only have one line of code in this override modifier of the base
class's UpdateScene() method. It simply calls the base class version of this meth-
od. This is important because the base class's UpdateScene() method contains
our code that gets the latest user input data each frame, as you may recall from the
previous chapter.
Now, we are finally ready to write the code that will draw our rectangle on the screen!
We will override the RenderScene() method so we can add our custom code:
public override void RenderScene()
{
if ((!this.IsInitialized) ||
this.IsDisposed)
{
return;
}
m_RenderTarget.BeginDraw();
m_RenderTarget.Clear(ClearColor);
m_RenderTarget.FillGeometry(m_Geometry,
m_BrushBlue);
m_RenderTarget.DrawGeometry(m_Geometry,
m_BrushRed, 1.0f);
m_RenderTarget.EndDraw();
}
First, we have an if statement, which happens to be identical to the one we put in
the base class's RenderScene() method. This is because we are not calling the
base class's RenderScene() method, since the only code in it is this if statement.
Not calling the base class version of this method will give us a slight performance
Search WWH ::




Custom Search