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 SummaryConstructors Constructor Description RectangleBatch(int numRectangles)Establishes a system through which vertex data may be streamed to draw rectangles.
- 
Method SummaryModifier and Type Method Description voidbatchEnd()Finalizes the data and sends it to the GPU to be rendered.voidbatchStart(float opacity)Begins the batch rendering process.voiddrawRectangle(int x, int y, int width, int height, Color color)Draws a rectangle using the data provided.voiddrawRectangle(org.joml.Vector2i pos, int width, int height, Color color)Draws a rectangle using the data provided.voiddrawRectangle(Rectangle rectangle, Color color)Draws a rectangle using the data provided.voidfreeBuffers()Convenience method which frees the data buffers allocated by this class.Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
- 
Constructor Details- 
RectangleBatchpublic 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- 
batchStartpublic void batchStart(float opacity)Begins the batch rendering process.- Parameters:
- opacity- the transparency value of each rectangle in the batch
 
- 
batchEndpublic void batchEnd()Finalizes the data and sends it to the GPU to be rendered.
- 
drawRectangleDraws 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 corner
- y- the y-coordinate of the rectangles bottom-left corner
- width- the width (in pixels) of the rectangle
- height- the height (in pixels) of the rectangle
- color- the color to draw the rectangle in
 
- 
drawRectangleDraws 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 from
- width- the width (in pixels) of the rectangle
- height- the height (in pixels) of the rectangle
- color- the color to draw the rectangle in
 
- 
drawRectangleDraws a rectangle using the data provided.- Parameters:
- rectangle- the rectangle to draw
- color- the color to draw the rectangle in
 
- 
freeBufferspublic void freeBuffers()Convenience method which frees the data buffers allocated by this class.
 
-