Class SceneCallback

java.lang.Object
io.codetoil.curved_spacetime.scene.SceneCallback
Direct Known Subclasses:
GLFWRenderModuleRenderer

public abstract class SceneCallback extends Object
Work the engine runs once at start-up and then repeatedly, against one particular scene.

A module does not register these directly. It registers a generator with MainModuleEngine.registerSceneCallbackGenerator(Function), and the engine applies that generator to every scene, so a module that wants to act on scenes gets one callback per scene without having to track scenes itself.

The engine calls init() once, then loop() at the configured frame rate, and clean() on shutdown, all on its single callback thread.

  • 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.
    protected final Scene
    The scene this callback acts on.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    SceneCallback(MainModuleEngine mainModuleEngine, Scene scene)
    Creates a callback bound to the given engine and scene.
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract void
    Releases whatever this callback acquired in init().
    abstract void
    Sets this callback up against its scene.
    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.
    • scene

      protected final Scene scene
      The scene this callback acts on.
    • 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

    • SceneCallback

      protected SceneCallback(MainModuleEngine mainModuleEngine, Scene scene)
      Creates a callback bound to the given engine and scene.
      Parameters:
      mainModuleEngine - the engine this callback belongs to
      scene - the scene this callback acts on
  • 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 against its scene.

      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().