Class HeadlessRenderer

java.lang.Object
nl.colorize.multimedialib.renderer.headless.HeadlessRenderer
All Implemented Interfaces:
InputDevice, Renderer, SceneContext, Updatable

public class HeadlessRenderer extends Object implements Renderer, SceneContext, InputDevice
Headless renderer implementation which can be used for testing and simulation purposes, and (unlike all other renderers) can be used on platforms without a graphics environment.

The headless renderer can be started without an active animation loop. In this scenatio, all frame updates need to be performed manually.

  • Field Details

    • DEFAULT_FONT

      public static final FontFace DEFAULT_FONT
  • Constructor Details

    • HeadlessRenderer

      public HeadlessRenderer(boolean graphicsEnvironmentEnabled)
  • Method Details

    • start

      public void start(RenderConfig config, Scene initialScene)
      Description copied from interface: Renderer
      Starts this renderer based on the specified configuration. The renderer will initially display the specified scene.

      This method can be called from any thread. The renderer will run in its own thread, which is started by calling this method. All callback methods will be called from the renderer thread.

      Specified by:
      start in interface Renderer
    • start

      public void start(Scene initialScene)
    • terminate

      public void terminate()
      Description copied from interface: SceneContext
      Terminates the renderer, which will end the animation loop and quit the application.
      Specified by:
      terminate in interface SceneContext
    • project

      public Point2D project(Point3D position)
      Description copied from interface: SceneContext
      Returns the 3D world coordinates that correspond to the specified 2D canvas coordinates, based on the current camera position.
      Specified by:
      project in interface SceneContext
    • castPickRay

      public boolean castPickRay(Point2D canvasPosition, Box area)
      Description copied from interface: SceneContext
      Casts a pick ray from the specified 2D canvas position, and returns true if the pick ray intersects with the specified 3D world coordinates.
      Specified by:
      castPickRay in interface SceneContext
    • createMesh

      public Mesh createMesh(Shape3D shape, ColorRGB color)
      Description copied from interface: SceneContext
      Programmatically creates a 3D polygon mesh with a solid color, based on the specified shape.
      Specified by:
      createMesh in interface SceneContext
    • takeScreenshot

      public void takeScreenshot(File screenshotFile)
      Description copied from interface: SceneContext
      Captures a screenshot of the renderer's current graphics and then exports the screenshot to a PNG file.
      Specified by:
      takeScreenshot in interface SceneContext
    • getRendererName

      public String getRendererName()
      Description copied from interface: SceneContext
      Returns the display name for the underlying renderer. The display name will not include the word "renderer".
      Specified by:
      getRendererName in interface SceneContext
    • isSupported

      public boolean isSupported(GraphicsMode graphicsMode)
      Specified by:
      isSupported in interface Renderer
    • getContext

      @Deprecated public SceneContext getContext()
      Deprecated.
    • doFrame

      public void doFrame()
    • doFrame

      public void doFrame(float deltaTime)
    • update

      public void update(float deltaTime)
      Description copied from interface: Updatable
      Updates this object for the current frame. deltaTime indicates the elapsed time since the last frame update, in seconds.
      Specified by:
      update in interface Updatable
    • getInput

      public InputDevice getInput()
      Specified by:
      getInput in interface SceneContext
    • getPointers

      public Iterable<Pointer> getPointers()
      Description copied from interface: InputDevice
      Returns all currently active pointers. Depending on the current platform and device, pointers could be based on mouse input, a trackpad, or touch controls.

      Note that the type of pointer will also influence its behavior. The mouse pointer is always included in this list, since the mouse cursor is always visible. Touch pointer are only available during the touch, as the pointer disappears once the touch event has ended.

      Specified by:
      getPointers in interface InputDevice
    • clearPointerState

      public void clearPointerState()
      Description copied from interface: InputDevice
      Clears all pointer state for all currently active pointers. Using this method is the equivalent of using Pointer.clearState() on all pointers.
      Specified by:
      clearPointerState in interface InputDevice
    • isKeyPressed

      public boolean isKeyPressed(KeyCode keyCode)
      Description copied from interface: InputDevice
      Returns true if the key with the specified key code was pressed during the current frame.
      Specified by:
      isKeyPressed in interface InputDevice
    • isKeyReleased

      public boolean isKeyReleased(KeyCode keyCode)
      Description copied from interface: InputDevice
      Returns true if the key with the specified key code was released during the current frame.
      Specified by:
      isKeyReleased in interface InputDevice
    • requestTextInput

      public nl.colorize.util.Subject<String> requestTextInput(String label, String initialValue)
      Description copied from interface: InputDevice
      Shows a dialog window with a text input field. The dialog window is not part of the scene, it uses the platform's native user interface.
      Specified by:
      requestTextInput in interface InputDevice
    • fillClipboard

      public void fillClipboard(String text)
      Description copied from interface: InputDevice
      Copies the specified text to the system clipboard.
      Specified by:
      fillClipboard in interface InputDevice
    • isGraphicsEnvironmentEnabled

      public boolean isGraphicsEnvironmentEnabled()
    • getConfig

      public RenderConfig getConfig()
      Specified by:
      getConfig in interface SceneContext
    • getGraphics

      public StageVisitor getGraphics()
    • getMediaLoader

      public MediaLoader getMediaLoader()
      Specified by:
      getMediaLoader in interface SceneContext
    • getNetwork

      public Network getNetwork()
      Specified by:
      getNetwork in interface SceneContext
    • getSceneManager

      public SceneManager getSceneManager()
      Specified by:
      getSceneManager in interface SceneContext
    • getStage

      public Stage getStage()
      Specified by:
      getStage in interface SceneContext
    • isTouchAvailable

      public boolean isTouchAvailable()
      Specified by:
      isTouchAvailable in interface InputDevice
    • isKeyboardAvailable

      public boolean isKeyboardAvailable()
      Specified by:
      isKeyboardAvailable in interface InputDevice
    • getPointer

      public Point2D getPointer()
    • isPointerPressed

      public boolean isPointerPressed()
    • isPointerReleased

      public boolean isPointerReleased()
    • setGraphicsEnvironmentEnabled

      public void setGraphicsEnvironmentEnabled(boolean graphicsEnvironmentEnabled)
    • setConfig

      public void setConfig(RenderConfig config)
    • setGraphics

      public void setGraphics(StageVisitor graphics)
    • setMediaLoader

      public void setMediaLoader(MediaLoader mediaLoader)
    • setNetwork

      public void setNetwork(Network network)
    • setSceneManager

      public void setSceneManager(SceneManager sceneManager)
    • setStage

      public void setStage(Stage stage)
    • setTouchAvailable

      public void setTouchAvailable(boolean touchAvailable)
    • setKeyboardAvailable

      public void setKeyboardAvailable(boolean keyboardAvailable)
    • setPointer

      public void setPointer(Point2D pointer)
    • setPointerPressed

      public void setPointerPressed(boolean pointerPressed)
    • setPointerReleased

      public void setPointerReleased(boolean pointerReleased)