All Known Implementing Classes:
SoftwareRenderer

@NullMarked public interface Renderer
Renderer defines the API for a sola game engine renderer. SoftwareRenderer is the default implementation but each SolaPlatform can implement their own as well to take advantage of the GPU.
  • Method Details

    • setBlendFunction

      void setBlendFunction(BlendFunction blendFunction)
      Sets the BlendFunction that should be used.
      Parameters:
      blendFunction - the new BlendMode to use
    • getBlendFunction

      BlendFunction getBlendFunction()
      Returns:
      the current BlendFunction being used when drawing
    • getFont

      Font getFont()
      Returns:
      the current Font being used for drawing text
    • setFont

      void setFont(Font font)
      Sets the Font to use when drawing text.
      Parameters:
      font - the new Font to use
    • getWidth

      int getWidth()
      Returns:
      the width of the Renderer
    • getHeight

      int getHeight()
      Returns:
      the height of the Renderer
    • createRendererForImage

      Renderer createRendererForImage(SolaImage solaImage)
      Creates a new Renderer instance that draws to a SolaImage instead of the screen.
      Parameters:
      solaImage - the image to draw to
      Returns:
      a new renderer instance drawing to an image
    • createLayers

      default void createLayers(String... layerNames)
      Creates new layers for drawing on.
      Parameters:
      layerNames - the names of the layers to create
    • getLayers

      List<Layer> getLayers()
      Returns:
      the List of Layers this Renderer has
    • getLayer

      default Layer getLayer(String name)
      Gets a Layer by name.
      Parameters:
      name - the name of the layer to get
      Returns:
      the layer
    • drawToLayer

      default void drawToLayer(String layerName, DrawItem drawItem)
      Adds a DrawItem to a layer at default order.
      Parameters:
      layerName - name of the layer to add draw item to
      drawItem - the draw item
    • drawToLayer

      default void drawToLayer(String layerName, int order, DrawItem drawItem)
      Adds a DrawItem to a layer at desired order. Higher order render later.
      Parameters:
      layerName - name of the layer to add draw item to
      order - the order of the draw item
      drawItem - the draw item
    • setClamp

      void setClamp(int x, int y, int width, int height)
      Restricts rendering of pixels within a rectangle. Any setPixel call outside of this rectangle will be ignored.
      Parameters:
      x - top left coordinate x
      y - top left coordinate y
      width - width of the rectangle
      height - height of the rectangle
    • resetClamp

      default void resetClamp()
      Resets the rendering clamp to the full size of the Renderer.
    • clear

      default void clear()
      Sets all pixels to Color.BLACK
    • clear

      void clear(Color color)
      Sets all pixels to desired Color.
      Parameters:
      color - the Color to set all pixels to
    • setPixel

      void setPixel(int x, int y, Color color)
      Sets the Color of a pixel at coordinate.
      Parameters:
      x - the x coordinate of the pixel
      y - the y coordinate of the pixel
      color - the new Color
    • setPixel

      default void setPixel(int x, int y, int color)
      Sets the Color of a pixel at coordinate.
      Parameters:
      x - the x coordinate of the pixel
      y - the y coordinate of the pixel
      color - the new Color
    • drawString

      default void drawString(String text, float x, float y, Color color)
      Draws a string of text using the current Font.
      Parameters:
      text - the text to draw
      x - the x coordinate to draw it at
      y - the y coordinate to draw it at
      color - the Color of the text
    • drawString

      default void drawString(String text, AffineTransform affineTransform, Color color)
      Draws a string of text using the current Font and applies the desired AffineTransform to the rendered string.
      Parameters:
      text - the text to draw
      affineTransform - the transform to apply
      color - the Color of the text
    • drawLine

      void drawLine(float x, float y, float x2, float y2, Color color)
      Draws a line.
      Parameters:
      x - the x coordinate of the first point
      y - the y coordinate of the first point
      x2 - the x coordinate of the second point
      y2 - the y coordinate of the second point
      color - the Color of the line
    • drawRect

      void drawRect(float x, float y, float width, float height, Color color)
      Draws an unfilled rectangle.
      Parameters:
      x - top left coordinate x
      y - top left coordinate y
      width - width of the rectangle
      height - height of the rectangle
      color - Color of the rectangle
    • fillRect

      void fillRect(float x, float y, float width, float height, Color color)
      Draws a filled rectangle.
      Parameters:
      x - top left coordinate x
      y - top left coordinate y
      width - width of the rectangle
      height - height of the rectangle
      color - Color of the rectangle
    • drawCircle

      void drawCircle(float x, float y, float radius, Color color)
      Draws an unfilled circle. Uses Bresenham's circle drawing algorithm.
      Parameters:
      x - top left coordinate x
      y - top left coordinate y
      radius - radius of the circle
      color - Color of the circle
    • fillCircle

      void fillCircle(float x, float y, float radius, Color color)
      Draws a filled circle.
      Parameters:
      x - top left coordinate x
      y - top left coordinate y
      radius - radius of the circle
      color - Color of the circle
    • drawTriangle

      default void drawTriangle(float x1, float y1, float x2, float y2, float x3, float y3, Color color)
      Draws a triangle.
      Parameters:
      x1 - x coordinate for the first point
      y1 - y coordinate for the first point
      x2 - x coordinate for the second point
      y2 - y coordinate for the second point
      x3 - x coordinate for the third point
      y3 - y coordinate for the third point
      color - Color of the triangle
    • fillTriangle

      void fillTriangle(float x1, float y1, float x2, float y2, float x3, float y3, Color color)
      Draws a filled triangle.
      Parameters:
      x1 - x coordinate for the first point
      y1 - y coordinate for the first point
      x2 - x coordinate for the second point
      y2 - y coordinate for the second point
      x3 - x coordinate for the third point
      y3 - y coordinate for the third point
      color - Color of the triangle
    • drawImage

      void drawImage(SolaImage solaImage, float x, float y)
      Draws a SolaImage at desired coordinate. The coordinate will be the top-left of the image drawn.
      Parameters:
      solaImage - the SolaImage to draw
      x - top left coordinate x
      y - top left coordinate y
    • drawImage

      void drawImage(SolaImage solaImage, AffineTransform affineTransform)
      Draws a SolaImage with AffineTransform applied.
      Parameters:
      solaImage - the SolaImage to draw
      affineTransform - the transform to apply
    • drawImage

      void drawImage(SolaImage solaImage, float x, float y, float width, float height)
      Draws a SolaImage scaled to fit within a rectangle specified by x,y, width and height.
      Parameters:
      solaImage - the SolaImage to draw
      x - top left coordinate x of the scaling rectangle
      y - top left coordinate y of the scaling rectangle
      width - the width of the scaling rectangle
      height - the height of the scaling rectangle