Package dev.prozilla.pine.core.rendering
Class Renderer
java.lang.Object
dev.prozilla.pine.core.rendering.Renderer
- All Implemented Interfaces:
Lifecycle
Handles rendering process.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
Matches the length ofuTextures
in the fragment shader.static final int
The amount of strides to fit into a single vertex buffer. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
begin()
Begin rendering.void
clear()
Clears the drawing area.void
destroy()
Disposes renderer and cleans up its used data.void
drawDebugText
(CharSequence text, float x, float y) Draw debug text at the specified position.void
drawDebugText
(CharSequence text, float x, float y, Color c) Draw debug text at the specified position and color.void
drawRect
(float x, float y, float z, float width, float height) Draws a white rectangle at the given position.void
Draws a colored rectangle at the given position.void
drawRotatedTexture
(Texture texture, float x, float y, float z, float r) void
drawRotatedTexture
(Texture texture, float x, float y, float z, Color c, float r) void
drawRotatedTextureRegion
(float x1, float y1, float x2, float y2, float z, float s1, float t1, float s2, float t2, float r) void
drawRotatedTextureRegion
(float x1, float y1, float x2, float y2, float z, float s1, float t1, float s2, float t2, Color c, float r) void
drawRotatedTextureRegion
(Texture texture, float x, float y, float z, float regX, float regY, float regWidth, float regHeight, float r) void
drawRotatedTextureRegion
(Texture texture, float x, float y, float z, float regX, float regY, float regWidth, float regHeight, Color c, float r) void
drawText
(Font font, CharSequence text, float x, float y, float z) Draw text at the specified position.void
drawText
(Font font, CharSequence text, float x, float y, float z, Color c) Draw text at the specified position and color.void
drawText
(CharSequence text, float x, float y, float z) void
drawText
(CharSequence text, float x, float y, float z, Color c) void
drawTexture
(Texture texture, float x, float y, float z) Draws a texture on specified coordinates.void
drawTexture
(Texture texture, float x, float y, float z, Color c) Draws a texture on specified coordinates and with specified color.void
drawTextureRegion
(float x1, float y1, float x2, float y2, float z, float s1, float t1, float s2, float t2) Draws a texture region on specified coordinates.void
drawTextureRegion
(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, float z, float s1, float t1, float s2, float t2, Color c) Draws a texture region on specified coordinates.void
drawTextureRegion
(float x1, float y1, float x2, float y2, float z, float s1, float t1, float s2, float t2, Color c) Draws a texture region on specified coordinates.void
drawTextureRegion
(Texture texture, float x, float y, float z, float regX, float regY, float regWidth, float regHeight) Draws a texture region on specified coordinates.void
drawTextureRegion
(Texture texture, float x, float y, float z, float regX, float regY, float regWidth, float regHeight, Color c) Draws a texture region on specified coordinates.void
end()
End rendering.void
flush()
Flushes the data to the GPU to let it get rendered.int
Calculates total height of a debug text.int
Calculates total width of a debug text.getFbo()
int
int
getTextHeight
(Font font, CharSequence text) Calculates total height of a text.int
getTextHeight
(CharSequence text) getTextSize
(Font font, CharSequence text) getTextSize
(CharSequence text) int
getTextWidth
(Font font, CharSequence text) Calculates total width of a text.int
getTextWidth
(CharSequence text) int
getWidth()
void
init()
Initializes the object before the game loop starts.void
initPreview
(int width, int height) boolean
boolean
outOfBounds
(float x, float y) Checks if coordinates are outside the screen bounds.boolean
outOfBounds
(float x1, float y1, float x2, float y2) Checks if a line is outside the screen bounds.boolean
outOfBounds
(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4) Checks if a quad is outside the screen bounds.void
void
void
void
resize()
Updates the projection matrix according to the window's dimensions.void
setMirrorHorizontally
(boolean mirrorHorizontally) void
setMirrorVertically
(boolean mirrorVertically) void
setScale
(float scale)
-
Field Details
-
MAX_TEXTURES
public static final int MAX_TEXTURESMatches the length ofuTextures
in the fragment shader.- See Also:
-
VERTEX_BUFFER_SIZE
public static final int VERTEX_BUFFER_SIZEThe amount of strides to fit into a single vertex buffer.- See Also:
-
-
Constructor Details
-
Renderer
-
-
Method Details
-
init
public void init()Description copied from interface:Lifecycle
Initializes the object before the game loop starts. -
initPreview
public void initPreview(int width, int height) -
clear
public void clear()Clears the drawing area. -
begin
Begin rendering.- Throws:
IllegalStateException
-
end
End rendering.- Throws:
IllegalStateException
-
flush
public void flush()Flushes the data to the GPU to let it get rendered. -
resetTransform
public void resetTransform() -
setScale
public void setScale(float scale) -
resetScale
public void resetScale() -
setMirrorHorizontally
public void setMirrorHorizontally(boolean mirrorHorizontally) -
setMirrorVertically
public void setMirrorVertically(boolean mirrorVertically) -
resetMirror
public void resetMirror() -
getDebugTextWidth
Calculates total width of a debug text.- Parameters:
text
- The text- Returns:
- Total width of the text
-
getDebugTextHeight
Calculates total height of a debug text.- Parameters:
text
- The text- Returns:
- Total width of the text
-
drawDebugText
Draw debug text at the specified position.- Parameters:
text
- TextRenderer to drawx
- X coordinate of the text positiony
- Y coordinate of the text position
-
drawDebugText
Draw debug text at the specified position and color.- Parameters:
text
- TextRenderer to drawx
- X coordinate of the text positiony
- Y coordinate of the text positionc
- Color to use
-
getTextSize
-
getTextSize
-
getTextWidth
-
getTextWidth
Calculates total width of a text.- Parameters:
text
- The text- Returns:
- Total width of the text
-
getTextHeight
-
getTextHeight
Calculates total height of a text.- Parameters:
text
- The text- Returns:
- Total width of the text
-
drawText
-
drawText
Draw text at the specified position.- Parameters:
text
- TextRenderer to drawx
- X coordinate of the text positiony
- Y coordinate of the text position
-
drawText
-
drawText
Draw text at the specified position and color.- Parameters:
text
- TextRenderer to drawx
- X coordinate of the text positiony
- Y coordinate of the text positionc
- Color to use
-
drawRect
public void drawRect(float x, float y, float z, float width, float height) Draws a white rectangle at the given position.- Parameters:
x
- X positiony
- Y positionwidth
- Width of the rectangleheight
- Height of the rectangle
-
drawRect
Draws a colored rectangle at the given position.- Parameters:
x
- X positiony
- Y positionwidth
- Width of the rectangleheight
- Height of the rectanglec
- Color
-
drawRotatedTexture
-
drawRotatedTexture
-
drawTexture
Draws a texture on specified coordinates.- Parameters:
texture
- Used for getting width and height of the texturex
- X position of the texturey
- Y position of the texture
-
drawTexture
Draws a texture on specified coordinates and with specified color.- Parameters:
texture
- Used for getting width and height of the texturex
- X position of the texturey
- Y position of the texturec
- The color to use
-
drawRotatedTextureRegion
public void drawRotatedTextureRegion(Texture texture, float x, float y, float z, float regX, float regY, float regWidth, float regHeight, float r) -
drawRotatedTextureRegion
-
drawRotatedTextureRegion
public void drawRotatedTextureRegion(float x1, float y1, float x2, float y2, float z, float s1, float t1, float s2, float t2, float r) -
drawRotatedTextureRegion
public void drawRotatedTextureRegion(float x1, float y1, float x2, float y2, float z, float s1, float t1, float s2, float t2, Color c, float r) -
drawTextureRegion
public void drawTextureRegion(Texture texture, float x, float y, float z, float regX, float regY, float regWidth, float regHeight) Draws a texture region on specified coordinates.- Parameters:
texture
- Used for getting width and height of the texturex
- X position of the texturey
- Y position of the textureregX
- X position of the texture regionregY
- Y position of the texture regionregWidth
- Width of the texture regionregHeight
- Height of the texture region
-
drawTextureRegion
public void drawTextureRegion(Texture texture, float x, float y, float z, float regX, float regY, float regWidth, float regHeight, Color c) Draws a texture region on specified coordinates.- Parameters:
texture
- Used for getting width and height of the texturex
- X position of the texturey
- Y position of the textureregX
- X position of the texture regionregY
- Y position of the texture regionregWidth
- Width of the texture regionregHeight
- Height of the texture regionc
- The color to use
-
drawTextureRegion
public void drawTextureRegion(float x1, float y1, float x2, float y2, float z, float s1, float t1, float s2, float t2) Draws a texture region on specified coordinates.- Parameters:
x1
- Bottom left x positiony1
- Bottom left y positionx2
- Top right x positiony2
- Top right y positions1
- Bottom left s coordinatet1
- Bottom left t coordinates2
- Top right s coordinatet2
- Top right t coordinate
-
drawTextureRegion
public void drawTextureRegion(float x1, float y1, float x2, float y2, float z, float s1, float t1, float s2, float t2, Color c) Draws a texture region on specified coordinates.- Parameters:
x1
- Bottom left x positiony1
- Bottom left y positionx2
- Top right x positiony2
- Top right y positions1
- Bottom left s coordinatet1
- Bottom left t coordinates2
- Top right s coordinatet2
- Top right t coordinatec
- The color to use
-
drawTextureRegion
public void drawTextureRegion(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, float z, float s1, float t1, float s2, float t2, Color c) Draws a texture region on specified coordinates. -
outOfBounds
public boolean outOfBounds(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4) Checks if a quad is outside the screen bounds. -
outOfBounds
public boolean outOfBounds(float x1, float y1, float x2, float y2) Checks if a line is outside the screen bounds. -
outOfBounds
public boolean outOfBounds(float x, float y) Checks if coordinates are outside the screen bounds.- Parameters:
x
- X positiony
- Y position- Returns:
- True if the coordinate is outside of bounds
-
destroy
public void destroy()Disposes renderer and cleans up its used data. -
resize
public void resize()Updates the projection matrix according to the window's dimensions. -
getWidth
public int getWidth() -
getHeight
public int getHeight() -
isDrawing
public boolean isDrawing() -
getFbo
-