CNA
View on GitHubA modern C++23 reimplementation of Microsoft XNA 4.0 with independent platform, audio and graphics layers.
CNA now has a Blog. Its articles describe different areas of CNA. Link: blog.libcna.com.
XNA samples, in C++ and in the browser. The C++ port of Microsoft’s XNA 4.0 samples is practically complete: 91 sample and game projects run as native C++ CNA programs, and 90 C++ builds are playable in your browser at samples.libcna.com. The Racing Game Kit is ported too, but not hosted. The original C# samples also run unchanged on CNA.NET. How these numbers are counted.
CNA actively maintains C and C# bindings. CNA itself is written in C++23, its native implementation language. The experimental C ABI (0.50.0 at this snapshot, opt-in build) exposes that implementation to other languages, and C# through CNA.NET is built on it: a Microsoft.Xna.Framework-compatible facade over the same native runtime, so existing XNA 4.0 C# game source often runs without being rewritten. CNA.NET is beta and admits exactly one ABI generation, 0.47.0 from mid-October; it does not yet build against this snapshot (details).
Archived language bindings: CNA also has eight further bindings — Common Lisp, Go, Java, Python, Ruby, Rust, Swift and TypeScript — several of them well advanced. They are archived in CNA Cemetery because keeping them current with a fast-moving pre-1.0 ABI took too much time, and may be revived if there is community interest.
Development snapshot after the 0.1.0 release. CNA released version 0.1.0 on 10 October 2026. This site documents the later commit 3b43bd86 (27 October 2026, branch next), 948 commits after the v0.1.0 tag; CNA’s version string is still 0.1.0 and public APIs may change before 1.0. Since the release CNA narrowed its renderer set to ten identities, with SDL_GPU as its modern native path and the default on Windows, macOS and iOS; dropped its compute and storage-buffer GPU layer; made every program link only the subsystems it uses (Link boundaries and binary size); generated its C API routes from a declarative specification (experimental C ABI now 0.50.0, whose release gate still reports “Not ready”); and worked through a 156-finding repair campaign driven by its demo suite. GitHub’s default branch is the 0.1.0 release, so clone next and check out 3b43bd86 to follow this documentation. See Releases & versioning for the exact boundary.
Read capabilities narrowly. The 10 public renderer identities share 8 implementation families and are not equally complete: SOFTWARE is a bounded CPU renderer, HEADLESS and STUB make no pixel claim, and SDL_GPU, the default on Windows, macOS and iOS, is qualified on Linux and, for its Direct3D 12 driver, under Wine only. A normal build contains one renderer; CNA_GRAPHICS_RENDERERS can opt into several compatible families and GraphicsRendererSelection chooses one before the first device. Platform host integration (CNA_PLATFORM), audio I/O (CNA_AUDIO_PLATFORM), graphics rendering and the target operating system are separate axes. Compiled XNA effects are not universal: FNA3D supports them by default and five more renderer families need an explicit build option, so a default build reports the capability on one identity only. The default Reach graphics profile is enforced on every renderer, so MRT, occlusion queries and float targets require HiDef.
XNA 4.0 for the modern C++ era
CNA brings the XNA programming model to native C++ without a managed runtime, while keeping host integration, audio and graphics independently selectable.
XNA-Compatible API
Public API follows XNA namespaces and patterns - Microsoft::Xna::Framework - so XNA knowledge transfers directly to CNA. All 3,627 documented XNA 4.0 runtime members across 331 types are represented in the public headers (representation, not a claim of identical behavior), and the previously missing Framework.Design converters now exist as an opt-in module. See XNA Compatibility.
Independent platform layer
CNA_PLATFORM selects one of three host integrations: SDL3 (default), the one windowing implementation, which reaches Windows, X11, Wayland, macOS, iOS, Android and the browser through SDL’s own video drivers, or the windowless Headless and POSIX Terminal hosts. CNA_AUDIO_PLATFORM independently accepts SDL3, ALSA (CNA’s own mixer) or Null; SDL3 and ALSA enable SOUND_ENABLED and the XNA playback engine. CNA_ENABLE_SDL=OFF builds a windowless binary without SDL entirely. See Platforms.
Pluggable Renderers
10 public renderer identities are implemented by 8 families. Single-renderer builds remain the compact default; compatible sets can be linked with CNA_GRAPHICS_RENDERERS and selected before device creation. The set spans OpenGL ES 3, desktop OpenGL 3.3 and WebGL 2 (one EasyGL family), WebGPU, SDL_GPU (on SDL’s Vulkan, Direct3D 12 and Metal GPU drivers), FNA3D, Direct3D 9, and the GPU-free Software, Headless and Stub implementations. See Renderers.
Native C++23
Full control over memory, lifetimes, and rendering. No garbage collector, no managed runtime - pure native performance.
Cross-Platform
Linux is the primary development host (SDL3 on X11 or Wayland) and the only place the full suites run. Windows runs through SDL3’s Windows driver with DIRECTX9 or SDL_GPU (the default there, on SDL’s Direct3D 12 driver); both are validated under Wine (DXVK, vkd3d-proton), and the native MSVC lane is manual. The browser is a real CNA platform through Emscripten, with WEBGL2 and WEBGPU — see the 90 playable sample builds. On macOS, CI builds with SOFTWARE and runs the portable platform suites and a bundle smoke app; SDL_GPU on SDL’s Metal driver is the default there but is not re-qualified on Apple hardware at this snapshot. iOS is experimental: a SOFTWARE smoke app runs in the iOS Simulator, and no physical iPhone or iPad has run CNA. Android uses OPENGLES3 by default and has NDK/source integration without an automatic gate; real games and samples have been run on the Android emulator.
Real .xnb Content Pipeline
A real XNB loader is wired into ContentManager with 61 built-in readers, LZX decompression and shared-resource resolution, and the load ladder tries .xnb, then CNA’s .cnb, then loose files. Each family of readers is installed the first time its type is loaded, so a game links only the readers it uses. The build-time Content Pipeline (cna-content, importers, processors and a .contentproj workflow) writes XNB and CNB — textures, cube and volume textures, sprite fonts, effects, sounds, songs and videos included — so CNA does not depend on XNA or MonoGame tooling to author content. See the CNB format.
PBR & Skeletal Animation
Beyond the XNA stock effects, CNA ships non-XNA (EXT) extensions: PbrEffect and SkinnedPbrEffect for physically based rendering with shadow and image-based-lighting inputs, SkinningData with AnimationPlayer and animation clips (the Avatar path has its own SkinnedModelEXT), and MorphTargetEXT blend shapes. Runtime glTF 2.0 loading works without a tooling step; the offline converter remains available. The opt-in CNAEXT module adds retro post-processing effects (ASCII, CRT and colour-depth reduction) and debug drawing. See CNAEXT extensions.
Built on sharp-runtime
CNA rests on sharp-runtime, a C++23 implementation of a practical .NET BCL subset covering System::Collections, IO, Text (including JSON and regular expressions), Net, Threading, Xml, Globalization and Numerics. It is a required sibling checkout with its own release cadence: CNA’s configure step checks that it declares version 0.1.0 (or a later 0.1.x). The 0.1.0 release pairs with sharp-runtime’s v0.1.0 tag; this later snapshot needs sharp-runtime’s next branch.
Verified Against Real XNA
A 39-scene oracle corpus of reference images captured from the genuine XNA 4.0 runtime (run under Wine with DXVK on Linux) is compared with CNA’s DIRECTX9 output at zero tolerance. The repository records all 39 scenes as pixel-exact on that path (the last consolidated report covers 31, later per-scene notes record the rest, and nothing was re-run for this site); the other renderers are held to a narrower bar, and none of this runs in CI. A running FNA build provides value-level differential checks. Real XNA programs are the other half of the evidence: 91 of Microsoft’s XNA 4.0 samples and games have complete C++ ports (cna-samples revision 5db32e6), 90 of them play in the browser, and 84 original C# sample programs run unchanged through CNA.NET. See the Showcase and Verification.
Diagnostics & Inspector
CNA_DIAGNOSTICS (OFF, STATS or FULL) records frame, resource and renderer statistics, and the opt-in Inspector exposes a running game to a browser UI through an authenticated local agent. Both are off by default and no CI lane builds them yet. Start with Diagnostics.
C# through CNA.NET
C++ is CNA’s implementation, and its C ABI opens it to other languages. CNA.NET builds on that ABI: CNA.XnaCompat exposes the Microsoft.Xna.Framework API, so existing XNA 4.0 C# source compiles against CNA’s native runtime, usually without changes to the game code. It targets source compatibility, not Microsoft’s binaries, and is beta. Start a new game from the dotnet new template or migrate an XNA, FNA or MonoGame game.
Runs in the browser
WebAssembly is a first-class CNA target, not a screenshot gallery: 90 C++ ports of Microsoft’s XNA samples are playable at samples.libcna.com, and more games are on the Play page. Saves persist in the browser’s storage, and games that start threads have a threaded build. CNA.NET has its own browser host for C# games, so far qualified in headless Chromium.
Gamer Services & Avatars
XNA’s GamerServices, Guide, avatars and NetworkSession work offline with local profiles, and can optionally connect to the self-hosted CNA Gamer Services server for accounts and sign-in, friends and presence, achievements and leaderboards, messages, parties, avatars and relayed online sessions with invitations and host migration. The server is CNA’s own and not Xbox LIVE compatible. See Gamer Services & Avatars.
Why CNA?
CNA fills a specific gap: there is no other mature native C++ reimplementation of the XNA 4.0 API.
No managed runtime
C++ avoids GC pauses, managed heap overhead, and JIT warmup. Useful for performance-critical or embedded scenarios where .NET is unavailable.
Familiar API
The XNA programming model is genuinely good design. CNA preserves it in C++ — if you know XNA or MonoGame, you'll be productive in minutes.
Pluggable renderers
Swap between OpenGL ES 3, desktop OpenGL 3.3, SDL_GPU (Vulkan, Direct3D 12 or Metal underneath), FNA3D, native Direct3D 9, browser WebGL 2, WebGPU, or the GPU-free Software and Headless renderers at build time — without changing a line of game code, and with several linked into one binary if you opt in.
Familiar XNA-style game loop
If you know XNA or MonoGame, CNA will feel immediately recognisable - just in native C++.
#include "Microsoft/Xna/Framework/Game.hpp"
#include "Microsoft/Xna/Framework/GraphicsDeviceManager.hpp"
#include "Microsoft/Xna/Framework/Graphics/SpriteBatch.hpp"
#include "Microsoft/Xna/Framework/Graphics/Texture2D.hpp"
using namespace Microsoft::Xna::Framework;
using namespace Microsoft::Xna::Framework::Graphics;
class MyGame final : public Game {
public:
MyGame() : graphics_(this) {}
protected:
void LoadContent() override {
spriteBatch_ = std::make_unique<SpriteBatch>(getGraphicsDeviceProperty());
logo_ = std::make_unique<Texture2D>("assets/logo.png", getGraphicsDeviceProperty());
}
void Draw(const GameTime& gameTime) override {
getGraphicsDeviceProperty().Clear(Color::CornflowerBlue);
spriteBatch_->Begin();
spriteBatch_->Draw(*logo_, 100.0f, 80.0f);
spriteBatch_->End();
Game::Draw(gameTime); // draws components; Game presents the frame after Draw returns
}
private:
GraphicsDeviceManager graphics_;
std::unique_ptr<SpriteBatch> spriteBatch_;
std::unique_ptr<Texture2D> logo_;
};
int main() { MyGame game; game.Run(); }
Get Started →
Get running from source
# 1. Clone CNA's documented branch and its sibling repositories (these are NOT submodules).
# GitHub's default branch of cna is the 0.1.0 release; this snapshot is on next. CNA's configure
# step checks the siblings' versions: sharp-runtime 0.1.x (its next branch for this snapshot),
# easy-gl 0.1.1 and meta-gl 0.4.1. For the 0.1.0 release itself, use the v0.1.0 tags instead.
git clone -b next https://github.com/libcna/cna.git
git -C cna checkout 3b43bd8687ed46523d873f9bec4b32bd8481dcb5
git clone -b next https://github.com/libcna/sharp-runtime.git
git clone -b v0.1.1 https://github.com/libcna/easy-gl.git
git clone -b v0.4.1 https://github.com/libcna/meta-gl.git
cd cna
git submodule update --init # non-recursive is correct, and much faster
# 2. System packages. FFmpeg is optional now (video throws NotSupportedException without it).
# Install the X11/GL/audio development headers BEFORE the first configure so the vendored SDL3
# gets real window and audio drivers; CI installs, on top of the basics below (abridged; the full list is on the Building page):
# libx11-dev libxext-dev libxrandr-dev libxi-dev libxcursor-dev libxkbcommon-dev
# libgl1-mesa-dev libegl1-mesa-dev libgles2-mesa-dev libasound2-dev libpulse-dev libdbus-1-dev
sudo apt install cmake g++ ninja-build pkg-config libcurl4-openssl-dev nlohmann-json3-dev
# 3. Configure and build (OPENGLES3 is the Linux default - needs OpenGL ES 3.0).
# The first configure also builds SDL3 from source, so allow a few minutes.
cmake -S . -B build -DCNA_GRAPHICS_RENDERER=OPENGLES3
cmake --build build --target cna_demo_2d
# 4. Build one of the 22 focused test targets (CnaMathTests, CnaContentTests, CnaInputModuleTests, ...).
# Many CTest entries are separate executables and GPU tests need a display: the build guide
# explains the CNA_TEST_DISPLAY policy and how to run them under xvfb-run.
cmake --build build --target CnaMathTests
Full Getting Started Guide →
All Build Options →
Development & Maintainer Guide →
Deep Dives →
Known Issues →
Engine, experiments and archive
CNA’s code lives in two GitHub organisations. github.com/libcna is the main one: CNA itself, sharp-runtime, easy-gl and meta-gl, CNA.NET, the templates and samples, cna-extended, cna-engine and the sources of these websites. Besides it, github.com/libcnalab is the organisation for experiments: simulators, games, tools and test beds that use CNA but are not part of it. Projects that are no longer developed rest, with their full history, in CNA Cemetery. The former cna-lab repository no longer exists: part of it moved into CNA Cemetery and part became separate repositories in libcnalab, and several repositories moved from libcna to libcnalab as well.
cna-engine
A C++23 game-engine layer above CNA that makes ordinary game code shorter without hiding CNA. It adds named input actions with rebinding, a fixed-step clock, camera controllers, mesh builders and GPU meshes, materials, render queues with culling, LOD and instancing, a forward renderer over XNA’s stock effects, sky and time of day, sun shadows, local lights, post-processing, positional audio, a HUD, menus and settings, save slots, collisions, a character controller and skeletal animation, and it reuses cna-extended instead of duplicating it. Its strict modules use only CNA’s XNA 4.0 types, so strict-XNA games can adopt it; the enhanced modules add PBR materials, glTF models and the cna-extended integration. A script starts a new first-person game that also builds for the browser.
Version 0.1.0 is experimental and MIT-licensed. Its two pilot games, Car Simulator and Street Simulator, run on it, and School, Backrooms and Train Simulator use it too.
cna-engine on GitHub ↗libcnalab — experiments
The GitHub organisation for experimental projects built on CNA, kept apart from the main libcna organisation. It holds the simulators — House, Car, Street, Room, Island, Museum, School, Backrooms and Train Simulator — together with CNA Craft (a port of fogleman/Craft), Wolf CNA (a retro first-person shooter), MeshCraft (a 3D scene editor), cna-rts (an RTS benchmark aiming at a million units), the CNA Benchmark suite, cna-killer (a fuzz tester disguised as a game) and cna-test.
These projects are not part of CNA and follow their own pace. Each is evidence only for its own revision and the CNA revision it was built with.
libcnalab on GitHub ↗ SimulatorsCNA Cemetery
The resting place of CNA projects that are no longer developed. Each was imported as a Git subtree with its complete, unsquashed history, so nothing is lost and a project can be revived from it. Under bindings/ it keeps the eight archived language bindings (Common Lisp, Go, Java, Python, Ruby, Rust, Swift and TypeScript) with their starter templates, plus a Kotlin layer and template over the archived Java binding and a VB.NET template.
It also keeps the standalone projects Black Pine (an exploration and puzzle adventure), CNA Studio (a visual development companion), Explore 2D (a 2D exploration engine), Myra CNA (a C++ port of the Myra UI library) and Tamagotchi CNA. Black Pine and Tamagotchi CNA remain playable on the Play page. Nothing in the cemetery is maintained.
cna-cemetery on GitHub ↗Related projects & references
CNA sits in a larger public ecosystem: required runtime layers, renderer libraries, starter projects, ports, tools, games and primary XNA references. The links below were re-checked against GitHub on 4 October 2026, including the public openeggbert GitHub account; several stale or dead links were corrected.
Release boundary: this site documents CNA snapshot 3b43bd86. Companion repositories have their own branches and release cadence; a link here means “related and public”, not that its current default branch builds against this exact snapshot. Numbers on these cards are tied to the named repository revision, not to CNA. Required sibling checkouts for a chosen CNA configuration are identified separately in the build guide.
CNA is partially based on FNA (C#). Portions of CNA's API design and implementation are derived from FNA - a managed C# reimplementation of XNA 4.0 by Ethan Lee, licensed under the Ms-PL. CNA translates these portions into native C++23. See About and the snapshot's THIRD_PARTY_NOTICES.md for full attribution.
Microsoft XNA 4.0 Documentation
The original XNA Game Studio 4.0 API documentation on Microsoft Learn - the reference CNA aims to be compatible with.
Microsoft Learn ↗FNA
FNA is a reimplementation of the Microsoft XNA Game Studio 4.0.4 libraries, targeting C#/.NET. CNA shares the Ms-PL licence and portions derived from FNA.
FNA Docs ↗MonoGame
MonoGame is a cross-platform successor to XNA for C#. Its documentation is a valuable reference for understanding the XNA API surface.
MonoGame Docs ↗sharp-runtime
The C++23 implementation of the practical System.* surface used throughout CNA: value types, strings, collections, IO, text, threading, XML, JSON and more. Every CNA build requires this sibling checkout at a 0.1.x version: its v0.1.0 tag pairs with CNA 0.1.0, and this snapshot needs its next branch.
easy-gl & meta-gl
meta-gl supplies type-safe OpenGL/OpenGL ES loading and calls; easy-gl adds the toolkit-independent object layer used by CNA's three EasyGL renderer identities. Clone both beside CNA when building those identities.
CNA glTF Viewer
A focused desktop viewer for .gltf and .glb assets. It exercises both CNA’s direct runtime glTF path and the cna_tool_gltf_to_cnj conversion path, including materials, skins and animation playback. The working code is on the repository’s develop branch.
CNA.NET
CNA’s C# binding: a Microsoft.Xna.Framework-compatible facade (CNA.XnaCompat) over an idiomatic managed API and an internal P/Invoke layer that talks only to CNA’s C ABI. It is beta and source-first; each revision admits exactly one reviewed C ABI version, currently 0.47.0, which an earlier CNA revision exports (this snapshot exports 0.50.0, which CNA.NET does not yet admit), and on a physical Mac mini M4 (osx-arm64) its suites, package acceptance, template and samples ran locally with an earlier CNA. Companion repositories: cna-dotnet-template (a dotnet new template with desktop, browser and Android heads), cna-dotnet-samples (the original XNA C# samples, unchanged) and cna-multi-language-3d-demo (one game in C++, C and C#).
Galaxy Eggbert
A playable 3D game and editor built directly on CNA and cna-engine. It provides a substantial real-game consumer for terrain, models, UI, audio, persistence and authoring workflows beyond isolated samples.
galaxy-eggbert on GitHub ↗Mobile Eggbert
A C++ migration of the 2013 Windows Phone XNA game (Speedy Blupi), decompiled from the original release, moved through MonoGame and then onto CNA. It consumes CNA directly, builds natively on desktop from source, has an Android Gradle/NDK project (no APK is published) and a playable browser build. Its results belong to the CNA revision it was built with, not to this snapshot.
mobile-eggbert on GitHub ↗MeshCraft
A C++23 scene editor and conversion toolchain for editable MC3 scenes and glTF/GLB output. Its graphical editor has a CNA rendering path, while its command-line converters can run without CNA. It is one of the experimental projects in libcnalab.
mesh-craft on GitHub ↗cna-samples
91 C++ ports of Microsoft’s XNA Game Studio 4.0 samples and games are complete in the repository’s own plan (revision 5db32e6, 3 October 2026), and 90 C++ builds are published as playable browser builds. The plan audits 153 entries (SAMPLE-001 to SAMPLE-153), not 153 games: 8 relevant XNA 4.0 C# programs remain, and 54 entries are not port targets (XNA 3.x or older, Silverlight, WinForms tools, VB.NET, C++, asset packs). The Racing Game Kit is ported in its own plan and is not hosted. These are results for CNA next on that date, not for this snapshot. Shader-driven samples such as Bloom, ShadowMapping and Skinning run through CNA’s compiled-effect path.
Car Simulator
A realistic passenger-car driving simulator in a fictional Czech landscape, built on CNA next and sharp-runtime next, with traffic, weather, a day-night cycle and a helicopter. It is one of cna-engine’s two pilot games. Playable in the browser; two videos on the CNA YouTube channel. More simulators are listed on the Play page.
Street Simulator
A procedurally generated European inner-city street — a signalised junction, traffic, pedestrians, shadows and reflections — rendered with CNA, formerly called CNA Street. It is cna-engine’s second pilot game. The web build generates the street in your browser, so the first start takes about a minute.
Play in Browser ↗ street-simulator on GitHub ↗cna-extended
A C++23 port of MonoGame.Extended with about 100,000 lines of C++ (102,360 lines in 890 files at revision 5775ecc97). All 18 upstream subsystems are implemented — tilemaps (Tiled TMX, LDtk and Ogmo), particles, ECS, screens, tweening, collisions, bitmap fonts, input listeners, animations and more — plus a non-upstream World3DEXT layer: an ECS-based 3D renderer with frustum culling, skinned models, octree and spatial-hash broadphases, a 3D particle system and voxel tilemaps. Its default build is headers-only — pass -DCNA_EXTENDED_LINK_CNA=ON to actually link. The working code is on the develop branch.
cna-examples
A single browsable catalogue app that teaches CNA’s own APIs, one demo screen at a time — Home → Area → Category → Demo, navigable at runtime with no rebuild. At revision ea33c9a29 (13 September 2026) the catalogue registers 249 demo screens across 13 areas, all populated, with a catalogue checker and a headless sweep tool; its README reports all 249 rendering in a headless sweep.
cna-template
The starting point for a new CNA game. The C++ is deliberately tiny — a HelloGame that loads a texture and moves it — because the build wiring is the actual product: per-renderer CMake presets, a complete Android gradle project, MinGW-w64 cross-compilation, Emscripten asset preloading, Windows DLL deployment and a dependencies.lock pinning exact CNA and sharp-runtime commits. Its public revision pins CNA from 11 August 2026 and its weekly CI is currently red, so treat it as a template to adapt, not as a verified build of this snapshot.
xna4-spec
A machine-readable XML catalogue of the XNA 4.0 API surface, scraped from Microsoft's original documentation and validated against a hand-written schema. It is useful as a checklist of namespaces, types and members, but its one-line summaries do not define runtime semantics or conformance. CNA does not consume it at build time.
xna4-spec on GitHub ↗CNA ecosystem map
The public umbrella repository explains how CNA, sharp-runtime, rendering layers, tools and preservation projects fit together. Use it to discover adjacent work; its moving project summaries are not the source of truth for this documentation snapshot.
libcna on GitHub ↗