mirror of
https://github.com/sampletext32/ParkanPlayground.git
synced 2026-08-15 02:57:49 +04:00
qol
This commit is contained in:
@@ -28,7 +28,7 @@ public sealed class GpuMesh
|
||||
PrimitiveType = primitiveType;
|
||||
}
|
||||
|
||||
public void Draw()
|
||||
public unsafe void Draw()
|
||||
{
|
||||
_gl.BindVertexArray(VertexArrayObject);
|
||||
_gl.DrawElements(PrimitiveType, IndexCount, DrawElementsType.UnsignedInt, null);
|
||||
|
||||
@@ -132,6 +132,59 @@ public static unsafe class PrimitiveMeshes
|
||||
return CreateIndexedMesh(gl, vertices.ToArray(), indices.ToArray(), PrimitiveType.Lines);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static GpuMesh CreateUnitWireBox(GL gl)
|
||||
{
|
||||
float[] vertices =
|
||||
{
|
||||
-1, -1, -1, 1.0f, 0.82f, 0.15f,
|
||||
1, -1, -1, 1.0f, 0.82f, 0.15f,
|
||||
1, 1, -1, 1.0f, 0.82f, 0.15f,
|
||||
-1, 1, -1, 1.0f, 0.82f, 0.15f,
|
||||
-1, -1, 1, 1.0f, 0.82f, 0.15f,
|
||||
1, -1, 1, 1.0f, 0.82f, 0.15f,
|
||||
1, 1, 1, 1.0f, 0.82f, 0.15f,
|
||||
-1, 1, 1, 1.0f, 0.82f, 0.15f,
|
||||
};
|
||||
|
||||
uint[] indices =
|
||||
{
|
||||
0, 1, 1, 2, 2, 3, 3, 0,
|
||||
4, 5, 5, 6, 6, 7, 7, 4,
|
||||
0, 4, 1, 5, 2, 6, 3, 7,
|
||||
};
|
||||
|
||||
return CreateIndexedMesh(gl, vertices, indices, PrimitiveType.Lines);
|
||||
}
|
||||
|
||||
public static GpuMesh CreateAxes(GL gl, float length = 1.0f)
|
||||
{
|
||||
if (length <= 0.0f)
|
||||
throw new ArgumentOutOfRangeException(nameof(length));
|
||||
|
||||
float[] vertices =
|
||||
{
|
||||
0, 0, 0, 1.0f, 0.25f, 0.25f,
|
||||
length, 0, 0, 1.0f, 0.25f, 0.25f,
|
||||
|
||||
0, 0, 0, 0.25f, 1.0f, 0.25f,
|
||||
0, length, 0, 0.25f, 1.0f, 0.25f,
|
||||
|
||||
0, 0, 0, 0.25f, 0.45f, 1.0f,
|
||||
0, 0, length, 0.25f, 0.45f, 1.0f,
|
||||
};
|
||||
|
||||
uint[] indices =
|
||||
{
|
||||
0, 1,
|
||||
2, 3,
|
||||
4, 5,
|
||||
};
|
||||
|
||||
return CreateIndexedMesh(gl, vertices, indices, PrimitiveType.Lines);
|
||||
}
|
||||
|
||||
private static GpuMesh CreateIndexedMesh(
|
||||
GL gl,
|
||||
float[] vertices,
|
||||
|
||||
Reference in New Issue
Block a user