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 Vector2
s are screen coordinates, so keep that in mind.
GPU primitives drawing is handled by the GraphicsLib.Primitives.PrimitivesDrawing
class.
For user convenience, the Vector2
s in the PrimitiveDrawing
methods are in world coordinates.
Draws a continuous set of lines connected end-to-end with a single color.
Exceptions:
-
points
isnull
-
points
has less than two points defined
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
isnull
-
points
has less than two points defined
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
isnull
-
colors
isnull
- The length of
points
isn't equal to the length ofcolors
-
points
has less than two points defined
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
isnull
-
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
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
isnull
-
colors
isnull
- The length of
points
isn't a multiple of two - The length of
points
isn't equal to the length ofcolors
-
points
has less than two points defined
Draws a set of solid triangles which all have the same color.
Exceptions:
-
points
isnull
- The length of
points
isn't a multiple of three -
points
has less than three points defined
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
isnull
-
colors
isnull
- The length of
points
isn't a multiple of three - The length of
points
isn't equal to the length ofcolors
-
points
has less than three points defined
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
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
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
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
Submits a custom packet of primitives to draw.
Exceptions:
-
packet
isnull
-
packet.draws
isnull
-
packet
doesn't have any primitives queued in it
Converts worldPos
and color
into a VertexPositionColor
that can be used by GraphicsLib.Primitives.PrimitivePacket
.