Game Development Reference
In-Depth Information
Gl.glColor3d(0.0, 0.0, 1.0);
Gl.glVertex3d(0, 0.5, 0);
}
Gl.glEnd();
Gl.glFinish();
}
#endregion
}
It's the spinning triangle from before. These states have already been loaded in to
the state system in the earlier examples. The only remaining task is to call the
Update and Render functions in the Form.cs.
private void GameLoop(double elapsedTime)
{
_system.Update(elapsedTime);
_system.Render();
_openGLControl.Refresh();
}
That's it. Run the code now and a white screen will appear for three seconds,
followed by a spinning triangle. That proves the state system works quite well
and we can now use this to break up the code. Next, it's time to leave the high-
level concepts of architecture and return to the details of rendering.
Setting the Scene with Projections
Up until now the OpenGL scene has not been explicitly setup; the default settings
have been used. By setting up the scene manually, much more control is given to
how a game appears.
Form Size and OpenGL Viewport Size
The size of the form is currently rather arbitrary; it's been left at the default size
that Visual Studio made it. Real games need to specify how large their window is
going to be. With the current settings, try enabling full-screenmode. The result is
shown in Figure 6.2.
The program has successfully gone full-screen, but the triangle is being rendered
in the bottom-left corner. This issue arises from there being two different sizes
with which to be concerned. One is the size of the form. This is what's changed
 
 
Search WWH ::




Custom Search