Skip to content

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.

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.

ReturnsSignatureSummary
Tessellatorinst() factoryReturns the shared tessellator.

ReturnsSignatureSummary
voidstart(DrawMode drawMode)Starts a shape joined as drawMode, without texture coordinates, colors or normals.
voiddraw()Sends the shape to the render bridge and ends it.
voidabort()Ends the shape without drawing it, for example after an exception in the middle of a shape.
voidsetColor(int r, int g, int b)Sets an opaque color for the next vertices, from 0 to 255.
voidsetColor(int r, int g, int b, int a)Sets the color of the next vertices, from 0 to 255, alpha included.
voidsetColor(float r, float g, float b, float a)Sets the color of the next vertices, on 1.
voidsetTextureUV(double u, double v)Sets the texture coordinates of the next vertices, on 1.
voidsetNormal(float x, float y, float z)Sets the normal of the next vertices, for lighting; give a vector of length 1.
voidaddVertex(double x, double y, double z)Adds a vertex at x, y, z, with the texture coordinates, the color and the normal set last.
voidaddVertexWithUV(double x, double y, double z, double u, double v)Sets the texture coordinates u, v, then adds the vertex at x, y, z.

Tessellator inst() factory

Returns the shared tessellator.

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.

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.

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.


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

Report a problem with this page