Skip to content

Demos

The demos are UIs that show every feature of JOID, one card per case. They exist for backend authors: run them on a backend to see it draw everything, and read them to find a working example of any feature. They ship only in the demo jars, never to an application.

The core and every backend of a release come in three variants, and ./gradlew build in the template builds the same three for your backend. The -prod and -dev jars are those of the applications (Choose the dev or the prod jar); the -demo jar adds to the dev content the demo UIs with their fonts, models, textures and videos, and the demo windows, for backend authors only.

The variants differ by package: dev/joid/demo/**, assets/demo/** and the demo packages of the base modules and of the backends leave the dev jar; the dev tools, assets/dev/** and the snapshot packages also leave the prod jar. To check a packaged jar, call JarCheck.run from a main of your own and run it on the jar with its libraries: it registers your backend, draws 60 frames of a UI, then exits with 0, or with 1 when the modes do not match the variant, a stack trace is printed or the UI closed.

The jar decides the modes; nothing in the code of an application turns them on. JOIDEnv reads them once, from the classes present:

ModeOn when the classpath holdsRead with
Devthe class of the inspector, DevNode (dev and demo jars)JOIDEnv.isDevMode
DemoDemoFont (demo jar)JOIDEnv.isDemoMode

When it loads, JOID loads the dev font in both modes and the demo fonts in demo mode. A test can turn the dev mode off or on with JOIDEnv.devMode (Testing a backend); the demo mode follows the jar alone.

Each official backend has a launcher in its demo jar: run its main class with the libraries of the backend on the classpath, and -XstartOnFirstThread on macOS for the GLFW ones.

BackendMain class of the demo jarWindow
LWJGL 3dev.joid.backend.lwjgl3.demo.DemoWindowGLFW, OpenGL 3.3 core requested
Vulkandev.joid.backend.vulkan.demo.DemoWindowGLFW without client API, through a WindowVulkanHost
LWJGL 2dev.joid.backend.lwjgl2.demo.DemoWindowDisplay, 24-bit depth, 8-bit stencil, key repeats on
Your backend./gradlew runDemo in the templatethe DemoWindow of src/demo/java

Each official launcher opens a 1920×1080 resizable window titled JOID - Demo (<backend>), registers itself as the UI bridge, then registers the backend, opens the menu and runs the loop. Registered first, the launcher is the only UI bridge: registerDefaults() finds the UI registry filled and adds no WindowUIBridge, so the window shows the dark grey window background of the demos. The DemoWindow of the template opens no window: it registers itself the same way, then calls frame() until you give it the loop of your engine (Run it).

The launchers are UI bridges: DemoUIBridge, a WindowUIBridge with a dark grey window background and the dev font for its tooltips, opens the menu in start() through its openMenu() hook. The GLFW launchers share GlfwDemoWindow of base-lwjgl3-glfw, whose subclass names the backend, sets the window hints, registers the backend and presents each frame.

In the demos:

  • the menu shows one card per demo, and a click opens it; Escape always comes back to the menu, which itself never closes;
  • Ctrl+K opens a popup from the menu, and from that popup again;
  • the shortcuts of the dev mode work as in any application (Dev tools).
DemoShows
UIDemoChoiceThe menu.
UIDemoSimpleRectangles, borders, hover colors, circles, progress bars.
UIDemoOptionThe options of a UI and of popups: scale, interface scale, zoom, anchors, backdrop, transitions, tasks, forced opening.
UIDemoOverlayAn overlay, turned on and off from its card of the menu.
UIDemoLayoutFlex and grid layouts.
UIDemoOverflowScrolling and scrollbars.
UIDemoTextAlignment, truncation, modifiers.
UIDemoFontFonts, weights and glyphs.
UIDemoMarkupText markup and text effects.
UIDemoResourceImages, SVG, URLs, a failed resource, crops, mipmaps, custom formats and locators.
UIDemoPlayerVideo and animated images.
UIDemoAudioThe sound of videos: volume and positional sound.
UIDemoEventMouse and key events, lifecycle listeners, tasks and shortcuts, tooltips.
UIDemoEventFlowThe order of the events: priorities, consumption, listeners of the UI, the printed key against the physical position.
UIDemoCursorCursors and click-through.
UIDemoDraggableDragging and snapping.
UIDemoReorderableReorderable lists.
UIDemoTextFieldText, integer and multiline fields.
UIDemoControlCheckbox, toggle, switch, and a control of your own.
UIDemoSliderDouble, integer and string sliders.
UIDemoSelectorSelectors.
UIDemoSignalSignals and collections of signals.
UIDemoWatchWatches, waits and silent writes.
UIDemoStore, UIDemoOtherStoreStores of every scope and remembered fields, shared between two screens.
UIDemoEffectRounded corners and the other effects.
UIDemoAnimationNode animations: yoyo, delay, start on click.
UIDemoTweenTweens, easings and timelines.
UIDemoRenderThe drawing API, the matrix stack, blending, framebuffers, shader pipelines and custom shaders.
UIDemoShaderGradients, masks, custom effects and effects under a zoom.
UIDemoChartCharts, radar included.
UIDemoModelThe 3D model viewer.

The snapshot scenarios of the testkit open these demos, so every visible feature is checked on every backend (Testing a backend).

Report a problem with this page