Game Development Reference
In-Depth Information
reflect the size of the OpenGL control. Forms have three possible Window-
States : Normal , Minimized , and Maximized . Maximized gives the
full-screen mode needed. Full-screen mode is good for playing games, but while
developing a game, windowed mode is better. If the program is in a window,
the debugger can be used while the game is running. For that reason, it's
probably best to set _fullscreen to false.
Rendering
To make games, we need to learn how to get OpenGL to start drawing to the
screen. When learning a new program like OpenGL, it's important to have fun,
be curious, and play around with the API. Don't be afraid to experiment or
break things. All OpenGL functions are documented on the OpenGL website
at http://www.opengl.org/sdk/docs/man/. This is a good site to start exploring
the library.
Clearing the Background
Rendering graphics using OpenGL first requires a game loop. Previously, a game
was created in the Program.cs class; this time the game loop will be created in
Form.cs so that it has access to the openGLControl.
using Tao.OpenGl;
namespace StartingGraphics
{
public partial class Form1 : Form
{
FastLoop _fastLoop;
bool _fullscreen ¼ false;
public Form1()
{
_fastLoop ¼ new FastLoop(GameLoop);
InitializeComponent();
_openGLControl.InitializeContexts();
if (_fullscreen)
{
FormBorderStyle ¼ FormBorderStyle.None;
WindowState ¼ FormWindowState.Maximized;
}
}
 
Search WWH ::




Custom Search