Backend
abstract class Backend
Known subtypes: Lwjgl2Backend, Lwjgl3Backend, VulkanBackend
Package: dev.joid.lib.bridge.backend · Module: core · Source: Backend.java
The base class of every backend, which connects JOID to a window, a graphics API and an audio device in one register() call.
Description
Section titled “Description”An application never extends Backend: it creates the backend of its library, sets its options, calls register() once the window and its graphics context exist, then frame() once per iteration of its loop (Start a backend).
A backend author extends it and implements the create... hooks, which register() calls in a fixed order.
Learn more
Section titled “Learn more”Creation
Section titled “Creation”| Returns | Signature | Summary |
|---|---|---|
| Backend() protected | Creates the backend and reads its version from the backend.properties file next to its class, which register() compares with the loaded JOID. |
Properties
Section titled “Properties”| Property | Type | Default | Summary |
|---|---|---|---|
| audio | boolean | true | If false, register() registers no audio bridge and opens no audio device: videos play their picture without sound. |
| dataDir | File | null: the joid.data system property, else the folder joid in the working directory (Where JOID stores files) | Sets the folder where JOID writes the data of the application; it wins over the joid.data system property. |
| cacheDir | File | null: the joid.cache system property, else a folder joid in the cache folder of the system (Where JOID stores files) | Sets the folder where JOID writes the caches it can rebuild; it wins over the joid.cache system property. |
Methods
Section titled “Methods”| Returns | Signature | Summary |
|---|---|---|
this | register() fluent | Connects the backend to JOID, loads JOID and runs the JOID.onReady listeners: What happens at register() lists every step. |
this | frame() fluent | Runs one frame of every UI bridge through UIBridgeRegistry.frame: resize when the window changed, update, clear and draw. |
String | getVersion() | Returns the version of JOID that the backend was built for, read from backend.properties. |
boolean | isRegistered() | If true, register() has run. |
For subclasses
Section titled “For subclasses”| Returns | Signature | Summary |
|---|---|---|
IWindowBridge | createWindowBridge() hook abstract protected | JOID calls it during register(), after the audio bridge, and registers the result in BridgeHandler.WINDOW. |
IRenderBridge | createRenderBridge() hook abstract protected | JOID calls it during register(), after the window bridge, with the graphics context current, and registers the result in BridgeHandler.RENDER. |
IAudioBridge | createAudioBridge() hook protected | JOID calls it first during register(), unless audio(false) was set. |
IThreadBridge | createThreadBridge() hook protected | JOID calls it during register(), after the render bridge. |
void | registerDefaults() hook protected | JOID calls it during register(), after the bridges. |
void | attachInput() hook protected | JOID calls it during register(), after registerDefaults(), to connect the input of the window to BridgeHandler.UI; it does nothing by default. |
Creation details
Section titled “Creation details”Backend
Section titled “Backend”Backend() protected
Creates the backend and reads its version from the backend.properties file next to its class, which register() compares with the loaded JOID.
Property details
Section titled “Property details”this audio(boolean audio)fluentboolean isAudio()
Default: true
If false, register() registers no audio bridge and opens no audio device: videos play their picture without sound.
dataDir
Section titled “dataDir”this dataDir(File dataDir)fluentFile getDataDir()
Default: null: the joid.data system property, else the folder joid in the working directory (Where JOID stores files)
Sets the folder where JOID writes the data of the application; it wins over the joid.data system property.
cacheDir
Section titled “cacheDir”this cacheDir(File cacheDir)fluentFile getCacheDir()
Default: null: the joid.cache system property, else a folder joid in the cache folder of the system (Where JOID stores files)
Sets the folder where JOID writes the caches it can rebuild; it wins over the joid.cache system property.
Method details
Section titled “Method details”register
Section titled “register”this register() fluent
Throws:
IllegalStateException: … is already registered, call register() only once
Connects the backend to JOID, loads JOID and runs the JOID.onReady listeners: What happens at register() lists every step.
Call it once, on the thread of your loop, with the graphics context current; a second call throws an IllegalStateException.
this frame() fluent
Runs one frame of every UI bridge through UIBridgeRegistry.frame: resize when the window changed, update, clear and draw.
Call it once per iteration of your loop, between polling the events and showing the image.
getVersion
Section titled “getVersion”String getVersion()
Returns the version of JOID that the backend was built for, read from backend.properties.
isRegistered
Section titled “isRegistered”boolean isRegistered()
If true, register() has run.
createWindowBridge
Section titled “createWindowBridge”IWindowBridge createWindowBridge() hook abstract protected
JOID calls it during register(), after the audio bridge, and registers the result in BridgeHandler.WINDOW.
Return the window bridge of your backend.
createRenderBridge
Section titled “createRenderBridge”IRenderBridge createRenderBridge() hook abstract protected
JOID calls it during register(), after the window bridge, with the graphics context current, and registers the result in BridgeHandler.RENDER.
Return the render bridge of your backend.
createAudioBridge
Section titled “createAudioBridge”IAudioBridge createAudioBridge() hook protected
JOID calls it first during register(), unless audio(false) was set.
Return the audio bridge, or null to register none; it returns null by default.
createThreadBridge
Section titled “createThreadBridge”IThreadBridge createThreadBridge() hook protected
JOID calls it during register(), after the render bridge.
Return the bridge of your render thread, or null to keep the DirectThreadBridge; it returns a FrameThreadBridge tied to the calling thread by default.
registerDefaults
Section titled “registerDefaults”void registerDefaults() hook protected
JOID calls it during register(), after the bridges.
It registers a WindowUIBridge with registerDefault by default; override it to add what your backend needs in other registries, and call super.registerDefaults() to keep the default UI bridge.
attachInput
Section titled “attachInput”void attachInput() hook protected
JOID calls it during register(), after registerDefaults(), to connect the input of the window to BridgeHandler.UI; it does nothing by default.
A backend whose input belongs to the loop of the application leaves it empty and gives the application a forwarder to poll.
fluent returns the instance, typed for chaining · factory creates an instance · signal also accepts a value that follows signals, as a signal, an expression or a lambda (When does JOID compute this value again?) · hook called by JOID, override it · abstract you implement it · default interface method with a body · static called on the class · protected visible to subclasses
