115 lines
2.0 KiB
C#
115 lines
2.0 KiB
C#
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;
|
|
}
|
|
|
|
public static VertexElementFormat[] Formats { get; } =
|
|
[
|
|
VertexElementFormat.Vector3
|
|
];
|
|
|
|
public static uint[] Offsets { get; } = [ 0 ];
|
|
|
|
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;
|
|
}
|
|
|
|
public static VertexElementFormat[] Formats { get; } =
|
|
[
|
|
VertexElementFormat.Vector3,
|
|
VertexElementFormat.Color
|
|
];
|
|
|
|
public static uint[] Offsets { get; } =
|
|
[
|
|
0,
|
|
12
|
|
];
|
|
|
|
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
|
|
};
|
|
|
|
public static uint[] Offsets { get; } =
|
|
[
|
|
0,
|
|
12
|
|
];
|
|
|
|
public override string ToString()
|
|
{
|
|
return Position + " | " + TexCoord;
|
|
}
|
|
}
|
|
|
|
[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
|
|
];
|
|
} |