# hxn

> hxn generates Haxe bindings for a Rust library: one set of Haxe classes that runs on HashLink, Ash, hxcpp and CPPIA, natively and on wasm, with a native adapter for each runtime. The hxn libraries built with it give Haxe native windows (hxn-window), audio and video (hxn-av), audio output and mixing (hxn-audio), asynchronous file storage (hxn-file), annotated typed assets and remote streams (hxn-assets), GPU shaders translated when the program compiles (hxnsl), one GPU API over every driver (hxn-gpu), Metal, Vulkan, Direct3D 12 and OpenGL ES drivers (hxn-gpu-metal, hxn-gpu-vulkan, hxn-gpu-d3d12, hxn-gpu-gles), and WebGPU and WebGL2 drivers for the browser (hxn-gpu-webgpu, hxn-gpu-webgl2).

Each library has an agent skill: a SKILL.md whose frontmatter says when to use it, followed by instructions. They are listed below and in the Agent Skills discovery index at https://hxn.dev/.well-known/agent-skills/index.json, so `npx skills add https://hxn.dev` installs them. Released haxelibs also contain their skills under `skills/`.

## Agent skills

- [hxn](https://hxn.dev/.well-known/agent-skills/hxn/SKILL.md): Write a Rust library for Haxe with hxn's attributes, and build, test and package it with the hxn command.
- [hxn-log](https://hxn.dev/.well-known/agent-skills/hxn-log/SKILL.md): Core Haxe/Rust logging, application-owned shared sinks, severity filtering and native delivery.
- [hxn-window](https://hxn.dev/.well-known/agent-skills/hxn-window/SKILL.md): Native windows from Haxe: events, monitors, gamepads, the clipboard and GPU surface handles.
- [hxn-av](https://hxn.dev/.well-known/agent-skills/hxn-av/SKILL.md): Audio and video from Haxe with the platform's codecs: playback, frames, PCM audio, an equalizer, AAC and H.264, and MP4.
- [hxn-audio](https://hxn.dev/.well-known/agent-skills/hxn-audio/SKILL.md): Audio output, voices, bounded PCM streams, buses and effects on native and browser runtimes.
- [hxn-file](https://hxn.dev/.well-known/agent-skills/hxn-file/SKILL.md): Asynchronous bundled files, application saves and preferences across native and browser runtimes.
- [hxn-assets](https://hxn.dev/.well-known/agent-skills/hxn-assets/SKILL.md): Typed annotated payloads, dynamic values, optional content identity and bounded HTTP/WS streams.
- [hxnsl](https://hxn.dev/.well-known/agent-skills/hxnsl/SKILL.md): GPU shaders written in HXSL and translated at compile time to WGSL, MSL, HLSL, SPIR-V and GLSL ES, with their layouts as constants.
- [hxn-gpu](https://hxn.dev/.well-known/agent-skills/hxn-gpu/SKILL.md): One GPU API for Haxe on Metal, Vulkan, Direct3D 12, OpenGL ES, WebGPU and WebGL2, with features and limits per device, a default backend per platform and fallback.
- [hxn-gpu-metal](https://hxn.dev/.well-known/agent-skills/hxn-gpu-metal/SKILL.md): Metal from Haxe on macOS and iOS: compute and render passes, with hxnsl shaders compiled into Metal libraries at compile time.
- [hxn-gpu-vulkan](https://hxn.dev/.well-known/agent-skills/hxn-gpu-vulkan/SKILL.md): Vulkan from Haxe on Linux, Windows, Android and macOS: compute and rendering with explicit barriers, and hxnsl shaders as SPIR-V.
- [hxn-gpu-d3d12](https://hxn.dev/.well-known/agent-skills/hxn-gpu-d3d12/SKILL.md): Direct3D 12 from Haxe on Windows: compute, rendering, textures and presenting to a window, with resource transitions or enhanced barriers, and hxnsl shaders as DXIL or HLSL.
- [hxn-gpu-gles](https://hxn.dev/.well-known/agent-skills/hxn-gpu-gles/SKILL.md): OpenGL ES 3.0 from Haxe over EGL on Android, Linux through Mesa, and macOS and Windows through ANGLE: rendering, textures and windows, with hxnsl shaders as GLSL ES 3.00.
- [hxn-gpu-webgpu](https://hxn.dev/.well-known/agent-skills/hxn-gpu-webgpu/SKILL.md): WebGPU from Haxe in the browser, on hxcpp and Ash compiled to wasm: compute, rendering, textures and the web page's canvas, with hxnsl shaders as WGSL.
- [hxn-gpu-webgl2](https://hxn.dev/.well-known/agent-skills/hxn-gpu-webgl2/SKILL.md): WebGL2 from Haxe in the browser, on hxcpp and Ash compiled to wasm, for browsers without WebGPU: rendering, textures and the web page's canvas, with hxnsl shaders as GLSL ES 3.00.

## API reference

- [API reference](https://hxn.dev/api/): Every type of every hxn library, at its released version.
- [hxn 0.3.9](https://hxn.dev/api/hxn/): Shared logging, futures, streams, signals, reactive values, atomics and callbacks: the Haxe classes every hxn library uses.
- [hxn-window 0.2.2](https://hxn.dev/api/hxn-window/): Native and browser windows, input, monitors, gamepads and the clipboard, with handles for GPU surfaces.
- [hxn-av 0.2.1](https://hxn.dev/api/hxn-av/): Audio and video with the platform's codecs: playback, frames, PCM audio, an equalizer, AAC, H.264 and MP4.
- [hxn-audio 0.1.2](https://hxn.dev/api/hxn-audio/): Audio output and mixing: voices, bounded PCM streams, buses and effects on native and browser runtimes. The Av and DecoderStream helpers require hxn-av.
- [hxnsl 0.2.1](https://hxn.dev/api/hxnsl/): Shaders written in HXSL and translated at compile time to WGSL, MSL, HLSL, SPIR-V and GLSL ES.
- [hxn-gpu 0.2.4](https://hxn.dev/api/hxn-gpu/): One GPU API over every hxn GPU driver, with features and limits per device and a default backend per platform.
- [hxn-gpu-metal 0.2.1](https://hxn.dev/api/hxn-gpu-metal/): Metal on macOS and iOS: compute and render passes, with hxnsl shaders compiled into Metal libraries.
- [hxn-gpu-vulkan 0.3.1](https://hxn.dev/api/hxn-gpu-vulkan/): Vulkan on Linux, Windows, Android and macOS: compute, rendering, explicit barriers and swapchains.
- [hxn-gpu-d3d12 0.2.1](https://hxn.dev/api/hxn-gpu-d3d12/): Direct3D 12 on Windows: compute, rendering, textures and swapchains, with transitions or enhanced barriers.
- [hxn-gpu-gles 0.3.1](https://hxn.dev/api/hxn-gpu-gles/): OpenGL ES 3.0 over EGL on Android, Linux, macOS and Windows: rendering, textures and windows.
- [hxn-gpu-webgpu 0.3.4](https://hxn.dev/api/hxn-gpu-webgpu/): WebGPU in the browser, on hxcpp and Ash compiled to wasm: compute, rendering and the web page's canvas.
- [hxn-gpu-webgl2 0.3.3](https://hxn.dev/api/hxn-gpu-webgl2/): WebGL2 in the browser, on hxcpp and Ash compiled to wasm, for browsers without WebGPU.

## Docs

- [README](https://raw.githubusercontent.com/hx-n/hxn/main/README.md): Installing hxn, a first library, packaging, iOS, Android and wasm, and binding a C library.
- [CLI](https://raw.githubusercontent.com/hx-n/hxn/main/docs/cli.md): Every command and its options.
- [Packaging](https://raw.githubusercontent.com/hx-n/hxn/main/docs/packaging.md): What a haxelib built by hxn contains, and adding platforms to it.
- [Rust API rules](https://raw.githubusercontent.com/hx-n/hxn/main/docs/conventions/rust-api.md): What an exposed Rust API may contain: types, ownership, errors, async and callbacks.
- [Data](https://raw.githubusercontent.com/hx-n/hxn/main/docs/design/data.md): Records, enums, collections and field defaults, and how they cross to Haxe.
- [Handles](https://raw.githubusercontent.com/hx-n/hxn/main/docs/design/handles.md): Object ownership, `close()`, shared interfaces and atomics.
- [Futures, streams and signals](https://raw.githubusercontent.com/hx-n/hxn/main/docs/design/async.md): Asynchronous results, scheduling and delivery to Haxe.
- [Callbacks](https://raw.githubusercontent.com/hx-n/hxn/main/docs/design/callbacks.md): Haxe functions called from Rust.
- [Importing C libraries](https://raw.githubusercontent.com/hx-n/hxn/main/docs/design/c-import.md): `hxn import` and the WebIDL it writes.

## Libraries

- [hxn-file](https://raw.githubusercontent.com/hx-n/hxn-assets/main/packages/hxn-file/README.md): Portable asynchronous files, saves and preferences.
- [hxn-assets](https://raw.githubusercontent.com/hx-n/hxn-assets/main/packages/hxn-assets/README.md): Metadata-authored typed assets and remote streams.

- [hxn-window](https://raw.githubusercontent.com/hx-n/hxn-window/main/README.md): Windows and input over winit, for HashLink, Ash, hxcpp and CPPIA.
- [hxn-av](https://raw.githubusercontent.com/hx-n/hxn-av/main/README.md): Audio and video over AVFoundation, Media Foundation and GStreamer.
- [hxn-audio](https://raw.githubusercontent.com/hx-n/hxn-audio/main/README.md): Audio output and mixing, with the remaining validation roadmap.
- [hxnsl](https://raw.githubusercontent.com/hx-n/hxnsl/main/README.md): HXSL shaders for every GPU API, and how hxnsl differs from Heaps.
- [hxn-gpu](https://raw.githubusercontent.com/hx-n/hxn-gpu/main/README.md): One GPU API in Haxe over the hxn GPU drivers, with one barrier tracker for Vulkan and Direct3D 12.
- [hxn-gpu-metal](https://raw.githubusercontent.com/hx-n/hxn-gpu-metal/main/README.md): A Metal driver over Apple's framework, binding by hxnsl's slots.
- [hxn-gpu-vulkan](https://raw.githubusercontent.com/hx-n/hxn-gpu-vulkan/main/README.md): A Vulkan driver over the ash crate, binding by hxnsl's descriptor sets.
- [hxn-gpu-d3d12](https://raw.githubusercontent.com/hx-n/hxn-gpu-d3d12/main/README.md): A Direct3D 12 driver over the windows crate, binding by hxnsl's HLSL registers.
- [hxn-gpu-gles](https://raw.githubusercontent.com/hx-n/hxn-gpu-gles/main/README.md): An OpenGL ES 3.0 driver over EGL, loaded at run time, binding by hxnsl's GLSL names.
- [hxn-gpu-webgpu](https://raw.githubusercontent.com/hx-n/hxn-gpu-webgpu/main/README.md): A WebGPU driver for the browser, over Emscripten's WebGPU port on hxcpp and a browser agent on Ash, binding by hxnsl's bind groups.
- [hxn-gpu-webgl2](https://raw.githubusercontent.com/hx-n/hxn-gpu-webgl2/main/README.md): A WebGL2 driver for the browser, over Emscripten's WebGL2 on hxcpp and a browser agent on Ash, binding by hxnsl's GLSL names.

## Optional

- [Tutorials](https://hxn.dev/tutorials/): Walkthroughs of the CLI, runtimes and targets, data, callbacks and async, as HTML.
- [Examples](https://github.com/hx-n/hxn/tree/main/examples): Seven libraries, each a Rust crate with a Haxe program.
