Package org.xjge.graphics
Class RectangleBatch
java.lang.Object
org.xjge.graphics.RectangleBatch
public final class RectangleBatch
extends java.lang.Object
Used to batch render rectangles. A batch should be done inside of a widgets
render method like so:
batchStart(1.0f); drawRectangle() drawRectangle() drawRectangle() ... batchEnd();
- Since:
- 2.0.0
-
Constructor Summary
Constructors Constructor Description RectangleBatch(int numRectangles)
Establishes a system through which vertex data may be streamed to draw rectangles. -
Method Summary
Modifier and Type Method Description void
batchEnd()
Finalizes the data and sends it to the GPU to be rendered.void
batchStart(float opacity)
Begins the batch rendering process.void
drawRectangle(int x, int y, int width, int height, Color color)
Draws a rectangle using the data provided.void
drawRectangle(org.joml.Vector2i pos, int width, int height, Color color)
Draws a rectangle using the data provided.void
drawRectangle(Rectangle rectangle, Color color)
Draws a rectangle using the data provided.void
freeBuffers()
Convenience method which frees the data buffers allocated by this class.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
RectangleBatch
public RectangleBatch(int numRectangles)Establishes a system through which vertex data may be streamed to draw rectangles.- Parameters:
numRectangles
- the maximum number of rectangles this batch is allowed to draw
-
-
Method Details
-
batchStart
public void batchStart(float opacity)Begins the batch rendering process.- Parameters:
opacity
- the transparency value of each rectangle in the batch
-
batchEnd
public void batchEnd()Finalizes the data and sends it to the GPU to be rendered. -
drawRectangle
Draws a rectangle using the data provided. The shape will be drawn starting from the position of its bottom-left corner.- Parameters:
x
- the x-coordinate of the rectangles bottom-left cornery
- the y-coordinate of the rectangles bottom-left cornerwidth
- the width (in pixels) of the rectangleheight
- the height (in pixels) of the rectanglecolor
- the color to draw the rectangle in
-
drawRectangle
Draws a rectangle using the data provided. The shape will be drawn starting from the position of its bottom-left corner.- Parameters:
pos
- the position in the viewport to draw the rectangle fromwidth
- the width (in pixels) of the rectangleheight
- the height (in pixels) of the rectanglecolor
- the color to draw the rectangle in
-
drawRectangle
Draws a rectangle using the data provided.- Parameters:
rectangle
- the rectangle to drawcolor
- the color to draw the rectangle in
-
freeBuffers
public void freeBuffers()Convenience method which frees the data buffers allocated by this class.
-