Class Renderer

java.lang.Object
dev.prozilla.pine.core.rendering.Renderer
All Implemented Interfaces:
Lifecycle

public class Renderer extends Object implements Lifecycle
Handles rendering process.
  • Field Details

    • MAX_TEXTURES

      public static final int MAX_TEXTURES
      Matches the length of uTextures in the fragment shader.
      See Also:
    • VERTEX_BUFFER_SIZE

      public static final int VERTEX_BUFFER_SIZE
      The amount of strides to fit into a single vertex buffer.
      See Also:
  • Constructor Details

  • Method Details

    • init

      public void init()
      Description copied from interface: Lifecycle
      Initializes the object before the game loop starts.
      Specified by:
      init in interface Lifecycle
    • initPreview

      public void initPreview(int width, int height)
    • clear

      public void clear()
      Clears the drawing area.
    • begin

      public void begin() throws IllegalStateException
      Begin rendering.
      Throws:
      IllegalStateException
    • end

      public void end() throws IllegalStateException
      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

      public int getDebugTextWidth(CharSequence text)
      Calculates total width of a debug text.
      Parameters:
      text - The text
      Returns:
      Total width of the text
    • getDebugTextHeight

      public int getDebugTextHeight(CharSequence text)
      Calculates total height of a debug text.
      Parameters:
      text - The text
      Returns:
      Total width of the text
    • drawDebugText

      public void drawDebugText(CharSequence text, float x, float y)
      Draw debug text at the specified position.
      Parameters:
      text - TextRenderer to draw
      x - X coordinate of the text position
      y - Y coordinate of the text position
    • drawDebugText

      public void drawDebugText(CharSequence text, float x, float y, Color c)
      Draw debug text at the specified position and color.
      Parameters:
      text - TextRenderer to draw
      x - X coordinate of the text position
      y - Y coordinate of the text position
      c - Color to use
    • getTextSize

      public Vector2i getTextSize(CharSequence text)
    • getTextSize

      public Vector2i getTextSize(Font font, CharSequence text)
    • getTextWidth

      public int getTextWidth(CharSequence text)
    • getTextWidth

      public int getTextWidth(Font font, CharSequence text)
      Calculates total width of a text.
      Parameters:
      text - The text
      Returns:
      Total width of the text
    • getTextHeight

      public int getTextHeight(CharSequence text)
    • getTextHeight

      public int getTextHeight(Font font, CharSequence text)
      Calculates total height of a text.
      Parameters:
      text - The text
      Returns:
      Total width of the text
    • drawText

      public void drawText(CharSequence text, float x, float y, float z)
    • drawText

      public void drawText(Font font, CharSequence text, float x, float y, float z)
      Draw text at the specified position.
      Parameters:
      text - TextRenderer to draw
      x - X coordinate of the text position
      y - Y coordinate of the text position
    • drawText

      public void drawText(CharSequence text, float x, float y, float z, Color c)
    • drawText

      public void drawText(Font font, CharSequence text, float x, float y, float z, Color c)
      Draw text at the specified position and color.
      Parameters:
      text - TextRenderer to draw
      x - X coordinate of the text position
      y - Y coordinate of the text position
      c - 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 position
      y - Y position
      width - Width of the rectangle
      height - Height of the rectangle
    • drawRect

      public void drawRect(float x, float y, float z, float width, float height, Color c)
      Draws a colored rectangle at the given position.
      Parameters:
      x - X position
      y - Y position
      width - Width of the rectangle
      height - Height of the rectangle
      c - Color
    • drawRotatedTexture

      public void drawRotatedTexture(Texture texture, float x, float y, float z, float r)
    • drawRotatedTexture

      public void drawRotatedTexture(Texture texture, float x, float y, float z, Color c, float r)
    • drawTexture

      public void drawTexture(Texture texture, float x, float y, float z)
      Draws a texture on specified coordinates.
      Parameters:
      texture - Used for getting width and height of the texture
      x - X position of the texture
      y - Y position of the texture
    • drawTexture

      public void drawTexture(Texture texture, float x, float y, float z, Color c)
      Draws a texture on specified coordinates and with specified color.
      Parameters:
      texture - Used for getting width and height of the texture
      x - X position of the texture
      y - Y position of the texture
      c - 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

      public void drawRotatedTextureRegion(Texture texture, float x, float y, float z, float regX, float regY, float regWidth, float regHeight, Color c, float r)
    • 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 texture
      x - X position of the texture
      y - Y position of the texture
      regX - X position of the texture region
      regY - Y position of the texture region
      regWidth - Width of the texture region
      regHeight - 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 texture
      x - X position of the texture
      y - Y position of the texture
      regX - X position of the texture region
      regY - Y position of the texture region
      regWidth - Width of the texture region
      regHeight - Height of the texture region
      c - 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 position
      y1 - Bottom left y position
      x2 - Top right x position
      y2 - Top right y position
      s1 - Bottom left s coordinate
      t1 - Bottom left t coordinate
      s2 - Top right s coordinate
      t2 - 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 position
      y1 - Bottom left y position
      x2 - Top right x position
      y2 - Top right y position
      s1 - Bottom left s coordinate
      t1 - Bottom left t coordinate
      s2 - Top right s coordinate
      t2 - Top right t coordinate
      c - 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 position
      y - Y position
      Returns:
      True if the coordinate is outside of bounds
    • destroy

      public void destroy()
      Disposes renderer and cleans up its used data.
      Specified by:
      destroy in interface Lifecycle
    • 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

      public FrameBufferObject getFbo()