Skip to content

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.

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.

ReturnsSignatureSummary
Backend() protectedCreates the backend and reads its version from the backend.properties file next to its class, which register() compares with the loaded JOID.

PropertyTypeDefaultSummary
audiobooleantrueIf false, register() registers no audio bridge and opens no audio device: videos play their picture without sound.
dataDirFilenull: 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.
cacheDirFilenull: 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.

ReturnsSignatureSummary
thisregister() fluentConnects the backend to JOID, loads JOID and runs the JOID.onReady listeners: What happens at register() lists every step.
thisframe() fluentRuns one frame of every UI bridge through UIBridgeRegistry.frame: resize when the window changed, update, clear and draw.
StringgetVersion()Returns the version of JOID that the backend was built for, read from backend.properties.
booleanisRegistered()If true, register() has run.
ReturnsSignatureSummary
IWindowBridgecreateWindowBridge() hook abstract protectedJOID calls it during register(), after the audio bridge, and registers the result in BridgeHandler.WINDOW.
IRenderBridgecreateRenderBridge() hook abstract protectedJOID calls it during register(), after the window bridge, with the graphics context current, and registers the result in BridgeHandler.RENDER.
IAudioBridgecreateAudioBridge() hook protectedJOID calls it first during register(), unless audio(false) was set.
IThreadBridgecreateThreadBridge() hook protectedJOID calls it during register(), after the render bridge.
voidregisterDefaults() hook protectedJOID calls it during register(), after the bridges.
voidattachInput() hook protectedJOID calls it during register(), after registerDefaults(), to connect the input of the window to BridgeHandler.UI; it does nothing by default.

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.

  • this audio(boolean audio) fluent
  • boolean isAudio()

Default: true

If false, register() registers no audio bridge and opens no audio device: videos play their picture without sound.

  • this dataDir(File dataDir) fluent
  • File 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.

  • this cacheDir(File cacheDir) fluent
  • File 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.

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.

String getVersion()

Returns the version of JOID that the backend was built for, read from backend.properties.

boolean isRegistered()

If true, register() has run.

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.

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.

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.

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.

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.

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

Report a problem with this page