Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

CheerpJ Wasm libraries

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

LWJGL 2 games with OpenGL 1/OpenGL 2

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.

How it works

CheerpJ runs the Linux version of LWJGL 2:

  1. lwjgl-2.9.3.jar loads its JNI component with System.loadLibrary("lwjgl"). CheerpJ loads liblwjgl.so from java.library.path, through a small JavaScript module (see below).
  2. LWJGL opens an X11 window and creates a GLX context. CheerpJ provides the X11 server, which draws into an HTML element of the page.
  3. LWJGL opens libGL.so.1 with dlopen. The page maps this name to libgl4es.so.
  4. 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.1 and libEGL.so.1) on top of WebGL.

OpenGL 3 and higher core profiles are not supported. This repository does not provide an OpenAL implementation.

Setup

  1. 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.so
    

    The jars are the standard LWJGL 2.9.3 jars. Add the other jars of your application as usual.

  2. Create lwjgl/libraries/lwjgl.js. CheerpJ maps System.loadLibrary("lwjgl") to lwjgl.js, and loads the Wasm module that its wasmModule export 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 to lwjgl.js does not work. Change the URL if you put liblwjgl.so in a different directory.

  3. Initialize CheerpJ with X11 support, the library path and the libGL.so.1 mapping, 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.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors