Tessellator
final class Tessellator
Package: dev.joid.lib.render.tessellator · Module: core · Source: Tessellator.java
Collects vertices with optional texture coordinates, colors and normals, and sends them to the render bridge in one draw.
Description
Section titled “Description”Start a shape, give it its vertices, then draw it (Build your own geometry).
It draws with the current render state: the bound texture, the bound shader and the current color, which tints the vertices. A texture coordinate, a color or a normal applies to every vertex added after it, until you set another one. Lines wider than one pixel, or smoothed lines, draw as triangles with round joints. It is not thread-safe: use it on the render thread only.
Learn more
Section titled “Learn more”Creation
Section titled “Creation”| Returns | Signature | Summary |
|---|---|---|
Tessellator | inst() factory | Returns the shared tessellator. |
Methods
Section titled “Methods”| Returns | Signature | Summary |
|---|---|---|
void | start(DrawMode drawMode) | Starts a shape joined as drawMode, without texture coordinates, colors or normals. |
void | draw() | Sends the shape to the render bridge and ends it. |
void | abort() | Ends the shape without drawing it, for example after an exception in the middle of a shape. |
void | setColor(int r, int g, int b) | Sets an opaque color for the next vertices, from 0 to 255. |
void | setColor(int r, int g, int b, int a) | Sets the color of the next vertices, from 0 to 255, alpha included. |
void | setColor(float r, float g, float b, float a) | Sets the color of the next vertices, on 1. |
void | setTextureUV(double u, double v) | Sets the texture coordinates of the next vertices, on 1. |
void | setNormal(float x, float y, float z) | Sets the normal of the next vertices, for lighting; give a vector of length 1. |
void | addVertex(double x, double y, double z) | Adds a vertex at x, y, z, with the texture coordinates, the color and the normal set last. |
void | addVertexWithUV(double x, double y, double z, double u, double v) | Sets the texture coordinates u, v, then adds the vertex at x, y, z. |
Creation details
Section titled “Creation details”Tessellator inst() factory
Returns the shared tessellator.
Method details
Section titled “Method details”void start(DrawMode drawMode)
Throws:
IllegalStateException: The Tessellator is already tessellating a … shape, call draw() to end it before start(…)
Starts a shape joined as drawMode, without texture coordinates, colors or normals.
Throws IllegalStateException while another shape is started.
void draw()
Throws:
IllegalStateException: The Tessellator has no shape to draw, call start(DrawMode) before draw()
Sends the shape to the render bridge and ends it.
Throws IllegalStateException when no shape is started.
void abort()
Ends the shape without drawing it, for example after an exception in the middle of a shape.
setColor
Section titled “setColor”void setColor(int r, int g, int b)
Sets an opaque color for the next vertices, from 0 to 255.
Throws IllegalStateException when no shape is started, like every setter of the tessellator.
void setColor(int r, int g, int b, int a)
Sets the color of the next vertices, from 0 to 255, alpha included.
void setColor(float r, float g, float b, float a)
Sets the color of the next vertices, on 1.
setTextureUV
Section titled “setTextureUV”void setTextureUV(double u, double v)
Sets the texture coordinates of the next vertices, on 1.
setNormal
Section titled “setNormal”void setNormal(float x, float y, float z)
Sets the normal of the next vertices, for lighting; give a vector of length 1.
addVertex
Section titled “addVertex”void addVertex(double x, double y, double z)
Adds a vertex at x, y, z, with the texture coordinates, the color and the normal set last.
addVertexWithUV
Section titled “addVertexWithUV”void addVertexWithUV(double x, double y, double z, double u, double v)
Sets the texture coordinates u, v, then adds the vertex at x, y, z.
fluent returns the instance, typed for chaining · factory creates an instance · signal also accepts a value that follows signals, as a signal, an expression or a lambda (When does JOID compute this value again?) · hook called by JOID, override it · abstract you implement it · default interface method with a body · static called on the class · protected visible to subclasses
