Game Development Reference
In-Depth Information
prototyping games. SlimDX is an independent C# API for DirectX, which is a
good alternative to Managed DirectX.
Architecture of OpenGL
OpenGL is a C-style graphics library. C style means there are no classes or
objects; instead, OpenGL is a large collection of functions. Internally, OpenGL is
a state machine. Function calls alter the internal state of OpenGL, which then
affects how it behaves and how it renders polygons to the screen. The fact that it
is a state machine can cause some issues; you may experience a bug in some far
flung region of your code by accidentally setting a state in some other area. For
this reason, it is very important to carefully note which states are being changed.
Vertices—The Building Blocks of 3D Graphics
The basic unit in OpenGL is the vertex. A vertex is, at its simplest, a point in
space. Extra information can be attached to these points—how it maps to a
texture, if it has a certain weight or color—but the most important piece of in-
formation is its position.
Games spend a lot of their time sending OpenGL vertices or telling OpenGL to
move vertices in certain ways. The game may first tell OpenGL that all the ver-
tices it's going to send are to be made into triangles. In this case, for every three
vertices OpenGL receives, it will attach them together with lines to create a
polygon, and it may then fill in the surface with a texture or color.
Modern graphics hardware is very good at processing vast sums of vertices,
making polygons from them and rendering them to the screen. This process of
going from vertex to screen is called the pipeline. The pipeline is responsible for
positioning and lighting the vertices, as well as the projection transformation.
This takes the 3D data and transforms it to 2D data so that it can be displayed on
your screen. A projection transformation may sound a little complicated, but the
world's painters and artists have been doing these transformations for centuries,
painting and drawing the world around them on to a flat canvas.
Even modern 2D games are made using vertices. The 2D sprites are made up of
two triangles to form a square. This is often referred to as a quad. The quad is
given a texture and it becomes a sprite. Two-dimensional games use a special
projection transformation that ignores all the 3D data in the vertices, as it's not
required for a 2D game.
 
 
Search WWH ::




Custom Search