Class GLFWContext.MainLoop
java.lang.Object
com.blackrook.gloop.glfw.GLFWContext.MainLoop
- All Implemented Interfaces:
Runnable
- Enclosing class:
GLFWContext
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddRunnableAlways(Runnable runnable) Adds a Runnable that is invoked at the beginning of the loop such that they execute on the main thread.voidaddRunnableAlwaysAfterPoll(Runnable runnable) Adds a Runnable that is invoked at the end of the loop after events are polled such that they execute on the main thread, after event/input polling.voidaddRunnableOnce(Runnable runnable) Adds a Runnable that is invoked only once at the beginning of the loop such that it executes on the main thread, but before the "always runnables" are invoked.voidaddRunnableOnLoopExit(Runnable runnable) Adds a Runnable that is invoked only once at the end of the loop such that it executes on the main thread, but only once the loop is escaped due to a closing window.voidremoveRunnableAlways(Runnable runnable) Removes a Runnable that was added byaddRunnableAlways(Runnable).voidremoveRunnableAlwaysAfterPoll(Runnable runnable) Removes a Runnable that was added byaddRunnableAlwaysAfterPoll(Runnable).voidrun()Enters a loop that sets the window and input system, and polls for events and input until the window is closed.voidsetEventWait(long eventWaitMillis) Sets the amount of time in milliseconds to wait for new events in the loop.voidsetLoopWaitMillis(long loopWaitMillis) Sets the amount of time in milliseconds to wait at the end of the loop after all hooks run and all events are polled.voidsetShutDownOnExit(boolean shutDownOnExit) Sets if GLFW shuts down on exit.
-
Method Details
-
addRunnableAlways
Adds a Runnable that is invoked at the beginning of the loop such that they execute on the main thread.Runnables are executed in the order that they are added this way.
- Parameters:
runnable- the runnable to add.
-
removeRunnableAlways
Removes a Runnable that was added byaddRunnableAlways(Runnable).- Parameters:
runnable- the runnable to remove.
-
addRunnableAlwaysAfterPoll
Adds a Runnable that is invoked at the end of the loop after events are polled such that they execute on the main thread, after event/input polling.Runnables are executed in the order that they are added this way, after event/input polling.
- Parameters:
runnable- the runnable to add.
-
removeRunnableAlwaysAfterPoll
Removes a Runnable that was added byaddRunnableAlwaysAfterPoll(Runnable).- Parameters:
runnable- the runnable to remove.
-
addRunnableOnce
Adds a Runnable that is invoked only once at the beginning of the loop such that it executes on the main thread, but before the "always runnables" are invoked.Runnables are executed in the order that they are added this way.
NOTE: You can invoke most things that require being on the "main thread" using this, provided that the loop is active!
- Parameters:
runnable- the runnable to add.
-
addRunnableOnLoopExit
Adds a Runnable that is invoked only once at the end of the loop such that it executes on the main thread, but only once the loop is escaped due to a closing window.Runnables are executed in the order that they are added this way.
- Parameters:
runnable- the runnable to add.
-
setEventWait
public void setEventWait(long eventWaitMillis) Sets the amount of time in milliseconds to wait for new events in the loop. By the time this wait occurs, joystick events will have been polled. Default is 1 millisecond.- Parameters:
eventWaitMillis- the time to wait in milliseconds, or 0 or less for no wait.
-
setLoopWaitMillis
public void setLoopWaitMillis(long loopWaitMillis) Sets the amount of time in milliseconds to wait at the end of the loop after all hooks run and all events are polled. Default is 0 milliseconds (no wait).- Parameters:
loopWaitMillis- the time to wait in milliseconds, or 0 or less for no wait.
-
setShutDownOnExit
public void setShutDownOnExit(boolean shutDownOnExit) Sets if GLFW shuts down on exit. If enabled, once the loop exits, the window is destroyed, input callbacks are freed, andGLFWContext.terminate()is called. Disabled by default.- Parameters:
shutDownOnExit- true to enable, false to disable.
-
run
public void run()Enters a loop that sets the window and input system, and polls for events and input until the window is closed. When the window closes, the loop exits.It is strongly advised that you use this method for starting the main event loop.
This must only be called from the main thread to ensure that everything works properly!
-