LWJGL 2 backend
joid-backend-lwjgl2 runs JOID on LWJGL 2.9.1, for applications built on its Display.
How an application installs and starts it is on Choosing a backend.
What it is made of
Section titled “What it is made of”| Bridge | Class | From |
|---|---|---|
| Render | GlRenderBridge over Lwjgl2GlBinding | base-opengl, base-lwjgl2 |
| Audio | AlAudioBridge over Lwjgl2AlBinding | base-openal, base-lwjgl2 |
| Window | Lwjgl2WindowBridge | base-lwjgl2 |
| Input | Lwjgl2InputForwarder, called by the loop | base-lwjgl2 |
Its own code is Lwjgl2Backend, which registers them, and Lwjgl2Natives; create() takes no window, because LWJGL 2 has a single Display.
The backend keeps the default thread bridge and the default UI bridge of Backend.
What differs
Section titled “What differs”Natives
Section titled “Natives”The jar bundles the LWJGL 2 natives for Windows, Linux and macOS.
Lwjgl2Natives.install installs them; whoever creates the Display calls it before Display.create(), and the backend never calls it itself:
- When
org.lwjgl.librarypathis set, or the natives are already onjava.library.path, it does nothing. - Otherwise it extracts them into the cache folder of JOID (Where JOID stores files), under
lwjgl, and setsorg.lwjgl.librarypath.
An extraction that fails throws an IllegalStateException that names the folder, and the next call tries again.
Input belongs to the loop
Section titled “Input belongs to the loop”LWJGL 2 delivers input through queues that the application loop drains, so the backend attaches no input in attachInput().
The application calls Lwjgl2InputForwarder.poll once per frame, before frame() (Input forwarder).
Mouse outside the window
Section titled “Mouse outside the window”attachInput() turns off the clipping of Mouse to the window, so that the mouse reports positions outside the window and a drag goes on past its edge, as with GLFW.
The jar embeds JNA 5.17, in its own packages, for the native cursors of base-lwjgl2.
Context
Section titled “Context”The Display and the OpenGL context that the backend needs are on Check the prerequisites.
Lwjgl2SnapshotBackend renders into a Display on Linux and into a Pbuffer elsewhere, both with a 24-bit depth and an 8-bit stencil.
Testing a backend runs the contract suites and the snapshot suite on your backend.
