Class MainCallback

java.lang.Object
io.codetoil.curved_spacetime.MainCallback
Direct Known Subclasses:
VulkanModuleVulkan

public abstract class MainCallback extends Object
Work the engine runs once at start-up and then repeatedly, independent of any scene.

A module registers one of these with MainModuleEngine.registerMainCallback(MainCallback). The engine calls init() once, then loop() at the configured frame rate, and clean() on shutdown. All three run on the engine's single callback thread, so an implementation may hold mutable state without synchronising it against the other callbacks.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected boolean
    Whether this callback has finished setting itself up.
    protected final MainModuleEngine
    The engine this callback belongs to.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    MainCallback(MainModuleEngine mainModuleEngine)
    Creates a callback bound to the given engine.
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract void
    Releases whatever this callback acquired in init().
    abstract void
    Sets this callback up.
    boolean
    Returns whether this callback has finished setting itself up.
    abstract void
    Advances this callback by one frame.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • mainModuleEngine

      protected final MainModuleEngine mainModuleEngine
      The engine this callback belongs to.
    • initialized

      protected boolean initialized
      Whether this callback has finished setting itself up.

      Deliberately not maintained by this class. An implementation sets this to true from its own init(), at the point where its setup is genuinely complete — only the implementation knows when that is.

  • Constructor Details

    • MainCallback

      protected MainCallback(MainModuleEngine mainModuleEngine)
      Creates a callback bound to the given engine.
      Parameters:
      mainModuleEngine - the engine this callback belongs to
  • Method Details

    • isInitialized

      public boolean isInitialized()
      Returns whether this callback has finished setting itself up.
      Returns:
      true once the implementation has flagged its own setup complete
    • init

      public abstract void init()
      Sets this callback up.

      Called once, before the first loop(). An implementation should set initialized when it finishes.

    • loop

      public abstract void loop()
      Advances this callback by one frame.

      Called repeatedly at the frame rate the engine's configuration specifies.

    • clean

      public abstract void clean()
      Releases whatever this callback acquired in init().