Prebuilt native libraries for CheerpJ, compiled to WebAssembly. CheerpJ
loads them as shared libraries, either as the native part of a Java library (JNI) or as a
system library that other native code opens with dlopen.
The binaries target the current CheerpJ release, CheerpJ 5.0. A different CheerpJ version may need different binaries.
| File | Library | Role |
|---|---|---|
lwjgl2/liblwjgl.so |
LWJGL 2.9.3 | JNI component of lwjgl-2.9.3.jar |
gl4es/libgl4es.so |
gl4es 1.1.6 | libGL.so.1: OpenGL 1.x/2.x and GLX |
These libraries run unmodified LWJGL 2 games that render with OpenGL 1.x or 2.x. They are the libraries used by Browsercraft, which runs Minecraft 1.2.5 in the browser.
CheerpJ runs the Linux version of LWJGL 2:
lwjgl-2.9.3.jarloads its JNI component withSystem.loadLibrary("lwjgl"). CheerpJ loadsliblwjgl.sofromjava.library.path, through a small JavaScript module (see below).- LWJGL opens an X11 window and creates a GLX context. CheerpJ provides the X11 server, which draws into an HTML element of the page.
- LWJGL opens
libGL.so.1withdlopen. The page maps this name tolibgl4es.so. - gl4es implements the OpenGL 1.x/2.x API, fixed-function pipeline included, on top of
OpenGL ES 2. CheerpJ provides OpenGL ES 2 (
libGLESv2.so.1andlibEGL.so.1) on top of WebGL.
OpenGL 3 and higher core profiles are not supported. This repository does not provide an OpenAL implementation.
-
Put the files on your web server, next to your application:
lwjgl/lwjgl-2.9.3.jar lwjgl/lwjgl_util-2.9.3.jar lwjgl/libraries/lwjgl.js lwjgl/libraries/liblwjgl.so lwjgl/libraries/libgl4es.soThe jars are the standard LWJGL 2.9.3 jars. Add the other jars of your application as usual.
-
Create
lwjgl/libraries/lwjgl.js. CheerpJ mapsSystem.loadLibrary("lwjgl")tolwjgl.js, and loads the Wasm module that itswasmModuleexport contains:var r = await fetch('/lwjgl/libraries/liblwjgl.so'); var buf = await r.arrayBuffer(); export default { wasmModule: buf };
The URL is an absolute path on your web server, not a path in the CheerpJ file system. CheerpJ imports the module from a
blob:URL, so a path relative tolwjgl.jsdoes not work. Change the URL if you putliblwjgl.soin a different directory. -
Initialize CheerpJ with X11 support, the library path and the
libGL.so.1mapping, then create the display./app/is the root of your web server in the CheerpJ file system.await cheerpjInit({ version: 8, javaProperties: ['java.library.path=/app/lwjgl/libraries/'], libraries: { 'libGL.so.1': '/app/lwjgl/libraries/libgl4es.so' }, enableX11: true }); await cheerpjCreateDisplay(-1, -1, document.getElementById('display')); await cheerpjRunMain( 'com.example.Game', '/app/lwjgl/lwjgl-2.9.3.jar:/app/lwjgl/lwjgl_util-2.9.3.jar:/app/game.jar' );
cheerpjCreateDisplay(-1, -1, element)makes the display fill the element. The X11 window of the game draws into it.