2024-06-05 21:19:43 +00:00
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
using MoonWorks.Graphics;
|
|
|
|
|
using MoonWorks.Math.Float;
|
|
|
|
|
|
|
|
|
|
namespace MoonWorksGraphicsTests;
|
|
|
|
|
|
|
|
|
|
[StructLayout(LayoutKind.Sequential)]
|
|
|
|
|
public struct PositionVertex : IVertexType
|
|
|
|
|
{
|
|
|
|
|
public Vector3 Position;
|
|
|
|
|
|
|
|
|
|
public PositionVertex(Vector3 position)
|
|
|
|
|
{
|
|
|
|
|
Position = position;
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-12 00:20:47 +00:00
|
|
|
|
public static VertexElementFormat[] Formats { get; } =
|
|
|
|
|
[
|
2024-06-05 21:19:43 +00:00
|
|
|
|
VertexElementFormat.Vector3
|
2024-06-12 00:20:47 +00:00
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
public static uint[] Offsets { get; } = [ 0 ];
|
2024-06-05 21:19:43 +00:00
|
|
|
|
|
|
|
|
|
public override string ToString()
|
|
|
|
|
{
|
|
|
|
|
return Position.ToString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[StructLayout(LayoutKind.Sequential)]
|
|
|
|
|
public struct PositionColorVertex : IVertexType
|
|
|
|
|
{
|
|
|
|
|
public Vector3 Position;
|
|
|
|
|
public Color Color;
|
|
|
|
|
|
|
|
|
|
public PositionColorVertex(Vector3 position, Color color)
|
|
|
|
|
{
|
|
|
|
|
Position = position;
|
|
|
|
|
Color = color;
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-12 00:20:47 +00:00
|
|
|
|
public static VertexElementFormat[] Formats { get; } =
|
|
|
|
|
[
|
2024-06-05 21:19:43 +00:00
|
|
|
|
VertexElementFormat.Vector3,
|
|
|
|
|
VertexElementFormat.Color
|
2024-06-12 00:20:47 +00:00
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
public static uint[] Offsets { get; } =
|
|
|
|
|
[
|
|
|
|
|
0,
|
|
|
|
|
12
|
|
|
|
|
];
|
2024-06-05 21:19:43 +00:00
|
|
|
|
|
|
|
|
|
public override string ToString()
|
|
|
|
|
{
|
|
|
|
|
return Position + " | " + Color;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[StructLayout(LayoutKind.Sequential)]
|
|
|
|
|
public struct PositionTextureVertex : IVertexType
|
|
|
|
|
{
|
|
|
|
|
public Vector3 Position;
|
|
|
|
|
public Vector2 TexCoord;
|
|
|
|
|
|
|
|
|
|
public PositionTextureVertex(Vector3 position, Vector2 texCoord)
|
|
|
|
|
{
|
|
|
|
|
Position = position;
|
|
|
|
|
TexCoord = texCoord;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static VertexElementFormat[] Formats { get; } = new VertexElementFormat[2]
|
|
|
|
|
{
|
|
|
|
|
VertexElementFormat.Vector3,
|
|
|
|
|
VertexElementFormat.Vector2
|
|
|
|
|
};
|
|
|
|
|
|
2024-06-12 00:20:47 +00:00
|
|
|
|
public static uint[] Offsets { get; } =
|
|
|
|
|
[
|
|
|
|
|
0,
|
|
|
|
|
12
|
|
|
|
|
];
|
|
|
|
|
|
2024-06-05 21:19:43 +00:00
|
|
|
|
public override string ToString()
|
|
|
|
|
{
|
|
|
|
|
return Position + " | " + TexCoord;
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-06-12 00:20:47 +00:00
|
|
|
|
|
|
|
|
|
[StructLayout(LayoutKind.Explicit, Size = 48)]
|
|
|
|
|
struct PositionTextureColorVertex : IVertexType
|
|
|
|
|
{
|
|
|
|
|
[FieldOffset(0)]
|
|
|
|
|
public Vector4 Position;
|
|
|
|
|
|
|
|
|
|
[FieldOffset(16)]
|
|
|
|
|
public Vector2 TexCoord;
|
|
|
|
|
|
|
|
|
|
[FieldOffset(32)]
|
|
|
|
|
public Vector4 Color;
|
|
|
|
|
|
|
|
|
|
public static VertexElementFormat[] Formats { get; } =
|
|
|
|
|
[
|
|
|
|
|
VertexElementFormat.Vector4,
|
|
|
|
|
VertexElementFormat.Vector2,
|
|
|
|
|
VertexElementFormat.Vector4
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
public static uint[] Offsets { get; } =
|
|
|
|
|
[
|
|
|
|
|
0,
|
|
|
|
|
16,
|
|
|
|
|
32
|
|
|
|
|
];
|
|
|
|
|
}
|