Game Development Reference
In-Depth Information
public float Alpha { get; set; }
public Color(float r, float g, float b, float a)
: this()
{
Red = r;
Green = g;
Blue = b;
Alpha
= a;
}
}
Vectors are a common tool in game programming. Conceptually they are dif-
ferent than positions in 3D space, but they have the same X,Y,Z values. Generally
vectors are used to represent positions as this makes the code simpler. The vector
here doesn't have any methods; it will be fleshed out when we investigate what
vectors are used for, later on.
The vector structure, and all the other structure, have metadata attached
[StructLayout(LayoutKind.Sequential)]
. This requires an addi-
tional
using
statement.
using System.Runtime.InteropServices;
This metadata informs the complier that it should layout the structures in
memory the same as the C programming language would. This makes it easier to
interact with OpenGL, which is written in C.
The
Point
structure will be used to describe the U,V coordinates. Double pre-
cision isn't need for the texture coordinates so a floating number is used instead.
The
Color
is used to describe the colors of the vertices.
Here is the
renderer
class.
using Tao.OpenGl;
using System.Runtime.InteropServices;
namespace GameStructure
{
public class Renderer
{
public Renderer()
Search WWH ::
Custom Search