`Gl.*` binds the whole OpenGL 4.1 core API — every entry point of the platform gl3.h with every GL_* constant, generated by `ludic-dev glgen` with per-call ABI thunks. Windowed builds get an NSOpenGLContext on the existing window at Retina resolution; headless builds render into an offscreen CGL context, so a program that uses Gl.* renders and screenshots identically under the test harness. It links gl.ll, the thunks and OpenGL.framework only when used; every other build stays byte-identical. packages/ludic.render3d is a physically based renderer written on that surface: HDRI image-based lighting, GPU-generated terrain with scanned PBR materials, CDLOD, cascaded shadows, glTF with skinning, instanced vegetation with impostors, procedural grass, water, SSAO, and an HDR pipeline with bloom, auto-exposure and ACES. It also carries this session's work on it: the terrain at half its cost (10.3 -> 5.4 ms of frame), the streaming hitch that got worse the longer you played, a resize that emptied the world, and the packaging that lets a game use the renderer from its own repository — `ludic assets`, the material manifest shipping with the package, and shader lookup falling back to the install root. See changes/ for each, with its numbers. The camping game that drove all of it has moved out to its own repository, Maroon Lake; examples/rendering/smooth.ludic stays as the renderer's example here. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
126 lines
5.8 KiB
Text
126 lines
5.8 KiB
Text
# ludic — the command-line interface to the Ludic language. One native binary
|
|
# (bin/ludic) written in Ludic and compiled by Ludic; the unix tools, clang and
|
|
# the compiler it drives are invoked through the `run` intrinsic.
|
|
#
|
|
# This is everything a user of the language does: create a project, build it, run
|
|
# it, test it, add a package, format, upgrade. Nothing here is about the
|
|
# toolchain's own repository — building the compiler, reseeding it, generating
|
|
# the docs site, cutting a release live in a separate tool (dev.ludic ->
|
|
# bin/ludic-dev) that only exists in a checkout and is never installed. Someone
|
|
# who installs Ludic should not have to read past commands they cannot use.
|
|
#
|
|
# Installing (macOS, Linux):
|
|
#
|
|
# curl -fsSL https://workshopsoft.pages.workshopsoft.io/ludic/install.sh | sh
|
|
#
|
|
# Building from a checkout — the one step Ludic cannot do for itself, since
|
|
# compiling Ludic needs a compiler:
|
|
#
|
|
# mkdir -p bin && clang selfhost/ludicc.seed.ll -o bin/ludicc
|
|
# bin/ludicc tools/ludic-cli/dev.ludic -o bin/ludic-dev
|
|
# bin/ludic-dev build
|
|
program Ludic {
|
|
import "prelude.ludic"
|
|
import "build.ludic"
|
|
import "project.ludic"
|
|
import "pkg.ludic"
|
|
import "assets.ludic"
|
|
|
|
function usage() -> void {
|
|
print("ludic — the toolchain for the Ludic language")
|
|
print("")
|
|
print("usage: ludic <command> [arguments]")
|
|
print("")
|
|
print("start a game:")
|
|
print(" new <name> create a project that builds and runs as it stands")
|
|
print(" run [file] [--headless] build the project and run it")
|
|
print(" build [file] [--headless] [-o out]")
|
|
print(" compile to build/<name> (a native binary, nothing to ship beside it)")
|
|
print(" test [file...] compile and run the project's tests")
|
|
print(" clean remove build/")
|
|
print("")
|
|
print("packages:")
|
|
print(" add <module>[@version] add a dependency, then resolve + fetch + link")
|
|
print(" get resolve every package.ludic dependency and write the lock")
|
|
print(" update [module] bump a dependency (or all) to its latest published version")
|
|
print(" verify check every locked package against the store by content hash")
|
|
print(" vendor copy the resolved packages into ./vendor for offline builds")
|
|
print(" assets [--force] fetch the CC0 materials the renderer needs into assets/polyhaven/")
|
|
print(" build-lib <module.ludic> compile a package's module to a prebuilt dylib in lib/<target>/")
|
|
print(" link-flags print the clang flags to link this project's prebuilt module dylibs")
|
|
print("")
|
|
print("the toolchain:")
|
|
print(" version print the toolchain version")
|
|
print(" upgrade [version] reinstall from the docs site (the same script that installed it)")
|
|
print(" doctor check that the install is complete and usable")
|
|
print(" fmt [--check] [paths...] format Ludic source in place (--check: report, write nothing)")
|
|
print(" lsp run the language server on stdio (what editors spawn)")
|
|
print(" help this message")
|
|
print("")
|
|
print("A file argument runs it: ludic mygame.ludic")
|
|
}
|
|
|
|
# does `s` end in ".ludic"? — `ludic mygame.ludic` runs that file, the shape
|
|
# the compiler-runner had before the CLI grew subcommands.
|
|
function is_ludic_file(s: pointer) -> bool {
|
|
let n = slen(s)
|
|
if n <= 6 { return false }
|
|
return sslice(s, n - 6, n) == ".ludic"
|
|
}
|
|
|
|
# route one subcommand to its implementation and return its exit code; -1 when
|
|
# the name is unknown. Returning (rather than exiting in place) lets entry tear
|
|
# down the per-process scratch directory before the process ends.
|
|
function dispatch(cmd: pointer) -> int {
|
|
if (cmd == "new") { return cmd_new() }
|
|
if (cmd == "build") { return cmd_build() }
|
|
if (cmd == "run") { return cmd_run() }
|
|
if (cmd == "test") { return cmd_test() }
|
|
if (cmd == "clean") { return cmd_clean() }
|
|
if (cmd == "fmt") { return cmd_fmt() }
|
|
if (cmd == "lsp") { return cmd_lsp() }
|
|
if (cmd == "doctor") { return cmd_doctor() }
|
|
if (cmd == "upgrade") { return cmd_upgrade() }
|
|
|
|
if (cmd == "add") { return cmd_pkg_add() }
|
|
if (cmd == "get") { return cmd_pkg_get() }
|
|
if (cmd == "update") { return cmd_pkg_update() }
|
|
if (cmd == "verify") { return cmd_pkg_verify() }
|
|
if (cmd == "vendor") { return cmd_pkg_vendor() }
|
|
if (cmd == "assets") { return cmd_fetch_assets() }
|
|
if (cmd == "build-lib") { return cmd_pkg_build_lib() }
|
|
if (cmd == "link-flags") { return cmd_pkg_link_flags() }
|
|
|
|
if (cmd == "version") or (cmd == "--version") or (cmd == "-v") { return cmd_version() }
|
|
if (cmd == "help") or (cmd == "--help") or (cmd == "-h") { usage(); return 0 }
|
|
|
|
# The toolchain's own tasks used to live here under `ludic dev`. Say where
|
|
# they went rather than printing "unknown command" at someone who read an
|
|
# older README or a commit message.
|
|
if (cmd == "dev") {
|
|
err("ludic: the toolchain's own tasks live in `ludic-dev`, which is built from a\n")
|
|
err(" checkout of the Ludic repository and is not part of an install:\n")
|
|
err(" clang selfhost/ludicc.seed.ll -o bin/ludicc\n")
|
|
err(" bin/ludicc tools/ludic-cli/dev.ludic -o bin/ludic-dev && bin/ludic-dev help\n")
|
|
return 1
|
|
}
|
|
return -1
|
|
}
|
|
|
|
entry {
|
|
if (arg_count() < 2) { usage(); exit(1) }
|
|
let cmd = arg(1)
|
|
# `ludic mygame.ludic` — build and run that file
|
|
if is_ludic_file(cmd) {
|
|
let rc = cmd_run_file()
|
|
tmp_cleanup()
|
|
exit(rc)
|
|
}
|
|
let code = dispatch(cmd)
|
|
tmp_cleanup()
|
|
if code >= 0 { exit(code) }
|
|
err(`ludic: unknown command '{cmd}'\n`)
|
|
usage()
|
|
exit(1)
|
|
}
|
|
}
|