Interface Application
- All Known Implementing Classes:
LegacyApplication
,SimpleApplication
,VRApplication
Application
interface represents the minimum exposed
capabilities of a concrete jME3 application.-
Method Summary
Modifier and TypeMethodDescriptionvoid
Enqueues a runnable object to execute in the jME3 rendering thread.<V> Future<V>
Enqueues a task/callable object to execute in the jME3 rendering thread.Returns the current AppProfiler hook, or null if none is set.Determine the application's behavior when unfocused.getTimer()
boolean
Returns true if pause on lost focus is enabled, false otherwise.void
restart()
Restarts the context, applying any changed settings.void
setAppProfiler
(AppProfiler prof) Sets an AppProfiler hook that will be called back for specific steps within a single update frame.void
setLostFocusBehavior
(LostFocusBehavior lostFocusBehavior) Changes the application's behavior when unfocused.void
setPauseOnLostFocus
(boolean pauseOnLostFocus) Enables or disables pause on lost focus.void
setSettings
(AppSettings settings) Set the display settings to define the display created.void
Sets the Timer implementation that will be used for calculating frame times.void
start()
Starts the application.void
start
(boolean waitFor) Starts the application.void
stop()
Requests the context to close, shutting down the main loop and making necessary cleanup operations.void
stop
(boolean waitFor) Requests the context to close, shutting down the main loop and making necessary cleanup operations.
-
Method Details
-
getLostFocusBehavior
LostFocusBehavior getLostFocusBehavior()Determine the application's behavior when unfocused.- Returns:
- The lost focus behavior of the application.
-
setLostFocusBehavior
Changes the application's behavior when unfocused. By default, the application willthrottle the update loop
so as not to use 100% of the CPU when it is out of focus, e.g. alt-tabbed, minimized, or obstructed by another window.- Parameters:
lostFocusBehavior
- The new lost focus behavior to use.- See Also:
-
isPauseOnLostFocus
boolean isPauseOnLostFocus()Returns true if pause on lost focus is enabled, false otherwise.- Returns:
- true if pause on lost focus is enabled
- See Also:
-
setPauseOnLostFocus
void setPauseOnLostFocus(boolean pauseOnLostFocus) Enables or disables pause on lost focus.By default, pause on lost focus is enabled. If enabled, the application will stop updating when it loses focus or becomes inactive (e.g. alt-tab). For online or real-time applications, this might not be preferable, so this feature should be disabled. For other applications, it is best to keep it enabled so that CPU is not used unnecessarily.
- Parameters:
pauseOnLostFocus
- True to enable pause on lost focus, false otherwise.- See Also:
-
setSettings
Set the display settings to define the display created.Examples of display parameters include display pixel width and height, color bit depth, z-buffer bits, anti-aliasing samples, and update frequency. If this method is called while the application is already running, then
restart()
must be called to apply the settings to the display.- Parameters:
settings
- The settings to set.
-
setTimer
Sets the Timer implementation that will be used for calculating frame times. By default, Application will use the Timer as returned by the current JmeContext implementation.- Parameters:
timer
- the desired timer (alias created)
-
getTimer
Timer getTimer() -
getAssetManager
AssetManager getAssetManager()- Returns:
- The
asset manager
for this application.
-
getInputManager
InputManager getInputManager()- Returns:
- the
input manager
.
-
getStateManager
AppStateManager getStateManager()- Returns:
- the
app state manager
-
getRenderManager
RenderManager getRenderManager()- Returns:
- the
render manager
-
getRenderer
Renderer getRenderer()- Returns:
- The
renderer
for the application
-
getAudioRenderer
AudioRenderer getAudioRenderer()- Returns:
- The
audio renderer
for the application
-
getListener
Listener getListener()- Returns:
- The
listener
object for audio
-
getContext
JmeContext getContext()- Returns:
- The
display context
for the application
-
getCamera
Camera getCamera()- Returns:
- The main
camera
for the application
-
start
void start()Starts the application. A bug occurring when using LWJGL3 prevents this method from returning until after the application is stopped on macOS. -
start
void start(boolean waitFor) Starts the application. A bug occurring when using LWJGL3 prevents this method from returning until after the application is stopped on macOS.- Parameters:
waitFor
- true→wait for the context to be initialized, false→don't wait
-
setAppProfiler
Sets an AppProfiler hook that will be called back for specific steps within a single update frame. Value defaults to null.- Parameters:
prof
- the profiler to use (alias created) or null for none (default=null)
-
getAppProfiler
AppProfiler getAppProfiler()Returns the current AppProfiler hook, or null if none is set.- Returns:
- the pre-existing instance, or null if none
-
restart
void restart()Restarts the context, applying any changed settings.Changes to the
AppSettings
of this Application are not applied immediately; calling this method forces the context to restart, applying the new settings. -
stop
void stop()Requests the context to close, shutting down the main loop and making necessary cleanup operations. Same as calling stop(false)- See Also:
-
stop
void stop(boolean waitFor) Requests the context to close, shutting down the main loop and making necessary cleanup operations. After the application has stopped, it cannot be used anymore.- Parameters:
waitFor
- true→wait for the context to be fully destroyed, true→don't wait
-
enqueue
Enqueues a task/callable object to execute in the jME3 rendering thread.Callables are executed right at the beginning of the main loop. They are executed even if the application is currently paused or out of focus.
- Type Parameters:
V
- type of result returned by the Callable- Parameters:
callable
- The callable to run in the main jME3 thread- Returns:
- a new instance
-
enqueue
Enqueues a runnable object to execute in the jME3 rendering thread.Runnables are executed right at the beginning of the main loop. They are executed even if the application is currently paused or out of focus.
- Parameters:
runnable
- The runnable to run in the main jME3 thread
-
getGuiViewPort
ViewPort getGuiViewPort()- Returns:
- The GUI viewport. Which is used for the on screen statistics and FPS.
-
getViewPort
ViewPort getViewPort()
-