Files
CalamityModPublic/Graphics/Primitives/VertexPosition2DColorTexture.cs
T
Toasty ff45607ee2 Primitive System Remake (#23)
* - Primitive system rewrite, start of converting old code to use the newer system.

* - Tweaks to the primitive manager to match the old one.
- Finished porting old uses of the primitives to the new ones.
- Improved XML documentation on the newer ones.

* Delete en-US.hjson

* Remove cosmic shiv auto-entry

* - Indentation fixes.

* - Remove interface access modifiers
2024-02-29 01:19:26 -05:00

47 lines
1.6 KiB
C#

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
namespace CalamityMod.Graphics.Primitives
{
/// <summary>
/// A custom vertex type with a position using Vector2 instead of Vector4, as Terraria is only a 2D game.
/// </summary>
/// <remarks>This represents a vertex that will be rendered by the GPU.</remarks>
public readonly struct VertexPosition2DColorTexture : IVertexType
{
/// <summary>
/// The position of the vertex.
/// </summary>
public readonly Vector2 Position;
/// <summary>
/// The color of the vertex.
/// </summary>
public readonly Color Color;
/// <summary>
/// The texture-coordinate of the vertex.
/// </summary>
public readonly Vector2 TextureCoordinates;
/// <summary>
/// The vertex declaration. This declares the layout and size of the data in the vertex shader.
/// </summary>
public VertexDeclaration VertexDeclaration => VertexDeclaration2D;
public static readonly VertexDeclaration VertexDeclaration2D = new(new VertexElement[]
{
new(0, VertexElementFormat.Vector2, VertexElementUsage.Position, 0),
new(8, VertexElementFormat.Color, VertexElementUsage.Color, 0),
new(12, VertexElementFormat.Vector2, VertexElementUsage.TextureCoordinate, 0),
});
public VertexPosition2DColorTexture(Vector2 position, Color color, Vector2 textureCoordinates)
{
Position = position;
Color = color;
TextureCoordinates = textureCoordinates;
}
}
}