Reworked the VBO
This commit is contained in:
parent
3bc90dd83b
commit
ee732240f7
11 changed files with 174 additions and 253 deletions
|
|
@ -163,7 +163,7 @@ namespace SM.Base
|
|||
private static void GLDebugAction(DebugSource source, DebugType type, DebugSeverity severity, string msg)
|
||||
{
|
||||
if (type.HasFlag(DebugType.DebugTypeError)) throw new Exception("[GLError] " + msg);
|
||||
Write(type != DebugType.DontCare ? type.ToString().Substring(9) : "DontCare", ConsoleColor.Gray, msg);
|
||||
Write("GL"+ (type != DebugType.DontCare ? type.ToString().Substring(9) : "DontCare"), ConsoleColor.Gray, msg);
|
||||
}
|
||||
|
||||
[DebuggerStepThrough]
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
#region usings
|
||||
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using OpenTK.Graphics.OpenGL4;
|
||||
using SM.OGL.Mesh;
|
||||
|
||||
|
|
@ -21,19 +23,19 @@ namespace SM.Base.Objects
|
|||
/// </param>
|
||||
public InstancedMesh(PrimitiveType type, string[] enabledAttibute) : base(type)
|
||||
{
|
||||
Attributes["vertex"] = Vertex = new VBO();
|
||||
Attributes["vertex"] = Vertex = new VBO<Vector3>();
|
||||
|
||||
foreach (string attribute in enabledAttibute)
|
||||
switch (attribute)
|
||||
{
|
||||
case "uv":
|
||||
Attributes["uv"] = UVs = new VBO(pointerSize: 2);
|
||||
Attributes["uv"] = UVs = new VBO<Vector2>();
|
||||
break;
|
||||
case "normals":
|
||||
Attributes["normal"] = Normals = new VBO();
|
||||
Attributes["normal"] = Normals = new VBO<Vector3>();
|
||||
break;
|
||||
case "color":
|
||||
Attributes["color"] = Color = new VBO(pointerSize: 4);
|
||||
Attributes["color"] = Color = new VBO<Color4>();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#region usings
|
||||
|
||||
using OpenTK.Graphics;
|
||||
using OpenTK.Graphics.OpenGL4;
|
||||
using SM.OGL.Mesh;
|
||||
|
||||
|
|
@ -22,7 +23,7 @@ namespace SM.Base.Objects
|
|||
/// <summary>
|
||||
/// Contains vertex colors
|
||||
/// </summary>
|
||||
public virtual VBO Color { get; protected set; }
|
||||
public virtual VBO<Color4> Color { get; protected set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public float LineWidth { get; set; } = 1;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#region usings
|
||||
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using OpenTK.Graphics.OpenGL4;
|
||||
using SM.OGL.Mesh;
|
||||
|
|
@ -27,18 +28,18 @@ namespace SM.Base.Objects.Static
|
|||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override VBO Vertex { get; protected set; } = new VBO
|
||||
public override VBO<Vector3> Vertex { get; protected set; } = new VBO<Vector3>
|
||||
{
|
||||
{0, 0, 0},
|
||||
{.5f, 0, 0},
|
||||
{0, 0, 0},
|
||||
{0, .5f, 0},
|
||||
{0, 0, -.5f},
|
||||
{0, 0, .5f}
|
||||
new Vector3(0, 0, 0),
|
||||
new Vector3(.5f, 0, 0),
|
||||
new Vector3(0, 0, 0),
|
||||
new Vector3(0, .5f, 0),
|
||||
new Vector3(0, 0, -.5f),
|
||||
new Vector3(0, 0, .5f)
|
||||
};
|
||||
|
||||
/// <inheritdoc />
|
||||
public override VBO Color { get; protected set; } = new VBO(pointerSize: 4)
|
||||
public override VBO<Color4> Color { get; protected set; } = new VBO<Color4>
|
||||
{
|
||||
Color4.White,
|
||||
Color4.Red,
|
||||
|
|
|
|||
|
|
@ -25,21 +25,21 @@ namespace SM.Base.Objects.Static
|
|||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override VBO Vertex { get; protected set; } = new VBO
|
||||
public override VBO<Vector3> Vertex { get; protected set; } = new VBO<Vector3>
|
||||
{
|
||||
{-.5f, -.5f, 0},
|
||||
{-.5f, .5f, 0},
|
||||
{.5f, .5f, 0},
|
||||
{.5f, -.5f, 0}
|
||||
new Vector3(-.5f, -.5f, 0),
|
||||
new Vector3(-.5f, .5f, 0),
|
||||
new Vector3(.5f, .5f, 0),
|
||||
new Vector3(.5f, -.5f, 0),
|
||||
};
|
||||
|
||||
/// <inheritdoc />
|
||||
public override VBO UVs { get; protected set; } = new VBO(pointerSize: 2)
|
||||
public override VBO<Vector2> UVs { get; protected set; } = new VBO<Vector2>
|
||||
{
|
||||
{0, 1},
|
||||
{0, 0},
|
||||
{1, 0},
|
||||
{1, 1}
|
||||
new Vector2(0, 1),
|
||||
new Vector2(0, 0),
|
||||
new Vector2(1, 0),
|
||||
new Vector2(1, 1),
|
||||
};
|
||||
|
||||
/// <inheritdoc />
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ namespace SM.OGL.Mesh
|
|||
public void Update(GenericMesh mesh)
|
||||
{
|
||||
int pos = 0;
|
||||
foreach (float f in mesh.Vertex)
|
||||
foreach (float f in mesh.Vertex.GetFloats())
|
||||
{
|
||||
Min[pos] = Math.Min(Min[pos], f);
|
||||
Max[pos] = Math.Max(Max[pos], f);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#region usings
|
||||
|
||||
using System;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics.OpenGL4;
|
||||
|
||||
#endregion
|
||||
|
|
@ -29,17 +30,17 @@ namespace SM.OGL.Mesh
|
|||
/// <summary>
|
||||
/// Contains the vertices for the mesh.
|
||||
/// </summary>
|
||||
public virtual VBO Vertex { get; protected set; }
|
||||
public virtual VBO<Vector3> Vertex { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Contains the texture coords for the mesh.
|
||||
/// </summary>
|
||||
public virtual VBO UVs { get; protected set; }
|
||||
public virtual VBO<Vector2> UVs { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Contains the normals for the mesh.
|
||||
/// </summary>
|
||||
public virtual VBO Normals { get; protected set; }
|
||||
public virtual VBO<Vector3> Normals { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Represents the bounding box.
|
||||
|
|
@ -97,8 +98,12 @@ namespace SM.OGL.Mesh
|
|||
if (!_boundingBoxUpdated)
|
||||
UpdateBoundingBox();
|
||||
|
||||
foreach (var kvp in Attributes)
|
||||
kvp.ConnectedVBO?.BindBuffer(kvp.Index);
|
||||
foreach (var kvp in Attributes)
|
||||
{
|
||||
if (kvp.ConnectedVBO == null) continue;
|
||||
kvp.ConnectedVBO.AttributeID = kvp.Index;
|
||||
kvp.ConnectedVBO.Compile();
|
||||
}
|
||||
|
||||
GL.BindVertexArray(0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,246 +1,155 @@
|
|||
#region usings
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using OpenTK;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using OpenTK.Graphics.OpenGL4;
|
||||
|
||||
#endregion
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SM.OGL.Mesh
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a Vertex Buffer Object used for meshes.
|
||||
/// </summary>
|
||||
public class VBO : List<float>
|
||||
public abstract class VBO : GLObject
|
||||
{
|
||||
/// <summary>
|
||||
/// The ID for the buffer.
|
||||
/// </summary>
|
||||
public int BufferID { get; private set; }
|
||||
private float[] _floatArray;
|
||||
|
||||
/// <summary>
|
||||
/// Specifies the expected usage pattern of the data store.
|
||||
/// </summary>
|
||||
public BufferUsageHint BufferUsageHint;
|
||||
protected override bool AutoCompile { get => false; set { return; } }
|
||||
public override ObjectLabelIdentifier TypeIdentifier => ObjectLabelIdentifier.Buffer;
|
||||
|
||||
/// <summary>
|
||||
/// Normalise floats?
|
||||
/// </summary>
|
||||
public bool Normalised;
|
||||
public bool Active { get; set; } = true;
|
||||
public bool CanBeUpdated { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Specifies a offset of the first component of the first generic vertex attribute in the array in the data store of
|
||||
/// the buffer currently bound to the GL_ARRAY_BUFFER target.
|
||||
/// </summary>
|
||||
public int PointerOffset;
|
||||
public bool Normalized { get; protected set; }
|
||||
public int PointerOffset { get; protected set; }
|
||||
public int PointerStride { get; protected set; }
|
||||
public int PointerSize { get; protected set; }
|
||||
public BufferUsageHint UsageHint { get; protected set; }
|
||||
public VertexAttribPointerType PointerType { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Specifies the number of components per generic vertex attribute. Must be 1, 2, 3, 4.
|
||||
/// </summary>
|
||||
public int PointerSize;
|
||||
public int AttributeID { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Specifies the byte offset between consecutive generic vertex attributes.
|
||||
/// </summary>
|
||||
public int PointerStride;
|
||||
public abstract int Count { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The VBO gets ignored when true.
|
||||
/// <para>Default: true</para>
|
||||
/// </summary>
|
||||
public bool Active = true;
|
||||
|
||||
/// <summary>
|
||||
/// Specifies the data type of each component in the array.
|
||||
/// </summary>
|
||||
public VertexAttribPointerType PointerType;
|
||||
|
||||
/// <summary>
|
||||
/// If true it can be updated, otherwise it will get ignored, when the mesh gets updated.
|
||||
/// </summary>
|
||||
public bool CanBeUpdated = false;
|
||||
|
||||
/// <summary>
|
||||
/// Generates a VBO for inserting mesh data.
|
||||
/// </summary>
|
||||
/// <param name="bufferUsageHint">
|
||||
/// Specifies the expected usage pattern of the data store.
|
||||
/// <para>Default: StaticDraw</para>
|
||||
/// </param>
|
||||
/// <param name="pointerType">
|
||||
/// Specifies the data type of each component in the array.
|
||||
/// <para>Default: Float</para>
|
||||
/// </param>
|
||||
/// <param name="pointerSize">
|
||||
/// Specifies the number of components per generic vertex attribute. Must be 1, 2, 3, 4.
|
||||
/// <para>Default: 3</para>
|
||||
/// </param>
|
||||
/// <param name="pointerStride">
|
||||
/// Specifies the byte offset between consecutive generic vertex attributes.
|
||||
/// <para>Default: 0</para>
|
||||
/// </param>
|
||||
/// <param name="pointerOffset">
|
||||
/// Specifies a offset of the first component of the first generic vertex attribute in the
|
||||
/// array in the data store of the buffer currently bound to the GL_ARRAY_BUFFER target.
|
||||
/// <para>Default: 0</para>
|
||||
/// </param>
|
||||
/// <param name="normalised">
|
||||
/// Normalise floats?
|
||||
/// <para>Default: false</para>
|
||||
/// </param>
|
||||
public VBO(BufferUsageHint bufferUsageHint = BufferUsageHint.StaticDraw,
|
||||
VertexAttribPointerType pointerType = VertexAttribPointerType.Float, int pointerSize = 3,
|
||||
int pointerStride = 0, int pointerOffset = 0, bool normalised = false)
|
||||
{
|
||||
BufferUsageHint = bufferUsageHint;
|
||||
PointerType = pointerType;
|
||||
PointerSize = pointerSize;
|
||||
UsageHint = bufferUsageHint;
|
||||
PointerStride = pointerStride;
|
||||
PointerOffset = pointerOffset;
|
||||
Normalised = normalised;
|
||||
Normalized = normalised;
|
||||
}
|
||||
|
||||
public void Add(float x)
|
||||
public override void Compile()
|
||||
{
|
||||
CanBeUpdated = true;
|
||||
}
|
||||
base.Compile();
|
||||
|
||||
/// <summary>
|
||||
/// Adds two values to the VBO.
|
||||
/// </summary>
|
||||
public void Add(float x, float y)
|
||||
{
|
||||
AddRange(new[] {x, y});
|
||||
CanBeUpdated = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds three values to the VBO.
|
||||
/// </summary>
|
||||
public void Add(float x, float y, float z)
|
||||
{
|
||||
AddRange(new[] {x, y, z});
|
||||
CanBeUpdated = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds four values to the VBO.
|
||||
/// </summary>
|
||||
public void Add(float x, float y, float z, float w)
|
||||
{
|
||||
AddRange(new[] {x, y, z, w});
|
||||
CanBeUpdated = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a Vector2.
|
||||
/// </summary>
|
||||
public void Add(Vector2 vector)
|
||||
{
|
||||
Add(vector.X, vector.Y);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a Vector2 and a value.
|
||||
/// </summary>
|
||||
public void Add(Vector2 vector, float z)
|
||||
{
|
||||
Add(vector.X, vector.Y, z);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a Vector2 and two values.
|
||||
/// </summary>
|
||||
public void Add(Vector2 vector, float z, float w)
|
||||
{
|
||||
Add(vector.X, vector.Y, z, w);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a array of vector2s.
|
||||
/// </summary>
|
||||
/// <param name="vectors"></param>
|
||||
public void Add(params Vector2[] vectors)
|
||||
{
|
||||
foreach (Vector2 vector in vectors)
|
||||
{
|
||||
Add(vector);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a Vector3.
|
||||
/// </summary>
|
||||
public void Add(Vector3 vector)
|
||||
{
|
||||
Add(vector.X, vector.Y, vector.Z);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a Vector3 and a value.
|
||||
/// </summary>
|
||||
public void Add(Vector3 vector, float w)
|
||||
{
|
||||
Add(vector.X, vector.Y, vector.Z, w);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a array of Vector3s.
|
||||
/// </summary>
|
||||
/// <param name="vectors"></param>
|
||||
public void Add(params Vector3[] vectors)
|
||||
{
|
||||
foreach (Vector3 vector in vectors)
|
||||
{
|
||||
Add(vector);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Adds a vector4.
|
||||
/// </summary>
|
||||
/// <param name="vector"></param>
|
||||
public void Add(Vector4 vector)
|
||||
{
|
||||
Add(vector.X, vector.Y, vector.Z, vector.W);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a color.
|
||||
/// </summary>
|
||||
public void Add(Color4 color)
|
||||
{
|
||||
Add(color.R, color.G, color.B, color.A);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Binds the buffer to the active VAO.
|
||||
/// </summary>
|
||||
/// <param name="attribID">The id for the attribute.</param>
|
||||
internal void BindBuffer(int attribID)
|
||||
{
|
||||
if (!Active) return;
|
||||
|
||||
var data = ToArray();
|
||||
float[] data = ToFloat();
|
||||
|
||||
BufferID = GL.GenBuffer();
|
||||
GL.BindBuffer(BufferTarget.ArrayBuffer, BufferID);
|
||||
GL.BufferData(BufferTarget.ArrayBuffer, data.Length * sizeof(float), data, BufferUsageHint);
|
||||
_id = GL.GenBuffer();
|
||||
GL.BindBuffer(BufferTarget.ArrayBuffer, _id);
|
||||
GL.BufferData(BufferTarget.ArrayBuffer, data.Length * sizeof(float), data, UsageHint);
|
||||
|
||||
GL.VertexAttribPointer(attribID, PointerSize, PointerType, Normalised, PointerStride, PointerOffset);
|
||||
GL.EnableVertexAttribArray(attribID);
|
||||
GL.BindBuffer(BufferTarget.ArrayBuffer, 0);
|
||||
GL.VertexAttribPointer(AttributeID, PointerSize, PointerType, Normalized, PointerStride, PointerOffset);
|
||||
GL.EnableVertexAttribArray(AttributeID);
|
||||
|
||||
CanBeUpdated = false;
|
||||
}
|
||||
|
||||
internal void Update()
|
||||
public void Update()
|
||||
{
|
||||
var data = ToArray();
|
||||
float[] data = GetFloats();
|
||||
|
||||
GL.BindBuffer(BufferTarget.ArrayBuffer, BufferID);
|
||||
GL.BindBuffer(BufferTarget.ArrayBuffer, _id);
|
||||
GL.BufferSubData(BufferTarget.ArrayBuffer, IntPtr.Zero, data.Length * sizeof(float), data);
|
||||
|
||||
CanBeUpdated = false;
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
GL.DeleteBuffer(_id);
|
||||
base.Dispose();
|
||||
}
|
||||
|
||||
public float[] GetFloats()
|
||||
{
|
||||
if (_floatArray == null || CanBeUpdated)
|
||||
{
|
||||
_floatArray = ToFloat();
|
||||
}
|
||||
|
||||
return _floatArray;
|
||||
}
|
||||
|
||||
protected abstract float[] ToFloat();
|
||||
}
|
||||
|
||||
public class VBO<TType> : VBO, IEnumerable<TType>
|
||||
where TType : struct
|
||||
{
|
||||
static Dictionary<Type, Tuple<int, VertexAttribPointerType>> _pointerSizes = new Dictionary<Type, Tuple<int, VertexAttribPointerType>>()
|
||||
{
|
||||
{ typeof(float), new Tuple<int, VertexAttribPointerType>(1, VertexAttribPointerType.Float) },
|
||||
{ typeof(Vector2), new Tuple<int, VertexAttribPointerType>(2, VertexAttribPointerType.Float) },
|
||||
{ typeof(Vector3), new Tuple<int, VertexAttribPointerType>(3, VertexAttribPointerType.Float) },
|
||||
{ typeof(Vector4), new Tuple<int, VertexAttribPointerType>(4, VertexAttribPointerType.Float) },
|
||||
{ typeof(Color4), new Tuple<int, VertexAttribPointerType>(4, VertexAttribPointerType.Float) },
|
||||
};
|
||||
private List<TType> _values = new List<TType>();
|
||||
|
||||
public override int Count => _values.Count;
|
||||
|
||||
public VBO(BufferUsageHint bufferUsageHint = BufferUsageHint.StaticDraw,
|
||||
int pointerStride = 0, int pointerOffset = 0, bool normalised = false) : base(bufferUsageHint, pointerStride, pointerOffset, normalised)
|
||||
{
|
||||
if (!_pointerSizes.ContainsKey(typeof(TType)))
|
||||
throw new NotSupportedException($"The type '{typeof(TType).FullName}' is not applicable for VBOs.");
|
||||
|
||||
PointerSize = _pointerSizes[typeof(TType)].Item1;
|
||||
PointerType = _pointerSizes[typeof(TType)].Item2;
|
||||
}
|
||||
|
||||
public void Add(TType value)
|
||||
{
|
||||
_values.Add(value);
|
||||
CanBeUpdated = true;
|
||||
}
|
||||
|
||||
public void RemoveAt(int pos)
|
||||
{
|
||||
_values.RemoveAt(pos);
|
||||
CanBeUpdated = true;
|
||||
}
|
||||
|
||||
public IEnumerator<TType> GetEnumerator()
|
||||
{
|
||||
return _values.GetEnumerator();
|
||||
}
|
||||
|
||||
protected override float[] ToFloat()
|
||||
{
|
||||
List<float> floats = new List<float>();
|
||||
|
||||
foreach (TType value in _values)
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case float f: floats.Add(f); break;
|
||||
case Vector2 v: floats.AddRange(new[] { v.X, v.Y }); break;
|
||||
case Vector3 v: floats.AddRange(new[] { v.X, v.Y, v.Z }); break;
|
||||
case Vector4 v: floats.AddRange(new[] { v.X, v.Y, v.Z, v.W }); break;
|
||||
case Color4 v: floats.AddRange(new[] { v.R, v.G, v.B, v.A }); break;
|
||||
}
|
||||
}
|
||||
return floats.ToArray();
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return _values.GetEnumerator();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -144,7 +144,7 @@ namespace SM.OGL.Shaders
|
|||
if (mesh.Indices != null)
|
||||
GL.DrawElementsInstanced(mesh.PrimitiveType, 0, DrawElementsType.UnsignedInt, mesh.Indices, amount);
|
||||
else
|
||||
GL.DrawArraysInstanced(mesh.PrimitiveType, 0, mesh.Vertex.Count / mesh.Vertex.PointerSize, amount);
|
||||
GL.DrawArraysInstanced(mesh.PrimitiveType, 0, mesh.Vertex.Count, amount);
|
||||
}
|
||||
/// <summary>
|
||||
/// Draws the mesh while forcing a primitive type instead of using the mesh type.
|
||||
|
|
@ -157,7 +157,7 @@ namespace SM.OGL.Shaders
|
|||
if (mesh.Indices != null)
|
||||
GL.DrawElementsInstanced(modelType, 0, DrawElementsType.UnsignedInt, mesh.Indices, amount);
|
||||
else
|
||||
GL.DrawArraysInstanced(modelType, 0, mesh.Vertex.Count / mesh.Vertex.PointerSize, amount);
|
||||
GL.DrawArraysInstanced(modelType, 0, mesh.Vertex.Count, amount);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using OpenTK.Graphics.OpenGL4;
|
||||
using SM.Base.Objects;
|
||||
using SM.OGL.Mesh;
|
||||
|
|
@ -17,13 +18,13 @@ namespace SM2D.Object
|
|||
public class Polygon : Mesh
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override VBO Vertex { get; protected set; } = new VBO();
|
||||
public override VBO<Vector3> Vertex { get; protected set; } = new VBO<Vector3>();
|
||||
|
||||
/// <inheritdoc />
|
||||
public override VBO UVs { get; protected set; } = new VBO(pointerSize: 2);
|
||||
public override VBO<Vector2> UVs { get; protected set; } = new VBO<Vector2>();
|
||||
|
||||
/// <inheritdoc />
|
||||
public override VBO Color { get; protected set; } = new VBO(pointerSize: 4);
|
||||
public override VBO<Color4> Color { get; protected set; } = new VBO<Color4>();
|
||||
|
||||
/// <inheritdoc />
|
||||
public override PrimitiveType PrimitiveType { get; protected set; } = PrimitiveType.TriangleFan;
|
||||
|
|
@ -38,7 +39,7 @@ namespace SM2D.Object
|
|||
|
||||
foreach (var vertex in vertices)
|
||||
{
|
||||
Vertex.Add(vertex, 0);
|
||||
Vertex.Add(new Vector3(vertex));
|
||||
}
|
||||
|
||||
UpdateBoundingBox();
|
||||
|
|
@ -55,7 +56,7 @@ namespace SM2D.Object
|
|||
foreach (var polygonVertex in vertices)
|
||||
{
|
||||
Color.Add(polygonVertex.Color);
|
||||
Vertex.Add(polygonVertex.Position, 0);
|
||||
Vertex.Add(new Vector3(polygonVertex.Position.X, polygonVertex.Position.Y, 0));
|
||||
}
|
||||
|
||||
UpdateBoundingBox();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue