Class RenderModuleWindow

java.lang.Object
io.codetoil.curved_spacetime.render.RenderModuleWindow
Direct Known Subclasses:
GLFWRenderModuleWindow

public abstract class RenderModuleWindow extends Object
A window, and the keyboard and mouse attached to it, independent of the windowing library.

Implementations supply the platform behaviour; this class holds only what every window has and the input plumbing that goes with it. An implementation is expected to create its input objects during init(), since pollEvents() dereferences them.

  • Field Details

    • mainModuleEngine

      protected final MainModuleEngine mainModuleEngine
      The engine this window belongs to.
    • title

      protected final String title
      The window's title bar text.
    • logger

      protected final Logger logger
      The logger this window writes its diagnostics to.
    • renderModuleKeyboardInput

      protected RenderModuleKeyboardInput renderModuleKeyboardInput
      Keyboard state for this window, created during init().
    • renderModuleMouseInput

      protected RenderModuleMouseInput renderModuleMouseInput
      Mouse state for this window, created during init().
    • shouldClose

      protected boolean shouldClose
      Whether the window at the next opportunity. Can be overridden by an implementation.
  • Constructor Details

    • RenderModuleWindow

      protected RenderModuleWindow(MainModuleEngine mainModuleEngine, String title, Logger logger)
      Creates a window bound to the given engine.

      Nothing is opened until init() is called.

      Parameters:
      mainModuleEngine - the engine this window belongs to
      title - the window's title bar text
      logger - the logger to write window diagnostics to
  • Method Details

    • init

      public abstract void init()
      Opens the window and creates its input objects.
    • loop

      public abstract void loop()
      Advances the window by one frame, sampling input and handling a close request.
    • getHeight

      public abstract int getHeight()
      Returns the window's height.
      Returns:
      the current height in pixels
    • getWidth

      public abstract int getWidth()
      Returns the window's width.
      Returns:
      the current width in pixels
    • isInitialized

      public abstract boolean isInitialized()
      Returns whether the window has been initialized
      Returns:
      true if the window is initialized.
    • setShouldClose

      public void setShouldClose()
      Asks the window to close at the next opportunity.
    • shouldClose

      public boolean shouldClose()
      Returns whether the window has been asked to close.
      Returns:
      true once a close has been requested, by this class or by the user
    • clean

      public abstract void clean()
      Destroys the window and releases its platform resources.
    • getKeyboardInput

      public RenderModuleKeyboardInput getKeyboardInput()
      Returns keyboard state for this window.
      Returns:
      the keyboard input, or null before init()
    • getMouseInput

      public RenderModuleMouseInput getMouseInput()
      Returns mouse state for this window.
      Returns:
      the mouse input, or null before init()
    • pollEvents

      public void pollEvents()
      Samples the keyboard and mouse for this frame.
    • resetInput

      public void resetInput()
      Clears per-frame keyboard state, so tapped keys are not reported twice.