Class RenderModuleWindow
java.lang.Object
io.codetoil.curved_spacetime.render.RenderModuleWindow
- Direct Known Subclasses:
GLFWRenderModuleWindow
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 Summary
FieldsModifier and TypeFieldDescriptionprotected final LoggerThe logger this window writes its diagnostics to.protected final MainModuleEngineThe engine this window belongs to.protected RenderModuleKeyboardInputKeyboard state for this window, created duringinit().protected RenderModuleMouseInputMouse state for this window, created duringinit().protected booleanWhether the window at the next opportunity.protected final StringThe window's title bar text. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedRenderModuleWindow(MainModuleEngine mainModuleEngine, String title, Logger logger) Creates a window bound to the given engine. -
Method Summary
Modifier and TypeMethodDescriptionabstract voidclean()Destroys the window and releases its platform resources.abstract intReturns the window's height.Returns keyboard state for this window.Returns mouse state for this window.abstract intgetWidth()Returns the window's width.abstract voidinit()Opens the window and creates its input objects.abstract booleanReturns whether the window has been initializedabstract voidloop()Advances the window by one frame, sampling input and handling a close request.voidSamples the keyboard and mouse for this frame.voidClears per-frame keyboard state, so tapped keys are not reported twice.voidAsks the window to close at the next opportunity.booleanReturns whether the window has been asked to close.
-
Field Details
-
mainModuleEngine
The engine this window belongs to. -
title
The window's title bar text. -
logger
The logger this window writes its diagnostics to. -
renderModuleKeyboardInput
Keyboard state for this window, created duringinit(). -
renderModuleMouseInput
Mouse state for this window, created duringinit(). -
shouldClose
protected boolean shouldCloseWhether the window at the next opportunity. Can be overridden by an implementation.
-
-
Constructor Details
-
RenderModuleWindow
Creates a window bound to the given engine.Nothing is opened until
init()is called.- Parameters:
mainModuleEngine- the engine this window belongs totitle- the window's title bar textlogger- 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:
trueif 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:
trueonce 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
Returns keyboard state for this window.- Returns:
- the keyboard input, or
nullbeforeinit()
-
getMouseInput
Returns mouse state for this window.- Returns:
- the mouse input, or
nullbeforeinit()
-
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.
-