Class SolaPlatform

java.lang.Object
technology.sola.engine.core.SolaPlatform

@NullMarked public abstract class SolaPlatform extends Object
SolaPlatform defines the API for a platform to run Sola.
  • Field Details

  • Constructor Details

    • SolaPlatform

      public SolaPlatform()
  • Method Details

    • play

      public void play(Sola sola)
      Main entry point for starting a Sola.
      Parameters:
      sola - the Sola to start
    • getRenderer

      public Renderer getRenderer()
      Returns:
      the platform's Renderer
    • getViewport

      public Viewport getViewport()
      Returns:
      the platform's Viewport
    • getSocketClient

      public SocketClient getSocketClient()
      Returns:
      the platform's SocketClient
    • getRestClient

      public RestClient getRestClient()
      Returns:
      the platform's RestClient
    • getIdentifier

      public abstract SolaPlatformIdentifier getIdentifier()
      Returns:
      the platform's identifier
    • onKeyPressed

      public abstract void onKeyPressed(Consumer<KeyEvent> keyEventConsumer)
      Registers an on key pressed listener.
      Parameters:
      keyEventConsumer - the method called when key is pressed
    • onKeyReleased

      public abstract void onKeyReleased(Consumer<KeyEvent> keyEventConsumer)
      Registers an on key released listener.
      Parameters:
      keyEventConsumer - the method called when key is released
    • onMouseMoved

      public abstract void onMouseMoved(Consumer<MouseEvent> mouseEventConsumer)
      Registers an on mouse moved listener.
      Parameters:
      mouseEventConsumer - the method called when mouse is moved
    • onMousePressed

      public abstract void onMousePressed(Consumer<MouseEvent> mouseEventConsumer)
      Registers an on mouse pressed listener.
      Parameters:
      mouseEventConsumer - the method called when mouse is pressed
    • onMouseReleased

      public abstract void onMouseReleased(Consumer<MouseEvent> mouseEventConsumer)
      Registers an on mouse released listener.
      Parameters:
      mouseEventConsumer - the method called when mouse is released
    • onMouseWheel

      public abstract void onMouseWheel(Consumer<MouseWheelEvent> mouseWheelEventConsumer)
      Registers an on mouse wheel listener.
      Parameters:
      mouseWheelEventConsumer - the method called when a mouse wheel interaction takes place
    • initializePlatform

      protected abstract void initializePlatform(SolaConfiguration solaConfiguration, SolaPlatform.SolaPlatformInitialization solaPlatformInitialization)
      Method to initialize a SolaPlatform. This operation can be async. It will provide the configuration from the ).
      Parameters:
      solaConfiguration - the Sola configuration
      solaPlatformInitialization - call SolaPlatform.SolaPlatformInitialization.finish() when platform initialization is finished
    • beforeRender

      protected abstract void beforeRender(Renderer renderer)
      Method called before each render frame.
      Parameters:
      renderer - the Renderer
    • onRender

      protected abstract void onRender(Renderer renderer)
      Main render frame method.
      Parameters:
      renderer - the Renderer
    • populateAssetLoaderProvider

      protected abstract void populateAssetLoaderProvider(AssetLoaderProvider assetLoaderProvider)
      Method to populate the SolaPlatform AssetLoaderProvider with AssetLoaders that Sola will be able to utilize.
      Parameters:
      assetLoaderProvider - the AssetLoaderProvider
    • buildRenderer

      protected Renderer buildRenderer(SolaConfiguration solaConfiguration)
      Builds the Renderer for this platform. Default implementation will utilize the SoftwareRenderer implementation.
      Parameters:
      solaConfiguration - the SolaConfiguration for the Sola
      Returns:
      the built Renderer
    • buildGameLoop

      protected SolaPlatform.GameLoopProvider buildGameLoop()
      Builds the GameLoop for this platform. Default implementation will utilize the FixedUpdateGameLoop implementation.
      Returns:
      the built GameLoop
    • adjustMouseForViewport

      protected SolaPlatform.MouseCoordinate adjustMouseForViewport(int x, int y)
      Convenience method for calculating adjusted mouse coordinate considering the current AspectMode of the Viewport.
      Parameters:
      x - the raw x coordinate of the mouse click
      y - the raw y coordinate of the mouse click
      Returns:
      the viewport adjusted mouse click coordinate