Code

The API, in real code.

One section for each area on the Features page, in the same order. Each example is complete enough to copy, and was compiled against the engine's source.

▶START HERE

Four steps, every time.

Every RenGL program does the same four things: make a Window, put a Container in it, put elements in the container, and hand the window to an Engine. Everything below builds on this. Imports are shown here once; later examples leave them out so the code stays readable.

Hello.java

The smallest complete program. Elements start transparent, so the window's own background shows through the container.

Hello.java
import me.piitex.engine.Engine;
import me.piitex.engine.Window;
import me.piitex.engine.WindowOptions;
import me.piitex.engine.ui.color.Color;
import me.piitex.engine.ui.containers.Container;
import me.piitex.engine.ui.overlays.TextOverlay;

public class Hello {
    public static void main(String[] args) {
        // 1. The window (title + size).
        Window window = new Window(new WindowOptions("Hello RenGL").setDimensions(1280, 720));

        // 2. A container that fills the window. Elements start transparent, so the
        // window's own background shows through it.
        Container root = new Container(1280, 720);
        window.addContainer(root);

        // 3. Elements. x/y is the top-left corner.
        TextOverlay title = new TextOverlay("Hello, RenGL!", 48f, Color.BLACK);
        title.setPosition(50, 50);
        root.addElement(title);

        // 4. Start the engine. This call blocks until the window is closed.
        new Engine().start(window);
    }
}

Add RenGL to a Maven project

RenGL is on Maven Central under io.github.piitex. Take the all-in-one RenGL artifact or only the modules you use, and add the rengl-natives-<platform> artifact for each platform you run on: windows, linux or macos, each with an -arm64 variant. The getting started guide has a full pom.xml with one profile per platform. The rengl-upscale and rengl-physx modules are not part of RenGL; add them yourself if you want them.

pom.xml
<dependency>
    <groupId>io.github.piitex</groupId>
    <artifactId>RenGL</artifactId>
    <version>0.1.1</version>
</dependency>
<dependency>
    <groupId>io.github.piitex</groupId>
    <artifactId>rengl-natives-windows</artifactId>
    <version>0.1.1</version>
</dependency>

Run it with -XstartOnFirstThread --enable-native-access=ALL-UNNAMED on macOS. Engine.start doesn't return until the window closes, so build the whole UI first and react to things inside callbacks.

▤01 · UI TOOLKIT

Widgets with one callback each.

Widgets are overlays you add to containers. Most take a size in the constructor and report what the user did through a single callback. Value setters such as setText or setSelected are silent, so a callback only ever means the user did something.

A themed settings form

A dark panel with a text field, a dropdown, a slider with a formatted label, a toggle with its label, and a button with an icon. A vertical layout places everything.

SettingsForm.java
ThemeManager.setCurrent(new DarkTheme()); // before building, so everything starts dark
Window window = new Window(new WindowOptions("Settings").setDimensions(800, 600));

Container root = new Container(800, 600);
window.addContainer(root);

VerticalLayout panel = new VerticalLayout(250, 100, 300, 420);
panel.setSpacing(14);
panel.setPadding(20);
panel.useTheme(); // opt this panel into theme colors
root.addElement(panel);

TextFieldOverlay name = new TextFieldOverlay(260, 28);
name.setPlaceholder("Your name...");
name.onTextChanged(text -> System.out.println("typed: " + text));
panel.addElement(name);

DropdownOverlay<String> country = new DropdownOverlay<>(260, 28);
country.setPlaceholder("Country...");
country.setItems(List.of("Canada", "France", "Germany", "Japan"));
country.onSelect(c -> System.out.println("Selected: " + c));
panel.addElement(country);

SliderOverlay volume = new SliderOverlay(260, 0, 100, 50); // width, min, max, start
volume.setStep(1);
volume.setLabelFormatter(v -> Math.round(v) + "%");
volume.onValueChange(v -> System.out.println("volume = " + v));
panel.addElement(volume);

HorizontalLayout row = new HorizontalLayout(260, 28);
row.setSpacing(12);
row.setAlignment(Layout.Alignment.CENTER_LEFT);
ToggleSwitchOverlay notifications = new ToggleSwitchOverlay();
notifications.onToggle(on -> System.out.println("notifications: " + on));
row.addElement(new TextOverlay("Notifications", 16f, Color.BLACK));
row.addElement(notifications);
panel.addElement(row);

ButtonOverlay add = new ButtonOverlay("Add files", 260, 36);
add.setIcon(Feather.PLUS);
add.setTooltip("Choose files to import");
add.onAction(() -> System.out.println("Hello, " + name.getText()));
panel.addElement(add);

new Engine().start(window);

A sortable table inside tabs

Clicking a header sorts, dragging its edge resizes the column, and rows can be selected. Give a column a comparator when its text wouldn't sort correctly, as with sizes and dates. Tabs can be closable.

FilesTab.java
record Entry(String name, long size, Instant modified) {}
List<Entry> entries = List.of(
        new Entry("notes.txt", 2_048, Instant.now()),
        new Entry("photo.png", 1_500_000, Instant.now()));

TableView<Entry> table = new TableView<>(600, 360); // width, height
table.addColumn("Name", Entry::name).setWidth(260);
table.addColumn("Size", e -> e.size() / 1024 + " KB")
        .setAlignment(TextAlign.RIGHT)
        .setComparator(Comparator.comparingLong(Entry::size)); // "9 KB" would sort after "1,500 KB" as text
table.addColumn("Modified", e -> e.modified().toString())
        .setComparator(Comparator.comparing(Entry::modified));
table.setItems(entries);
table.onActivate(entry -> System.out.println("open " + entry.name()));

VerticalLayout notes = new VerticalLayout(600, 360);
notes.addElement(new TextOverlay("Nothing here yet.", 16f, Color.BLACK));

TabContainer tabs = new TabContainer(20, 20, 640, 440);
tabs.addTab("Files", table);
tabs.addTab("Notes", notes).setClosable(true);
tabs.onTabSelected(tab -> System.out.println("Now showing " + tab.getTitle()));
root.addElement(tabs);

Charts, including live ones

Line, bar, pie and donut charts are drawn by the engine from plain numbers. Pointing shows a tooltip, clicking a legend entry hides that series, and the theme's colors are used. A live chart is updated by changing its data and nothing else: the line eases to the new values. Charts live in the rengl-charts module.

Dashboard.java
BarChartOverlay sales = new BarChartOverlay(520, 320);          // width, height
sales.setTitle("Sales by region");
sales.setCategories("North", "South", "East", "West");
sales.addSeries("2025", 42, 31, 55, 28);
sales.addSeries("2026", 51, 36, 49, 40);
sales.onPointClick(hit -> System.out.println(hit.seriesName() + " in " + hit.categoryLabel() + ": " + hit.value()));
root.addElement(sales);

PieChartOverlay share = new PieChartOverlay(320, 320);
share.setSlices(List.of("Web", "App", "API"), 52, 31, 17);
share.setHoleRatio(0.6f);                                       // a donut, with the total in the middle
root.addElement(share);

// A live chart: change the data and nothing else. The line eases to the new values.
LineChartOverlay load = new LineChartOverlay(840, 240);
load.setSmooth(true);
ChartSeries cpu = load.addSeries("CPU");
Scheduler.every(0.25f, () -> {
    cpu.add(readCpu());                                         // your own reading
    if (cpu.size() > 40) cpu.removeFirst(1);                    // the oldest value leaves
});
root.addElement(load);

Lists, dials and toasts

A ListBox draws only the rows on screen, so thousands cost no more than a few. KnobOverlay is a dial the user drags, and GaugeOverlay a read-out the game sets, with colored zones. ToastManager shows a short message in a corner of the window and removes it for you, from any thread.

Widgets.java
ListBox<Save> saves = new ListBox<>(240, 300);
saves.setLabelProvider(Save::name);
saves.setItems(allSaves);
saves.onSelect(save -> preview(save));
saves.onActivate(save -> load(save));        // double-click, or Enter
root.addElement(saves);

KnobOverlay volume = new KnobOverlay(64, 0, 100);   // diameter, min, max
volume.setValue(70);
volume.setDefaultValue(70);                          // a double-click goes back to 70
volume.setLabelFormatter(v -> Math.round(v) + "%");
volume.onValueChange(v -> System.out.println("volume " + v / 100));
root.addElement(volume);

GaugeOverlay speed = new GaugeOverlay(160, 0, 240);
speed.setTitle("km/h");
speed.setStyle(GaugeOverlay.Style.NEEDLE);
speed.addZone(0, 160, Color.GREEN);
speed.addZone(160, 200, Color.YELLOW);
speed.addZone(200, 240, Color.RED);
speed.setValue(120);                                 // set it every frame if you like
root.addElement(speed);

ToastManager toasts = ToastManager.of(window);
toasts.success("Game saved");
toasts.show(new ToastManager.Toast("Item removed")
        .setDuration(6f)
        .setAction("Undo", () -> restore(item)));
⊞02 · LAYOUTS

Describe the structure, not the pixels.

A layout positions its children every frame, so you never set an x and y by hand. Layouts nest freely and keep working as the window is resized.

An app shell with a docked header and sidebar

DockLayout pins a header, a status bar and a sidebar to the edges and gives the last child whatever remains. Inside the header, a HorizontalLayout gives the title the room the two buttons leave, using a layout weight.

AppShell.java
Container header = new Container(1280, 56);
Container statusBar = new Container(1280, 28);
Container sidebar = new Container(240, 0);
Container content = new Container(0, 0);

DockLayout screen = new DockLayout(1280, 720);
screen.setSpacing(6);
screen.addElement(header, DockLayout.Dock.TOP);     // keeps its height, takes the full width
screen.addElement(statusBar, DockLayout.Dock.BOTTOM);
screen.addElement(sidebar, DockLayout.Dock.LEFT);   // keeps its width, takes the height that is left
screen.addElement(content, DockLayout.Dock.FILL);   // takes everything that remains
root.addElement(screen);

// A toolbar: the title takes whatever room the other two leave.
ButtonOverlay back = new ButtonOverlay("Back", 80, 40);
TextOverlay title = new TextOverlay("Inbox", 18f, Color.BLACK);
ButtonOverlay menu = new ButtonOverlay("Menu", 80, 40);

HorizontalLayout bar = new HorizontalLayout(800, 40);
bar.setSpacing(8);
bar.addElement(back);                   // keeps its own width
bar.addElement(title);
title.setLayoutWeight(1);               // takes what is left
title.setRelativeHeight(1);             // and is as tall as the bar
bar.addElement(menu);
header.addElement(bar);

Fit to content, and anchors

A layout can size itself to its children, which suits lists. An anchor keeps an element at a spot in its parent however the window is resized. Anchors work for children of a plain container; a layout places its own children, so anchor the layout instead.

Sizing.java
// A column with a fixed width whose height follows its rows.
VerticalLayout list = new VerticalLayout(280, 0);
list.setSpacing(6);
list.setSizeToContent(false, true);
for (String item : List.of("Inbox", "Sent", "Drafts")) {
    list.addElement(new ButtonOverlay(item, 280, 32));
}
root.addElement(list);

// Anchored elements keep their place when the window is resized.
ButtonOverlay close = new ButtonOverlay("Close", 90, 32);
close.setAnchor(Anchor.TOP_RIGHT, -12, 12); // 12 points in from the top-right corner
root.addElement(close);

A whole screen as data

A layout file holds a tree of containers and elements as JSON. Loading it builds the real objects, so themes, transitions and click handlers work on them as usual. Find an element by the name it has in the file.

layouts/menu.json
{
  "format": 1,
  "root": {
    "kind": "vertical", "name": "Menu", "width": 1280, "height": 720, "spacing": 12, "alignment": "CENTER",
    "children": [
      { "kind": "text", "name": "title", "text": "My Game", "fontSize": 48 },
      { "kind": "button", "name": "play", "text": "Play", "width": 160, "height": 40, "cornerRadius": 6 },
      { "kind": "button", "name": "quit", "text": "Quit", "width": 160, "height": 40,
        "anchor": "BOTTOM_RIGHT", "offsetX": -16, "offsetY": -16 }
    ]
  }
}
Menu.java
Container ui = UiFile.load("layouts/menu.json");
window.addContainer(ui);
UiFile.find(ui, "play", ButtonOverlay.class).onAction(() -> System.out.println("play!"));

// Follow the window; anchored elements keep their place as it changes.
window.onResize((width, height) -> {
    ui.setWidth(width);
    ui.setHeight(height);
});
◐03 · STYLING & THEMES

Every look is set from Java.

No CSS engine and no native defaults. A theme gives every widget a baseline; anything you set yourself is pinned and survives theme switches.

Gradients and animated borders

Any fill or border takes a Paint: a color, a gradient, a gradient that slides (ScrollingGradient) or a RainbowColor that cycles through the color wheel.

StyledCard.java
Container card = new Container(40, 40, 320, 180);
card.getStyling().setBackgroundColor(new Color(0.12f, 0.12f, 0.14f, 1f));
card.getStyling().setBorderColor(new RainbowColor()); // a border that cycles through the colour wheel
card.getStyling().setBorderThickness(2f);
card.getStyling().setCornerRadius(16f);
root.addElement(card);

ButtonOverlay glow = new ButtonOverlay("Upgrade", 160, 40);
glow.getStyling().setBackgroundColor(new ScrollingGradient(Color.BLUE, Color.PURPLE, 80f)); // slides over time
glow.getStyling().setCornerRadius(20f);
glow.setTextColor(Color.WHITE); // pin the label colour
glow.setPosition(20, 20);
card.addElement(glow);

Themes you can switch live

Light, dark and crimson ship with the engine. ThemeManager.setCurrent restyles everything on screen at once. A property you set by hand is pinned until you reset it.

Themes.java
ThemeManager.setCurrent(new DarkTheme()); // LightTheme, DarkTheme, CrimsonTheme, or your own

ButtonOverlay toggle = new ButtonOverlay("Toggle theme", 150, 36);
toggle.onAction(() -> {
    boolean dark = ThemeManager.getCurrent().getButtonBackground().getR() < 0.5f;
    ThemeManager.setCurrent(dark ? new LightTheme() : new DarkTheme()); // everything restyles live
});

// Anything you set yourself is pinned: a theme switch leaves it alone.
accent.getStyling().setBackgroundColor(Color.RED);
// ...until you hand it back to the theme.
accent.getStyling().resetBackgroundColor();

Animated backgrounds

A Background is an effect painted behind an element's content. It is not a child, so a layout never moves it. Attach one to a panel or to the whole window.

Backgrounds.java
window.setBackground(new ConstellationBackground()); // drifting, linked dots behind everything

formPanel.setBackground(new DotGridBackground());    // or behind a single panel

AnimatedDotBackground dots = new AnimatedDotBackground();
dots.setHueSpan(0.15f); // calmer: one colour family instead of the full rainbow
dots.setSpeed(0.5f);    // half speed
root.setBackground(dots);
⤢04 · DRAGGABLE CONTAINERS

Let the user rearrange things.

Containers that can be moved, resized and reordered by the user, with sensible limits so nothing ends up off-screen.

Drag, bound and collide

Dragging is off by default, so ordinary grouping containers don't move when the user drags across them. Controls inside, like buttons, keep their own clicks. A dragged container comes to the front.

Dragging.java
Container panel = new Container(320, 80, 300, 200);
panel.useTheme();
panel.setDraggable(true);             // off by default; grab it anywhere that isn't a control
panel.setDragBounds(0, 0, 800, 600);  // stay inside this rectangle
panel.addCollideable(sidebar);        // and never be dragged into the sidebar
root.addElement(panel);

A panel that scales with the window

A ResizableContainer follows the window proportionally and scales its children and font sizes with it. The user can drag its corners within the limits you set.

ResizablePanel.java
ResizableContainer panel = new ResizableContainer(60, 60, 360, 260);
panel.setMinSize(200, 140);   // never shrink below this
panel.setMaxSize(800, 600);   // never grow beyond this
panel.setUserResizable(true); // the user can drag the corners

ButtonOverlay ok = new ButtonOverlay("OK", 100, 32);
panel.addElement(ok);
panel.setFixedSize(ok, true); // the button keeps its 100x32 size; everything else scales

window.addContainer(panel);   // follows the window as it is resized

A grid the user can rearrange

Press an item, move a few points, and it lifts; the others slide aside. The grid only reports the new order, so saving it is up to you.

Rearrange.java
ReorderableGrid grid = new ReorderableGrid(620, 400, 140, 100, 12); // width, height, item w, item h, gap
grid.setPosition(20, 20);
grid.useTheme();

List<Container> cards = new java.util.ArrayList<>();
for (String name : List.of("Alpha", "Beta", "Gamma", "Delta", "Epsilon")) {
    Container card = new Container(140, 100);
    card.useTheme();
    TextOverlay label = new TextOverlay(name, 16f, Color.BLACK);
    label.setPosition(12, 10);
    card.addElement(label);
    cards.add(card);
}
grid.setItems(cards);

grid.onReorder(order -> System.out.println("new order: " + order.size() + " cards")); // once per drag
grid.onItemClick(card -> System.out.println("opened a card"));
root.addElement(grid);
✦05 · ANIMATION

Motion that runs the same everywhere.

Transitions animate UI elements. Tweens and sequences animate any value, or script a series of steps. Everything is driven by delta time, so it plays at the same real-world speed on every machine.

Fades, pops and a title card that locks the game

A fade changes the whole element's opacity as one unit, children included. Chain animations by nesting callbacks. A locking transition holds the game still until it ends, or until the player presses a key.

Transitions.java
panel.fadeIn(0.3f);                                   // transparent -> opaque

// Chain by nesting: the callback runs on the frame the fade finishes.
panel.fadeOut(0.25f, () -> {
    panel.setEnabled(false);
    next.setEnabled(true);
    next.fadeIn(0.25f);
});

// Pop in: grow from 80% to full size with a little overshoot.
card.playTransition(new ScaleTransition(0.8f, 1f, 0.3f, Easing.EASE_OUT_BACK, null));

// A title card that holds the game still until it is over, or the player presses a key.
title.fadeIn(2f).lock().skippable();

Tweens and sequences

Inside a scene, play(...) runs on the scene's game clock, so animations pause with the game and are cancelled when the scene leaves. A sequence's timing is exact at any frame rate.

Shop.java
public class Shop extends Scene {
    private final Camera camera = new Camera();
    private final TextOverlay banner = new TextOverlay("", 32f, Color.WHITE);
    private float coinOffset, shown, scoreScale = 1f, playerX;

    @Override
    protected void onEnter() {
        // A coin that bobs forever.
        play(Tween.of(0f, -6f, 0.6f, v -> coinOffset = v).easing(Easing.EASE_IN_OUT).loop().yoyo());

        // A score that counts up, then pops.
        float score = 1250f;
        play(Tween.of(shown, score, 0.8f, v -> shown = v).easing(Easing.EASE_OUT)
                .onComplete(() -> play(Tween.of(1.3f, 1f, 0.3f, v -> scoreScale = v).easing(Easing.EASE_OUT_BACK))));

        // A scripted moment: steps run one after another, on the scene's clock.
        play(new Sequence()
                .run(() -> banner.setText("Wave 2"))
                .delay(2f)
                .then(Tween.to(camera::getZoom, camera::setZoom, 2f, 1f).easing(Easing.EASE_IN_OUT))
                .waitUntil(() -> playerX > 400)
                .run(this::spawnWave)
                .onComplete(() -> System.out.println("wave started")));
    }

    private void spawnWave() { }
}

Write your own transition

Implement Transition to draw anything over an element each frame. This one pulses a yellow border and never finishes.

Pulse.java
public class Pulse implements Transition {
    private float time;

    @Override
    public void update(Element target, float delta) {
        time += delta;
    }

    @Override
    public void render(Renderer renderer, Element target) {
        float a = 0.25f + 0.25f * (float) Math.sin(time * 5f);
        renderer.drawBorder((float) target.getX(), (float) target.getY(),
                (float) target.getWidth(), (float) target.getHeight(),
                new Color(1f, 1f, 0.3f, a), 3f, target.getStyling().getCornerRadius());
    }

    @Override
    public boolean isFinished() {
        return false; // loops until the program ends
    }
}

// elsewhere: button.playTransition(new Pulse());
◈06 · 2D GAME FRAMEWORK

A game loop without a game engine on top.

A Scene is one screen of a game. Logic runs at a fixed rate, drawing is smoothed between steps, and the scene's container holds ordinary UI that draws above the world.

A scene with a camera, sprites and input

fixedUpdate moves the hero at 120 points per second whatever the frame rate. render blends between the last two steps, so motion stays smooth. Named actions come from an InputContext, which receives input only while the scene runs. The sprite batch draws every sprite sharing a texture in one call.

Level.java
public class Level extends Scene {
    private final Camera camera = new Camera();
    private final SpriteBatch batch = new SpriteBatch();
    private final Sprite hero = new Sprite(new TextureRegion(Texture.load("assets/hero.png")));
    private final InputContext controls = new InputContext("gameplay")
            .bind("left", Binding.key(GLFW_KEY_A), Binding.key(GLFW_KEY_LEFT))
            .bind("right", Binding.key(GLFW_KEY_D), Binding.key(GLFW_KEY_RIGHT))
            .bind("pause", Binding.key(GLFW_KEY_ESCAPE));
    private float x, prevX;

    public Level() {
        addInputContext(controls);   // receives input while this scene runs
        hero.setPivot(0.5f, 1f);     // stand on (x, y)
    }

    @Override
    protected void onEnter() {
        camera.setViewport(0, 0, (float) getContainer().getWidth(), (float) getContainer().getHeight());
        camera.setZoom(3f);
        getContainer().addElement(new TextOverlay("Level 1", 20f, Color.WHITE)); // UI sits above the world
    }

    @Override
    protected void onResize(int width, int height) {
        camera.setViewport(0, 0, width, height);
    }

    @Override
    protected void fixedUpdate(float step) {             // 60 times a second, however fast the screen is
        prevX = x;
        x += controls.getAxis("left", "right") * 120 * step;
    }

    @Override
    protected void update(float delta) {                 // once per frame
        if (controls.isJustPressed("pause")) getSceneManager().push(new PauseMenu());
        float drawX = prevX + (x - prevX) * GameTime.getAlpha();
        camera.follow(drawX, 0, 6f, delta);              // ease towards the hero, the same at any frame rate
        camera.update(delta);
    }

    @Override
    protected void render(Renderer renderer, float alpha) {
        hero.setPosition(prevX + (x - prevX) * alpha, 0); // smooth between fixed steps
        batch.add(hero);

        camera.begin(renderer);
        batch.draw(renderer, camera.getVisibleBounds());  // one call for every sprite on the same texture
        camera.end(renderer);
    }
}

Pause menus and scene transitions

Scenes live on a stack. A scene marked as an overlay lets the one below show through, and pushing it pauses the one below. Transitions fade, slide or wipe between them.

PauseMenu.java
public class PauseMenu extends Scene {
    public PauseMenu() {
        setOverlay(true);   // the frozen game stays visible underneath
    }

    @Override
    protected void onEnter() {
        getContainer().getStyling().setBackgroundColor(new Color(0f, 0f, 0f, 0.55f));
        ButtonOverlay resume = new ButtonOverlay("Resume", 180, 40);
        resume.setAnchor(Anchor.CENTER);   // stays centered when the window is resized
        resume.onAction(() -> getSceneManager().pop());
        getContainer().addElement(resume);
    }
}

void startGame(Window window) {
    SceneManager scenes = window.getSceneManager();
    scenes.set(new Level(), SceneTransition.fadeThrough(Color.BLACK, 0.6f)); // menu -> level, through black
    // later, from a key press or a button:
    scenes.push(new PauseMenu(), SceneTransition.fade(0.2f));                // pauses the level below
}

Particles that stay cheap

A ParticleEffect is a recipe with ranges for speed, lifetime, size and color. A ParticleSystem pools and draws them all in one batch. Use a burst for a hit and an emitter for a trail. camera.shake adds trauma that settles by itself.

Battle.java
public class Battle extends Scene {
    private final Camera camera = new Camera();
    private final ParticleSystem particles = new ParticleSystem(5000); // pooled: nothing is allocated per particle
    private final ParticleEffect sparks;
    private final ParticleEmitter smoke;
    private float rocketX, rocketY;

    public Battle(TextureRegion spark, TextureRegion puff) {
        sparks = new ParticleEffect(spark)
                .speed(200f, 600f).lifetime(0.3f, 0.6f).size(8f, 14f).endScale(0.2f)
                .drag(0.9f).alignToVelocity(1f / 400f).color(Color.ORANGE);

        smoke = new ParticleEmitter(particles, new ParticleEffect(puff)
                .speed(20f, 60f).lifetime(0.8f, 1.4f).size(10f, 24f).endScale(3f)
                .color(Color.WHITE, Color.GRAY))
                .rate(40).cone(270, 30);   // 40 a second, fanning upwards
    }

    void enemyDied(float x, float y) {
        particles.burst(sparks, x, y, 40);  // 40 sparks flying out in every direction
        camera.shake(0.3f);                 // a hit: about 0.1 for a shot, 0.6 for an explosion
    }

    @Override
    protected void fixedUpdate(float step) {
        smoke.moveTo(rocketX, rocketY);     // leaves a smooth trail even when the rocket is fast
        smoke.update(step);
        particles.update(step);
    }

    @Override
    protected void update(float delta) {
        camera.update(delta);
    }

    @Override
    protected void render(Renderer renderer, float alpha) {
        camera.begin(renderer);
        particles.draw(renderer, camera.getVisibleBounds());   // thousands in one batched draw
        camera.end(renderer);
    }
}

SkSL shaders and post effects

A shader fills a rectangle, like the animated bar below. A post effect receives everything drawn between pushEffect and popEffect as content: here a vignette. The same SkSL runs on Metal, OpenGL, Vulkan and the CPU renderer.

Sea.java
public class Sea extends Scene {
    // SkSL runs the same on Metal, OpenGL, Vulkan and the CPU renderer.
    private final ShaderEffect stripes = ShaderEffect.compile("""
            uniform float time;
            uniform half4 color;
            half4 main(float2 coord) {
                float band = step(0.5, fract((coord.x + coord.y + time * 40) / 24));
                return color * (0.6 + 0.4 * band);
            }
            """);

    // A post effect gets everything drawn between push and pop as `content`.
    private final ShaderEffect vignette = ShaderEffect.compile("""
            uniform shader content;
            uniform float2 size;
            half4 main(float2 coord) {
                half4 color = content.eval(coord);
                float edge = distance(coord / size, float2(0.5));
                return half4(color.rgb * (1 - edge * edge * 1.4), color.a);
            }
            """);

    public Sea() {
        stripes.set("color", Color.ORANGE);
    }

    @Override
    protected void render(Renderer renderer, float alpha) {
        float width = (float) getContainer().getWidth();
        float height = (float) getContainer().getHeight();

        vignette.set("size", width, height);
        renderer.pushEffect(vignette, 0, 0, width, height);

        stripes.set("time", (float) GameTime.getTime());
        renderer.drawShader(stripes, 20, 20, 300, 16, 8f);   // fill a rounded bar with the shader

        renderer.popEffect();   // what comes after, like a HUD, is drawn normally
    }
}

Levels as data

An EntityScene holds entities with components. Fields marked @Property are saved with the scene, so a level can live in a JSON file. A child entity moves, turns and scales with its parent.

Entities.java
public static class Spin extends Component {
    @Property public float degreesPerSecond = 90f;   // saved with the scene, editable in the editor

    @Override
    protected void update(float delta) {
        getTransform().rotate(degreesPerSecond * delta);
    }
}

void entities(Window window) {
    EntityScene scene = new EntityScene();

    Entity player = scene.create("Player");
    player.getTransform().setPosition(100, 200);
    player.addComponent(new SpriteRenderer(TextureRef.of("assets/hero.png")));
    player.addComponent(new BoxCollider(24, 32));
    player.addComponent(new Spin());

    Entity sword = new Entity("Sword");
    sword.getTransform().setPosition(16, 0);   // 16 units to the player's right, turning with it
    player.addChild(sword);

    window.getSceneManager().set(scene);
    // Or load a level that was saved as JSON:
    // window.getSceneManager().set(EntityScene.load("scenes/level1.json"));
}
♪07 · AUDIO & VIDEO

Sound with a place in the world, and video in the UI.

Short sounds are decoded once and overlap freely. Music streams from disk. Positional audio works in 2D games too, and a video is just another element.

Music, effects and playback control

Calling playMusic with the track that's already playing does nothing, so every screen can call it. Every play returns a Playback for adjusting that one instance; a finished playback ignores calls, so you never have to check first.

Sounds.java
Audio.playMusic("music/menu.ogg");          // streams, loops, and crossfades
Audio.playMusic("music/battle.ogg", 3f);    // a 3 second crossfade into the next track
Audio.stopMusic(2f);                        // fade out and stop

Sound hit = Sound.load("sfx/hit.ogg")       // short clips are decoded once and kept in memory
        .channel(AudioChannel.SFX)
        .pitchVariation(0.08f)              // each play up to 8% higher or lower
        .minGap(0.05f)                      // skip a play less than 0.05 s after the last one
        .maxPlaying(4);                     // ...or while 4 copies are still sounding
hit.play(0.8f);                             // overlapping plays are fine

Playback engine = Sound.load("sfx/engine.ogg").loop();
engine.volume(0.6f);
engine.pitch(1f + speed / 100f);            // rises as the player accelerates
engine.stop(0.5f);                          // fade out when they stop

Sound in the world

hearIn2D sets the distance falloff and panning for a 2D game in one call. After that, place sounds where things happen. Add a world reverb, aim a sound with a cone, or muffle it when a wall is in the way.

SpatialSound.java
Audio.hearIn2D(150f, 1500f);   // once: full volume within 150 units, silent at 1500

Sound explosion = Sound.load("sfx/explosion.ogg");
Audio.listener().setPosition(camera.getX(), camera.getY()); // every frame: the ears follow the view
explosion.playAt(x, y);                                     // heard from where it happens

Audio.setReverb(Reverb.cave());   // every sound in the world now rings like a cave

Playback horn = Sound.load("sfx/horn.ogg").loopAt(x, y, 0f)
        .direction(0, 0, -1)      // which way it faces
        .cone(60f, 200f, 0.2f);   // loud in front, 20% volume behind
horn.occlusion(blocked ? 0.8f : 0f); // muffle it when a wall is in the way

Video in the UI

A VideoOverlay streams from disk, so a file of tens of gigabytes opens instantly. H.264 and HEVC in MP4 or MOV play through the system decoder on macOS and Windows (on Windows, HEVC needs Microsoft's HEVC Video Extensions) and through GStreamer on Linux, which has not been confirmed on real files yet. Anywhere, Motion JPEG with PCM sound in AVI, MP4 or MOV plays with no decoder; the docs list an FFmpeg command to convert.

Intro.java
VideoOverlay intro = new VideoOverlay("assets/intro.avi", 1280, 720); // fitted into 1280x720
intro.getPlayer().onFinish(() -> System.out.println("intro finished"));
container.addElement(intro);                                          // it starts playing at once

VideoPlayer player = intro.getPlayer();
player.setLooping(true);
player.setVolume(0.6f);
player.setProgress(0.5f);   // jump to the middle; big files are streamed from disk

container.onMouseClick(event -> intro.toggle());   // click to pause and resume
intro.dispose();            // when you are done: stops decoding and closes the file
⬡08 · 3D (OPTIONAL)

3D inside your UI.

The 3D layer draws into a picture that the UI shows like an image: in a panel, or behind the whole window. It needs OpenGL or Vulkan, so on macOS a 3D program asks for Vulkan. Coordinates are right-handed with +Y up, and colors are written as you see them on screen.

A first scene: a cube you can orbit

A Scene3D is something a Viewport3D can show. OrbitControls turns the camera when the user drags and zooms with the wheel. The update handler runs once a frame.

FirstCube.java
// Vulkan on macOS; OpenGL is the default elsewhere.
Window window = new Window(new WindowOptions("First cube")
        .setDimensions(900, 520)
        .setRenderer(RenderAPI.VULKAN));

Scene3D scene = new Scene3D();
scene.camera().lookAt(new Vec3(3, 2.5f, 4), new Vec3(0, 0.75f, 0)); // from above and the side

Node3D cube = new Node3D("cube", Mesh.cube(1.5f), new Material(Color.CORNFLOWER_BLUE));
cube.setPosition(0, 0.75f, 0);
scene.add(cube);
scene.setUpdateHandler((s, delta) -> cube.rotate(Vec3.UP, delta)); // one radian a second

Viewport3D view = new Viewport3D(640, 480);   // 3D inside a panel of the 2D UI
view.setPosition(20, 20);
view.setContent(scene);
view.setInputListener(new OrbitControls(scene.camera())); // drag to turn, scroll to zoom

Container root = new Container(900, 520);
window.addContainer(root);
root.addElement(view);

ButtonOverlay close = new ButtonOverlay("Close", 120, 32);
close.setPosition(700, 20);
close.onAction(window::close);
root.addElement(close);

new Engine().start(window);

// Or put the same scene behind the whole window, with the UI on top:
// window.setBackground(new Background3D(window, scene));

Materials, lights, shadows and a sky

An HDR sky both lights the scene and reflects in the gold ball. A directional light adds sharp shadows nearby through three cascades. Tone mapping brings the bright sky into range; bloom and fog finish the picture.

Lighting.java
// Materials: classic for flat colours, PBR for anything that should look real.
Material gold = new Material(new Color(1f, 0.78f, 0.34f, 1f)).setMetallic(1f).setRoughness(0.25f);
Material lamp = new Material(Color.BLACK).setEmissive(Color.WHITE, 3f);   // glows

Node3D ball = new Node3D("ball", Mesh.sphere(0.8f, 48, 24), gold);
ball.setPosition(0, 0.8f, 0);
scene.add(ball);

// A sun with sharp-near, far-reaching shadows, and a spot light with its own.
Light sun = Light.directional(new Vec3(-0.5f, -1f, -0.35f), Color.WHITE, 1.1f)
        .setShadows(Shadows.of(ShadowQuality.HIGH).cascades(3).distance(80f));
Light spot = Light.spot(new Vec3(0, 5, 0), new Vec3(0, -1, 0), Color.WHITE, 3f, 20f, 20f, 35f)
        .setShadows(ShadowQuality.MEDIUM);
scene.lights().clear();
scene.lights().add(sun);
scene.lights().add(spot);

// An HDR sky that is both the backdrop and the light: the metal reflects it.
scene.setSkybox(Skybox.equirectHdr(HdrTextureData.load(Path.of("sky.hdr"))));
scene.setEnvironmentLighting(1f);
scene.setToneMapping(ToneMapping.ACES);   // brings the bright sun into range
scene.setExposure(0.8f);
scene.setBloom(0.6f);                     // a soft glow round the brightest parts
scene.setFog(new Color(0.75f, 0.6f, 0.8f, 1f), 0.02f);

Blinking lights and a finished look

A LightAnimation applies a LightPattern to lights and glowing materials, so a lamp and the bulb in it stay in step. A light at zero costs nothing and casts no shadow, so a blinking light is not counted while it is off. Occlusion, a colour grade and lens effects are each off until you set them.

Blinking.java
// A red lamp and the bulb in it, blinking together once a second.
Light lamp = Light.point(new Vec3(2, 3, 0), Color.RED, 6f, 8f);      // intensity 6, reach 8
scene.lights().add(lamp);
Material bulb = new Material(Color.BLACK).setEmissive(Color.RED, 4f);
Node3D bulbNode = new Node3D("bulb", Mesh.sphere(0.15f, 16, 8), bulb);
bulbNode.setPosition(2, 3, 0);
scene.add(bulbNode);

// Set the intensity and the glow first: they are the animation's full strength.
scene.animate(LightAnimation.of(LightPattern.blink(1f)).light(lamp).glow(bulb));
// Others: pulse(2f), flicker(12f, 0.6f, 7L), faulty(6f, 3L), sequence(0.25f, 1, 0, 1, 0, 0, 0)

// Finish the picture: grounded corners, a teal and magenta grade, a touch of lens.
scene.setAmbientOcclusion(0.8f);
scene.setAmbientOcclusionRadius(0.5f);
scene.setSaturation(1.2f);
scene.setContrast(1.15f);
scene.setShadowTint(new Color(0.55f, 0.85f, 1f, 1f));
scene.setHighlightTint(new Color(1f, 0.7f, 0.9f, 1f));
scene.setChromaticAberration(0.003f);
scene.setVignette(0.4f);

Models and skeletal animation

Loading reads files but never touches the GPU, so it is safe on a worker thread. The result callback runs on the render thread, where the scene can be changed.

LoadModel.java
Path path = Path.of("assets/soldier.glb");   // also OBJ, FBX and Collada

// Loading never touches the GPU, so do it on a worker thread.
Scheduler.async(() -> {
            try {
                return Model.load(path);
            } catch (IOException e) {
                throw new UncheckedIOException(e);
            }
        })
        .onSuccess(model -> {                       // back on the render thread
            scene.add(model.root());
            orbit.frame(model.bounds());            // aim the camera at it

            AnimationPlayer player = model.player();
            scene.animate(player);                  // advances once per frame
            player.play("Idle");
            // later: player.play("Run", 0.3f);     // blend into another clip over 0.3 seconds
        })
        .onError(e -> System.err.println("Could not load " + path + ": " + e.getMessage()));

Physics

A RigidBody moves a node; the world writes the position and rotation back each frame. Shapes are in the node's own units. Click to fire a ball from the camera into the crates. Physics is plain Java with no native library.

Physics.java
Scene3D scene = new Scene3D();
PhysicsWorld world = new PhysicsWorld();
scene.setPhysics(world);                    // steps once per frame from now on

Node3D floor = new Node3D("floor", Mesh.plane(20, 20), new Material(new Color(0.5f, 0.5f, 0.5f, 1f)));
scene.add(floor);
world.add(new RigidBody(floor, BodyType.STATIC).addShape(new PlaneShape()));

Mesh cube = Mesh.cube(1f);
Material wood = new Material(new Color(0.75f, 0.5f, 0.3f, 1f));
for (int i = 0; i < 5; i++) {
    Node3D crate = new Node3D("crate", cube, wood);
    crate.setPosition(i * 0.2f, 1f + i * 1.5f, 0);   // a wobbly column that will topple
    scene.add(crate);
    world.add(new RigidBody(crate).addShape(BoxShape.ofSize(1, 1, 1)).setMass(10f));
}

// Click to fire a ball from the camera.
Mesh ballMesh = Mesh.sphere(0.3f, 32, 16);
Material red = new Material(new Color(0.9f, 0.2f, 0.2f, 1f));
Viewport3D view = new Viewport3D(900, 600);
view.setContent(scene);
view.setInputListener(new Viewport3D.InputListener() {
    @Override
    public void clicked(double x, double y) {
        Ray ray = scene.camera().screenRay(x, y, view.getWidth(), view.getHeight());
        Node3D ball = new Node3D("ball", ballMesh, red);
        ball.setPosition(ray.origin());
        scene.add(ball);
        world.add(new RigidBody(ball).addShape(new SphereShape(0.3f)).setMass(5f)
                .setVelocity(ray.direction().normalized().mul(25f)));
    }
});

A working screen in the world

A UiScreen draws any container, buttons and text included, onto a surface in the scene. The player hovers and clicks it by aiming at the surface, and the same hit testing as a window decides what was pressed. It costs a CPU draw and a texture upload per refresh, so a screen that rarely changes should refresh only after a click.

Terminal.java
// Any container can be the screen: buttons, text, lists, animated backgrounds.
Container ui = new Container(320, 200);
ui.getStyling().setBackgroundColor(new Color(0.02f, 0.05f, 0.09f, 1f));
ButtonOverlay open = new ButtonOverlay("Open the door", 200, 40);
open.setX(60);
open.setY(80);
open.onMouseClick(e -> unlockDoor());
ui.addElement(open);

UiScreen screen = new UiScreen(ui, 2f);                              // a 640 x 400 texture
Material glass = new Material(Color.BLACK).setEmissiveTexture(screen.texture()).setEmissive(Color.WHITE, 2f);
Node3D terminal = new Node3D("terminal", Mesh.cube(1.2f), glass);
scene.add(terminal);

scene.setUpdateHandler((s, delta) -> screen.refresh(delta));         // draw it as it looks now

view.setInputListener(new Viewport3D.InputListener() {
    @Override
    public void pointerMoved(double x, double y) {
        screen.pointAt(scene.pick(x, y, view.getWidth(), view.getHeight()), terminal);   // hover
    }

    @Override
    public void pointerExited() {
        screen.pointAway();
    }

    @Override
    public void clicked(double x, double y) {
        screen.click(scene.pick(x, y, view.getWidth(), view.getHeight()), terminal);     // press
    }
});

Upscaling and ray tracing

Draw a fraction of the pixels and let an upscaler rebuild the rest; Upscalers.builtIn() needs no library and works on every GPU. DlssProvider, FsrProvider and MetalFxProvider come from the rengl-upscale module, and DLSS and FSR find the vendors' libraries at run time, which you download yourself. Ray tracing needs Vulkan; a GPU with ray queries traces in hardware and any other Vulkan 1.2 GPU traces in shader code. A scene that asks for something the GPU cannot do keeps what it had, so the calls are safe to leave on.

Tracing.java
scene.setRenderScale(0.5f);                 // draw a quarter of the pixels...
scene.setUpscaler(new DlssProvider());      // ...and let DLSS rebuild the rest
// scene.setUpscaler(Upscalers.builtIn());  // works on every GPU, no library needed

scene.setRayTracedShadows(true);            // exact shadows at any distance
scene.setRayTracedReflections(true);        // a polished floor shows the room around it
scene.setPathTracing(true);                 // light that bounces around the room
scene.setPathTracingBounces(4);
scene.setRayReconstruction(true);           // DLSS cleans up the noise

Levels of detail and PhysX

Levels of detail are generated for a mesh and picked for every node each frame, by how many pixels of error a simpler level would cause (next release). The physics world can be stepped by NVIDIA PhysX 5 instead of the built-in solver: add rengl-physx and the physx-jni natives for each platform, and the bodies, joints and characters you already wrote keep working.

Detail.java
tree.generateLods();                        // simpler levels, made with meshoptimizer
tree.setImpostor(true);                     // and a picture card for the far distance
scene.setLodPixelError(2);                  // 1 by default; 2 to 4 draws far fewer triangles

// The same physics world, stepped by NVIDIA PhysX 5.
if (PhysX.isAvailable()) PhysX.install();   // once, at startup
PhysicsWorld world = new PhysicsWorld();
scene.setPhysics(world);
world.add(new RigidBody(crate).addShape(new BoxShape(0.5f, 0.5f, 0.5f)));
⚙09 · APP PLUMBING

The parts every real app needs.

Callbacks always arrive on the render thread, so you can change the UI from them directly. Slow work goes on a worker thread, and its results come back the same way.

Native file dialogs

The operating system's own open and save dialogs. show() never blocks, and the callbacks run on the render thread, so they can update elements directly. The dialog only chooses a path; reading and writing is up to you.

ImportExport.java
importButton.onAction(() -> FileDialog.open()      // the operating system's own dialog
        .filter("Text files", "txt", "md")
        .onSelect(path -> {
            try {
                editor.setText(Files.readString(path));
            } catch (IOException e) {
                status.setText("Could not read " + path.getFileName());
            }
        })
        .show());                                  // never blocks; callbacks arrive on the render thread

exportButton.onAction(() -> FileDialog.save()
        .filter("Text files", "txt")
        .defaultName("notes.txt")
        .onSelect(path -> {
            try {
                Files.writeString(path, editor.getText());
            } catch (IOException e) {
                status.setText("Could not write " + path.getFileName());
            }
        })
        .show());

Timers and background work

Scheduler covers a splash screen, a repeating clock and slow work on a worker thread. Timers count frame time, so they stay in step with animations.

Timers.java
// A splash screen that becomes the main UI after three seconds.
window.addContainer(splash);
Scheduler.after(3f, () -> {
    window.removeContainer(splash);
    window.addContainer(main);
});

// A clock that ticks once a second, until you cancel it.
Task clock = Scheduler.every(1f, () -> time.setText(LocalTime.now().toString()));
// clock.cancel();

// Slow work goes on a worker thread. Touch the UI only in the callbacks.
Scheduler.async(() -> loadSaveFile(path))        // worker thread
        .onSuccess(save -> showMenu(save))       // render thread
        .onError(e -> status.setText("Load failed: " + e.getMessage()));

A loading screen's loader

A Loader runs named steps one after another and reports weighted progress. Steps marked as render-thread steps run one per frame, so the screen keeps drawing between them. What the loading screen looks like is up to you.

Boot.java
public class Boot {
    private final List<Sound> sounds = new ArrayList<>();
    private String map;
    private String level;

    void load(SceneManager scenes, TextOverlay status, List<String> files) {
        Loader loader = new Loader()
                .add("Map", progress -> map = "level-1")                    // worker thread
                .add("Sounds", 3f, progress -> {                            // weighs 3 times as much
                    for (int i = 0; i < files.size(); i++) {
                        sounds.add(Sound.load(files.get(i)));
                        progress.set(i + 1, files.size());                  // progress within the step
                    }
                })
                .addOnRenderThread("Scene", progress -> level = map + "!")  // render thread, one step per frame
                .onComplete(() -> System.out.println("ready: " + level))
                .onError(error -> status.setText("Couldn't load: " + error.getMessage()))
                .start();

        // Each frame, read loader.getProgress() (0 to 1) and loader.getCurrentStep() to draw a loading bar.
    }
}

Config files and where they live

AppEnvironment answers "where do my files live?" the same way from the IDE and from an installed build. Read shipped files from assets and write everything else to the per-user data folder.

Settings.java
AppEnvironment env = AppEnvironment.create("chat-app");

Path logo = env.getAssetPath("logo.png");        // shipped with the app, read-only
Path saves = env.getDirectory("saves");          // per-user and writable; created if missing

Config cfg = env.loadOrCreateConfig("settings.cfg", c -> {
    c.setDefault("window.width", 1280);          // only applied where the key is missing
    c.setDefault("audio.volume", 0.8);
    c.setDefault("engine-vsync", true);
});
int width = cfg.getInt("window.width", 1280);
double volume = cfg.getDouble("audio.volume", 0.8);

cfg.set("audio.volume", 0.5);
env.saveConfig("settings.cfg", cfg);             // always written to the per-user data folder

Downloads

Bytes go to a .part file and only move to the target once complete and verified. A dropped connection is retried and resumed. Ready-made progress displays read the download once per frame.

Fetch.java
Download d = new Download(URI.create("https://example.com/backend.zip"), Path.of("downloads/backend.zip"));
d.setExpectedSha256("9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08"); // verified before the file appears
d.setSegments(4);                  // up to 16 connections at once, where the server allows it
d.setMaxBytesPerSecond(2_000_000); // optional speed limit
d.start();                         // runs on background threads; pause() and start() resume it

Windows

One engine can drive any number of windows. Window options stay live: change a setter on a running window and the window changes, even the graphics API.

Windows.java
Window game = new Window(new WindowOptions("Game").setDimensions(960, 540));
game.onClose(() -> System.out.println("game window closed"));
game.open();                       // a second OS window, driven by the same engine

// Window options stay live: change them on a running window.
window.getWindowOptions().setTitle("My App - Level 2");
window.getWindowOptions().setAlwaysOnTop(true);
window.getWindowOptions().setFullscreen(true);
window.getWindowOptions().setRenderer(RenderAPI.VULKAN); // reopens the window on another graphics API
window.getWindowOptions().setBackgroundFPS(15);          // redraw less while no window has focus (default 30)

// A borderless splash that becomes the main window, all in one OS window.
window.setStyle(WindowStyle.STANDARD);
window.setSize(1280, 720);
window.center();

Rebindable controls

Game code asks about named actions, never about keys, so players can rebind them. A key code names a position on the keyboard, and getDisplayName returns what that key prints on the player's own layout.

Controls.java
InputContext controls = new InputContext("gameplay")
        .bind("jump", Binding.key(GLFW_KEY_SPACE), Binding.mouse(GLFW_MOUSE_BUTTON_RIGHT));

// In your settings screen, once the player has pressed a new key:
controls.setBindings("jump", Binding.key(GLFW_KEY_W));
controls.resetBindings("jump");                          // back to the defaults

String label = Binding.key(GLFW_KEY_Z).getDisplayName(); // what the key prints on their own keyboard layout

Gamepads

A controller is another way to trigger the same actions a key does, so most games add bindings and never poll a pad. Xbox, PlayStation and Switch Pro pads work with no setup. A stick binding counts as pressed past a press point, but getAxis follows the stick smoothly from 0 to 1.

Gamepad.java
InputContext controls = new InputContext("gameplay")
        .bind("jump", Binding.key(GLFW_KEY_SPACE), Binding.gamepad(Gamepad.Button.A))
        .bind("move_left", Binding.key(GLFW_KEY_A), Binding.gamepadAxis(Gamepad.Axis.LEFT_X, false))
        .bind("move_right", Binding.key(GLFW_KEY_D), Binding.gamepadAxis(Gamepad.Axis.LEFT_X, true));
scene.addInputContext(controls);

// In Scene.fixedUpdate:
float velocityX = controls.getAxis("move_left", "move_right") * speed;   // -1 to 1 on a stick, -1, 0 or 1 on keys
if (controls.isJustPressed("jump")) jump();

Speech and screen readers

Buttons, check boxes, sliders and links are Tab stops, and every element can name itself. With the rengl-accessibility module the window speaks each control as Tab lands on it, through SAPI on Windows, say on macOS and spd-say or espeak-ng on Linux. On Windows, NVDA, JAWS and Narrator also read the window through UI Automation; there is no screen reader connection on macOS or Linux yet. This is on main and arrives in the next release.

Speech.java
SpeechHost speech = Accessibility.enable(window);   // Tab now reads each control aloud
speech.setEnabled(true);                            // usually behind a setting
window.announce("Level complete");

ButtonOverlay play = new ButtonOverlay("Play", 160, 40);
play.setAccessibleName("Start the game");           // what a screen reader says
root.addElement(play);

A web page, and the splash screen

A WebViewOverlay shows a page inside its bounds, for a login portal or an embedded browser. It uses WebView2 on Windows and an installed Chrome, Edge, Chromium or Brave elsewhere. Every application opens with an animated RenGL splash; switch it off or give it your own. setCentered opens the window in the middle of the primary monitor (next release).

WebAndSplash.java
WebViewOverlay web = new WebViewOverlay("https://example.com", 900, 600);
root.addElement(web);

WindowOptions options = new WindowOptions("My App")
        .setDimensions(1280, 720)
        .setCentered(true)                  // open in the middle of the primary monitor
        .setSplashEnabled(false);           // skip the RenGL splash screen
⬇10 · PACKAGING

Ship it, with its own Java.

Your players do not have Java, so an app carries its own. The RenGL packager turns a Maven project into a folder with a native launcher, a private Java runtime and your jars, or into a setup.exe, a .deb or an .rpm. It builds all five platforms from one computer. It needs JDK 25, a Maven project that depends on io.github.piitex:RenGL, and the RenGL source folder.

Once: install the engine and its packager

The first command builds the engine and the packager into your local Maven repository. The second adds the Linux, macOS and Windows natives that the images for your other platforms need. Repeat both when you update the engine.

PowerShell, in the RenGL folder
cd C:\Path\To\RenGL
.\mvnw.cmd install -DskipTests
powershell -ExecutionPolicy Bypass -File rengl-packager\install-natives.ps1

Once per project: write its settings

Run the RenGL folder's package-app.ps1 with -Init in your project's folder. It looks at your pom.xml and sources and writes rengl-package.properties, whose values are guesses to check, and a package.cmd launcher with the path to the RenGL folder filled in. A misspelled setting is an error, not silently skipped.

PowerShell, in your project
cd C:\Path\To\MyApp
powershell -ExecutionPolicy Bypass -File C:\Path\To\RenGL\rengl-packager\package-app.ps1 -Init
rengl-package.properties
name=MyApp
mainClass=com.example.Main
version=1.0.0
platform=windows-x64,linux-x64,macos-arm64
installer=true
# installer=true gives a setup.exe on Windows, and a .deb and an .rpm on Linux.
# Without it you get a .zip or .tar.gz that runs where it is unpacked.
# Also: icon, vendor, description, identifier, addModules, content (a folder
# of files to ship beside the jars, such as assets), fileAssociation, shellVerb
# (an Explorer right-click entry), documentTypes (macOS), output and mainJar.

Build

package.cmd builds your project with Maven, collects the jars and natives, and runs the packager. Anything on the command line wins over the file for that run. The first build of another platform downloads that platform's Java modules once into ~/.rengl/jdks. Keep the project's path short, because Windows fails on paths over about 260 characters.

PowerShell, in your project
.\package.cmd
.\package.cmd -Installer
.\package.cmd -Platform all
.\package.cmd -Platform linux-x64,macos-arm64

# The results land in dist\app-images:
#   MyApp-1.0.0-windows-x64.zip       unzip and run MyApp.exe
#   MyApp-1.0.0-linux-x64.tar.gz      extract and run bin/MyApp
#   MyApp-1.0.0-macos-arm64.tar.gz    extract and open MyApp.app
# With installer=true the .zip becomes MyApp-1.0.0-windows-x64-setup.exe
# and each Linux .tar.gz becomes a .deb and an .rpm. macOS keeps its .tar.gz.

Silent installs

The Windows setup asks for an install folder and offers desktop and Start menu shortcuts. For scripts and package managers it also runs without a window. It installs for the current user by default, into %LOCALAPPDATA%\Programs\MyApp, and the uninstaller removes exactly the files the installer wrote. An install for all users choice (/ALLUSERS=1 when silent) installs into %ProgramFiles% instead and asks for administrator rights. On Linux, sudo apt install ./MyApp-1.0.0-linux-x64.deb or sudo dnf install ./MyApp-1.0.0-linux-x64.rpm puts the app in /opt/MyApp and adds an application-menu entry.

PowerShell
.\MyApp-1.0.0-windows-x64-setup.exe /S /DIR=C:\Tools\MyApp /DESKTOP=0 /STARTMENU=1 /LAUNCH
C:\Tools\MyApp\uninstall.exe /S
About these examples. Each Java snippet was compiled against the engine's source, the examples added for ray tracing, upscaling, PhysX, levels of detail, widgets, gamepads, accessibility, web views and the splash in November 2026 against the current main. Items marked next release are not in the 0.1.1 jars on Maven Central. The packaging commands and settings come from the engine's packaging guide. RenGL's API can still change before 1.0, and the documentation always has the current version. Asset paths such as assets/hero.png are placeholders for your own files.