Game Development Reference
In-Depth Information
1.73 times greater than the height, and this is commonly referred to as a 16:9
aspect ratio.
if (_fullscreen)
{
FormBorderStyle = FormBorderStyle.None;
WindowState = FormWindowState.Maximized;
}
else
{
ClientSize = new Size(1280, 720);
}
Play around with different aspect ratios to decide what you like. Bear in mind
that if you wish to release your game to a large number of people, they may not
be able to support resolutions as high as you can. It may be worth trying to
support a number of different aspects and resolutions.
When playing around with resolutions, you may observe that in certain resolu-
tions the triangle seems a little squashed or distorted. OpenGL's viewport is now
set correctly, but OpenGL's default aspect is 1:1, a square. It's not going to map
to 4:3 or 16:9 very gracefully. OpenGL aspect is 1:1 because that is how the aspect
is set up by default. In order to change it, the projection matrix must be altered.
The Projection Matrix
Computer monitors and televisions display 2D pictures while OpenGL deals
with 3D data. A projection matrix transforms the 3D data to the 2D screen.
There are two types of projection matrix that we're concerned with, ortho-
graphic and perspective. Simply, orthographic is used for 2D graphics like hud
elements, 2D games, and text. Perspective is used for 3D games like an FPS game.
The orthographic matrix ignores the depth information; it doesn't matter how
far away an item is from the user, it remains the same size. With a perspective
projection, things that are farther away are smaller. Those are the main
differences.
2D Graphics
Even 3D games need to be able to render 2D graphics.
A new function should be made in Form.cs named Setup2DGraphics .
 
Search WWH ::




Custom Search