java.lang.Object
technology.sola.engine.core.SolaPlatform
SolaPlatform defines the API for a platform to run
Sola
.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static interface
GameLoopProvider is aFunctionalInterface
defining the contract for providing aGameLoop
implementation for the sola game engine to use.protected static final record
Holds the coordinate of the mouse.protected static interface
SolaPlatformInitialization is aFunctionalInterface
defining the contract for finishing initialization of aSolaPlatform
. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected GameLoop
TheGameLoop
for the platform.protected Renderer
TheRenderer
for the platform.protected RestClient
TheRestClient
for the platform.protected SocketClient
TheSocketClient
for the platform.protected EventHub
protected Viewport
TheViewport
for the platform. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected SolaPlatform.MouseCoordinate
adjustMouseForViewport
(int x, int y) Convenience method for calculating adjusted mouse coordinate considering the currentAspectMode
of theViewport
.protected abstract void
beforeRender
(Renderer renderer) Method called before each render frame.protected SolaPlatform.GameLoopProvider
Builds theGameLoop
for this platform.protected Renderer
buildRenderer
(SolaConfiguration solaConfiguration) Builds theRenderer
for this platform.abstract SolaPlatformIdentifier
protected abstract void
initializePlatform
(SolaConfiguration solaConfiguration, SolaPlatform.SolaPlatformInitialization solaPlatformInitialization) Method to initialize aSolaPlatform
.abstract void
onKeyPressed
(Consumer<KeyEvent> keyEventConsumer) Registers an on key pressed listener.abstract void
onKeyReleased
(Consumer<KeyEvent> keyEventConsumer) Registers an on key released listener.abstract void
onMouseMoved
(Consumer<MouseEvent> mouseEventConsumer) Registers an on mouse moved listener.abstract void
onMousePressed
(Consumer<MouseEvent> mouseEventConsumer) Registers an on mouse pressed listener.abstract void
onMouseReleased
(Consumer<MouseEvent> mouseEventConsumer) Registers an on mouse released listener.abstract void
onMouseWheel
(Consumer<MouseWheelEvent> mouseWheelEventConsumer) Registers an on mouse wheel listener.protected abstract void
Main render frame method.void
Main entry point for starting aSola
.protected abstract void
populateAssetLoaderProvider
(AssetLoaderProvider assetLoaderProvider) Method to populate theSolaPlatform
AssetLoaderProvider
withAssetLoader
s thatSola
will be able to utilize.
-
Field Details
-
renderer
TheRenderer
for the platform. -
gameLoop
TheGameLoop
for the platform. -
viewport
TheViewport
for the platform. -
solaEventHub
-
socketClient
TheSocketClient
for the platform. -
restClient
TheRestClient
for the platform.
-
-
Constructor Details
-
SolaPlatform
public SolaPlatform()
-
-
Method Details
-
play
Main entry point for starting aSola
.- Parameters:
sola
- theSola
to start
-
getRenderer
- Returns:
- the platform's
Renderer
-
getViewport
- Returns:
- the platform's
Viewport
-
getSocketClient
- Returns:
- the platform's
SocketClient
-
getRestClient
- Returns:
- the platform's
RestClient
-
getIdentifier
- Returns:
- the platform's identifier
-
onKeyPressed
Registers an on key pressed listener.- Parameters:
keyEventConsumer
- the method called when key is pressed
-
onKeyReleased
Registers an on key released listener.- Parameters:
keyEventConsumer
- the method called when key is released
-
onMouseMoved
Registers an on mouse moved listener.- Parameters:
mouseEventConsumer
- the method called when mouse is moved
-
onMousePressed
Registers an on mouse pressed listener.- Parameters:
mouseEventConsumer
- the method called when mouse is pressed
-
onMouseReleased
Registers an on mouse released listener.- Parameters:
mouseEventConsumer
- the method called when mouse is released
-
onMouseWheel
Registers an on mouse wheel listener.- Parameters:
mouseWheelEventConsumer
- the method called when a mouse wheel interaction takes place
-
initializePlatform
protected abstract void initializePlatform(SolaConfiguration solaConfiguration, SolaPlatform.SolaPlatformInitialization solaPlatformInitialization) Method to initialize aSolaPlatform
. This operation can be async. It will provide the configuration from the)
.- Parameters:
solaConfiguration
- the Sola configurationsolaPlatformInitialization
- callSolaPlatform.SolaPlatformInitialization.finish()
when platform initialization is finished
-
beforeRender
Method called before each render frame.- Parameters:
renderer
- theRenderer
-
onRender
Main render frame method.- Parameters:
renderer
- theRenderer
-
populateAssetLoaderProvider
Method to populate theSolaPlatform
AssetLoaderProvider
withAssetLoader
s thatSola
will be able to utilize.- Parameters:
assetLoaderProvider
- theAssetLoaderProvider
-
buildRenderer
Builds theRenderer
for this platform. Default implementation will utilize theSoftwareRenderer
implementation.- Parameters:
solaConfiguration
- theSolaConfiguration
for theSola
- Returns:
- the built
Renderer
-
buildGameLoop
Builds theGameLoop
for this platform. Default implementation will utilize theFixedUpdateGameLoop
implementation.- Returns:
- the built
GameLoop
-
adjustMouseForViewport
Convenience method for calculating adjusted mouse coordinate considering the currentAspectMode
of theViewport
.- Parameters:
x
- the raw x coordinate of the mouse clicky
- the raw y coordinate of the mouse click- Returns:
- the viewport adjusted mouse click coordinate
-