GPU Primitives - absoluteAquarian/GraphicsLib GitHub Wiki

GPU primitives consist of points, lines and triangles, although this mod doesn't support drawing points (yet).

In the GraphicsLib mod, all Vector2s are screen coordinates, so keep that in mind.

GPU primitives drawing is handled by the GraphicsLib.Primitives.PrimitivesDrawing class.

For user convenience, the Vector2s in the PrimitiveDrawing methods are in world coordinates.

Primitives Lines

PrimitiveDrawing.DrawLineStrip(Vector2[] points, Color color)

Draws a continuous set of lines connected end-to-end with a single color.

Exceptions:

  • points is null
  • points has less than two points defined

PrimitiveDrawing.DrawLineStrip(Vector2[] points, Color start, Color end)

Draws a continuous set of lines connected end-to-end whose colors blend from start to end over the length of the entire line strip.

Exceptions:

  • points is null
  • points has less than two points defined

PrimitiveDrawing.DrawLineStrip(Vector2[] points, Color[] colors)

Draws a continuous set of lines connected end-to-end where the color colors[X] blends to colors[X + 1].
Each point in points corresponds with a color in colors.

Exceptions:

  • points is null
  • colors is null
  • The length of points isn't equal to the length of colors
  • points has less than two points defined

PrimitiveDrawing.DrawLineList(Vector2[] points, Color color)

Draws a set of separated lines where all lines share the same color.
Each line uses a pair of points in points, points[X] and points[X + 1].

Exceptions:

  • points is null
  • points has an odd number of points defined
  • The length of points isn't a multiple of two
  • points has less than two points defined

PrimitiveDrawing.DrawLineList(Vector2[] points, Color[] colors)

Draws a set of separated lines where the colors lerp blend point to point.
Each line uses a pair of points in points, points[X] and points[X + 1], and the color colors[X] blends to colors[X + 1].

Exceptions:

  • points is null
  • colors is null
  • The length of points isn't a multiple of two
  • The length of points isn't equal to the length of colors
  • points has less than two points defined

Primitive Triangles

PrimtiveDrawing.DrawTriangleList(Vector2[] points, Color color)

Draws a set of solid triangles which all have the same color.

Exceptions:

  • points is null
  • The length of points isn't a multiple of three
  • points has less than three points defined

PrimitiveDrawing.DrawTriangleList(Vector2[] points, Color[] colors)

Draws a set of solid triangles which have their own colors.
Each triangle uses a triplet of points in points: points[X], points[X + 1] and points[X + 2].
Each point, points[X] corresponds to a color, colors[X].
The colors of each vertex in a triangle blend toward each other.

Exceptions:

  • points is null
  • colors is null
  • The length of points isn't a multiple of three
  • The length of points isn't equal to the length of colors
  • points has less than three points defined

Simple Primitive Shapes

PrimitiveDrawing.DrawHollowRectangle(Vector2 coordTL, Vector2 coordBR, Color colorTL, Color colorTR, Color colorBL, Color colorBR)

Draws a hollow rectangle where the colors of each vertex blend from one vertex to their adjacent vertices.

Exceptions:

  • none

PrimitiveDrawing.DrawFilledRectangle(Vector2 coordTL, Vector2 coordBR, Color colorTL, Color colorTR, Color colorBL, Color colorBR)

Draws a solid rectangle where the colors of each vertex blend from one vertex to their adjacent vertices.

Exceptions:

  • none

PrimitiveDrawing.DrawHollowCircle(Vector2 center, float radius, Color color)

Draws a hollow circle where the color of the circle is constant across its perimeter.
It's actually a 360-sided polygon, but who can tell the difference?

Exceptions:

  • none

PrimitiveDrawing.DrawFilledCircle(Vector2 center, float radius, Color color)

Draws a solid circle where the color of the circle is constant across its area.
It's actually a 360-sided polygon, but who can tell the difference?

Exceptions:

  • none

PrimitiveDrawing.DrawFilledCircle(Vector2 center, float radius, Color color, Color edge)

Draws a solid circle where the color of the circle blends from color in the center to edge at its perimeter.
It's actually a 360-sided polygon, but who can tell the difference?

Exceptions:

  • none

Other

PrimitiveDrawing.SubmitPacket(GraphicsLib.Primitives.PrimitivePacket packet)

Submits a custom packet of primitives to draw.

Exceptions:

  • packet is null
  • packet.draws is null
  • packet doesn't have any primitives queued in it

PrimitiveDrawing.ToPrimitive(Vector2 worldPos, Color color)

Converts worldPos and color into a VertexPositionColor that can be used by GraphicsLib.Primitives.PrimitivePacket.

⚠️ **GitHub.com Fallback** ⚠️