Class RenderConfig

java.lang.Object
nl.colorize.multimedialib.renderer.RenderConfig

public final class RenderConfig extends Object
Used to configure and launch the renderer, and can also be used to obtain this configuration at runtime. Launching the renderer effectively "starts" the MultimediaLib application, and is therefore typically done from the application's main method. Application code will not directly interact with the renderer. The renderer runs in a separate thread, and will invoke callback methods that receive the SceneContext to interact with the underlying renderer.

The renderer configuration consists of the following aspects:

Renderer: MultimediaLib supports multiple renderer implementations. Applications can select a renderer implementation based on the target platform(s) and whether the application uses 2D or 3D graphics.

Canvas: Defines how the renderer should display graphics for the current screen size and resolution. See Canvas for more information.

Framerate: The renderer will attempt to perform frame updates as close as possible to the target framerate.

Window: Defines how the application window should be displayed on desktop platforms. See WindowOptions for more information.

Error handler: The default error handler will log the error and then terminate the renderer. Additional error handlers can be added in order to customize this behavior.

Global handlers: The configuration can define "global" handlers that are always active, independent of the currently active scene. Global handlers can also be registered at runtime, using SceneContext.attachGlobal(Scene).

Simulation mode: During development, the launcher can "simulate" the behavior of mobile platforms when running on desktop platforms. This is comparable to "responsive design mode" in desktop browsers. Simulation mode can be activated programmatically, but it can also be enabled using the system property multimedialib.simulation.

  • Method Details

    • isSimulationMode

      public boolean isSimulationMode()
    • start

      public void start(Scene initialScene)
      Uses this configuration to start the renderer, initially displaying the provided scene. Once the renderer has been started, this configuration will be available to the scene at runtime via the SceneContext.
      Throws:
      UnsupportedOperationException - if the renderer does not support the graphics mode defined in this configuration.
    • forDesktop

      public static RenderConfig forDesktop(String renderer, GraphicsMode graphicsMode, Canvas canvas)
      Starts configuring the desktop platform renderer with the specified name and graphics mode.
      Throws:
      IllegalStateException - if the current platform is not a desktop platform.
      IllegalArgumentException - if no desktop renderer with the requested name exists.
      UnsupportedOperationException - if the requested renderer does not support the requested graphics mode.
    • forBrowser

      public static RenderConfig forBrowser(String renderer, GraphicsMode graphicsMode, Canvas canvas)
      Starts configuring the browser-based renderer with the specified name and graphics mode.
      Throws:
      IllegalStateException - if the current platform is not browser-based.
      IllegalArgumentException - if no browser-based renderer with the requested name exists.
      UnsupportedOperationException - if the requested renderer does not support the requested graphics mode.
    • headless

      public static RenderConfig headless(GraphicsMode graphicsMode, Canvas canvas)
      Starts configuring a headless renderer that will simulate the requested graphics mode.
    • getLauncher

      public Supplier<Renderer> getLauncher()
    • getGraphicsMode

      public GraphicsMode getGraphicsMode()
    • getCanvas

      public Canvas getCanvas()
    • getFramerate

      public int getFramerate()
    • getWindowOptions

      public WindowOptions getWindowOptions()
    • getErrorHandler

      public ErrorHandler getErrorHandler()
    • getGlobalHandlers

      public List<Scene> getGlobalHandlers()
    • getSimulationMode

      public String getSimulationMode()
    • setFramerate

      public void setFramerate(int framerate)
    • setErrorHandler

      public void setErrorHandler(ErrorHandler errorHandler)
    • setSimulationMode

      public void setSimulationMode(String simulationMode)