Skip to content

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.

BridgeClassFrom
RenderGlRenderBridge over Lwjgl2GlBindingbase-opengl, base-lwjgl2
AudioAlAudioBridge over Lwjgl2AlBindingbase-openal, base-lwjgl2
WindowLwjgl2WindowBridgebase-lwjgl2
InputLwjgl2InputForwarder, called by the loopbase-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.

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:

  1. When org.lwjgl.librarypath is set, or the natives are already on java.library.path, it does nothing.
  2. Otherwise it extracts them into the cache folder of JOID (Where JOID stores files), under lwjgl, and sets org.lwjgl.librarypath.

An extraction that fails throws an IllegalStateException that names the folder, and the next call tries again.

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).

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.

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.

Report a problem with this page