Represents a primitive 2D shape composed of triangles.
More...
|
uint | IndicesID [get] |
| Indices buffer ID assigned to this primitive by GL.BindBuffer. More...
|
|
uint | VerticesID [get] |
| Vertices buffer ID assigned to this primitive by GL.BindBuffer. More...
|
|
uint | ColorID [get] |
| Color buffer ID assigned to this primitive by GL.BindBuffer. More...
|
|
Represents a primitive 2D shape composed of triangles.
TriDevs.TriEngine.Graphics.Primitive.Primitive |
( |
ushort[] |
indices, |
|
|
Vector3[] |
vectors, |
|
|
Color[] |
colors = null |
|
) |
| |
|
protected |
60 :
this(indices, vectors.ToFloatArray(), colors)
TriDevs.TriEngine.Graphics.Primitive.Primitive |
( |
ushort[] |
indices, |
|
|
float[] |
vertices, |
|
|
Color[] |
colors = null |
|
) |
| |
|
protected |
66 if (indices.Length % 3 != 0)
67 throw new EngineException(
68 "Primitives can only be composed of a series of triangles. Expected n*3 points, got " +
69 vertices.Length +
".",
70 new ArgumentException(
"Unexpected number of array items.",
"indices"));
77 GL.GenBuffers(2,
Ids);
79 GL.BindBuffer(BufferTarget.ElementArrayBuffer,
IndicesID);
80 GL.BufferData(BufferTarget.ElementArrayBuffer,
new IntPtr(
Indices.Length *
sizeof(ushort)),
Indices, BufferUsageHint.StaticDraw);
81 GL.BindBuffer(BufferTarget.ElementArrayBuffer, 0);
83 GL.BindBuffer(BufferTarget.ArrayBuffer,
VerticesID);
84 GL.BufferData(BufferTarget.ArrayBuffer,
new IntPtr(
Vertices.Length *
sizeof(
float)),
Vertices, BufferUsageHint.StaticDraw);
85 GL.BindBuffer(BufferTarget.ArrayBuffer, 0);
89 Colors =
new int[colors.Length];
90 for (
int i = 0; i < colors.Length; i++)
91 Colors[i] = colors[i].ToColor4().ToArgb();
94 GL.BindBuffer(BufferTarget.ArrayBuffer,
ColorID);
95 GL.BufferData(BufferTarget.ArrayBuffer,
new IntPtr(
Colors.Length *
sizeof(
int)),
Colors, BufferUsageHint.StaticDraw);
96 GL.BindBuffer(BufferTarget.ArrayBuffer, 0);
void TriDevs.TriEngine.Graphics.Primitive.Dispose |
( |
| ) |
|
124 GL.DeleteBuffers(2,
Ids);
127 GL.DeleteBuffers(1, ref
ColorId);
void TriDevs.TriEngine.Graphics.Primitive.Draw |
( |
| ) |
|
Draw the object to screen.
Implements TriDevs.TriEngine.Interfaces.IDrawable.
102 GL.PushClientAttrib(ClientAttribMask.ClientVertexArrayBit);
104 GL.EnableClientState(ArrayCap.VertexArray);
108 GL.EnableClientState(ArrayCap.ColorArray);
109 GL.BindBuffer(BufferTarget.ArrayBuffer,
ColorID);
110 GL.ColorPointer(
sizeof(
int), ColorPointerType.UnsignedByte, 0, 0);
113 GL.BindBuffer(BufferTarget.ArrayBuffer,
VerticesID);
114 GL.VertexPointer(3, VertexPointerType.Float, 0, 0);
116 GL.BindBuffer(BufferTarget.ElementArrayBuffer,
IndicesID);
117 GL.DrawElements(BeginMode.Triangles,
Indices.Length, DrawElementsType.UnsignedShort, 0);
119 GL.PopClientAttrib();
uint TriDevs.TriEngine.Graphics.Primitive.ColorId |
|
protected |
int [] TriDevs.TriEngine.Graphics.Primitive.Colors |
|
protected |
uint [] TriDevs.TriEngine.Graphics.Primitive.Ids |
|
protected |
ushort [] TriDevs.TriEngine.Graphics.Primitive.Indices |
|
protected |
float [] TriDevs.TriEngine.Graphics.Primitive.Vertices |
|
protected |
uint TriDevs.TriEngine.Graphics.Primitive.ColorID |
|
get |
Color buffer ID assigned to this primitive by GL.BindBuffer.
uint TriDevs.TriEngine.Graphics.Primitive.IndicesID |
|
get |
Indices buffer ID assigned to this primitive by GL.BindBuffer.
uint TriDevs.TriEngine.Graphics.Primitive.VerticesID |
|
get |
Vertices buffer ID assigned to this primitive by GL.BindBuffer.
The documentation for this class was generated from the following file: