Work in Progress

CNA

View on GitHub

A modern C++ reimplementation of the Microsoft XNA 4.0 API, built on SDL3 with a pluggable rendering backend layer.

Licensed under the Microsoft Public License (Ms-PL)  ·  C++23  ·  SDL3

~99%
XNA 4.0 types present
~75%
Functional coverage
4,845
Unit tests
648
Backend pixel tests
63/86
XNA samples ported
14
Rendering backends

Development preview. Essentially every public XNA 4.0 type is present — the only outright absences are five reflection-only ContentSerializer attributes that have no meaning in C++, plus a few XNB type readers. Presence is not behaviour, and CNA is explicit about the split: type presence is roughly 99%, weighted functional coverage roughly 75%. Graphics, Input, Audio, Net, Storage and the math namespace are production-real; Media's catalogue types and all 51 GamerServices types are deliberate API-shaped no-ops that let XNA code compile but persist nothing. A real .xnb content pipeline now exists — 49 registered type readers and a genuine LZX decompressor wired into ContentManager — you call RegisterAllBuiltInXnbReaders() once at startup. The biggest remaining gap is compiled .fx shader bytecode, which throws unconditionally; custom shaders must be hand-written GLSL/SPIR-V through the NOXNA ShaderEffect. Only SurfaceFormat::Color textures can be constructed today. Verified by 4,845 unit tests and 648 backend pixel/integration tests across 14 selectable backends, plus a 39-scene XNA oracle corpus diffed pixel-exactly against a real XNA 4.0 reference renderer. APIs are still evolving; not yet recommended for shipping production games.

📝

Honest caveats. Ten of the fourteen backends were created within roughly the last two weeks, and maturity tracks age closely — only EasyGL is production-ready. SupportsCapability() is unreliable: the base implementation returns true for everything and 8 of the 14 backends never override it. CI is thin — only one workflow is auto-triggered (Linux, gcc-14, a 5-way backend matrix running just the input-labelled tests); the full unit suite and the GPU pixel suites are run locally, not gated by CI, and there is no macOS, Android or Emscripten CI. Media and Storage have zero unit tests. macOS handling is minimal and there is no iOS support.

XNA 4.0 for the modern C++ era

CNA brings the beloved XNA programming model to native C++, without a managed runtime, built on the solid cross-platform foundation of SDL3.

XNA-Compatible API

Public API follows XNA namespaces and patterns - Microsoft::Xna::Framework - so XNA knowledge transfers directly to CNA.

🔗

SDL3 Foundation

SDL3 provides the cross-platform layer for windowing, input, audio, and surface management. No system SDL packages required - built from vendored submodules.

🌐

Pluggable Backends

14 backends, selected at build time with -DCNA_GRAPHICS_BACKEND — exactly one per build, no runtime dispatch. EASYGL (OpenGL) is production-ready; VULKAN, D3D9, D3D11, SDL_GPU, SOFTWARE, DX3 and ASCII are functional; SDL_RENDERER and CANVAS are mature within a 2D-only scope; D3D12, BGFX and WEBGPU are partial; HEADLESS renders nothing by design, for fast CI. Game code stays the same across all of them.

🏅

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 platform (default EASYGL backend) and the only one with automatic CI. Windows is reached through a MinGW-w64 cross-toolchain and native MSVC; the D3D9/D3D11/D3D12 backends are Windows-gated, verified from Linux via Wine+DXVK / vkd3d-proton and — for D3D11/D3D12 — on real Windows through a manual MSVC workflow. Web/Emscripten is a real path with its own CMake preset and the Emscripten-only CANVAS backend. Android is genuinely wired through CMake and the NDK. macOS handling is minimal; iOS is not supported.

📦

Real .xnb Content Pipeline

A genuine XNB reader (~4,000 LOC) is wired into ContentManager: 49 registered type readers covering primitives, math types, textures, SpriteFont, SoundEffect, Song, the stock effects and the model family, plus a real LZX decompressor and two-pass shared-resource resolution. ContentManager prefers a .xnb when one exists and falls back to loose files otherwise.

PBR & Skeletal Animation

Beyond the six XNA stock effects, CNA ships non-XNA (NOXNA) extensions: PbrEffect and SkinnedPbrEffect for physically based rendering, SkinnedModelEXT with AnimationPlayer and animation clips for skeletal animation, and MorphTargetEXT blend shapes. An offline glTF 2.0 converter is CNA's actual content path for models.

🔧

Built on sharp-runtime

CNA rests on sharp-runtime, a serious project in its own right: a C++23 reimplementation of a .NET BCL subset — 135,204 LOC and roughly 12,375 test cases — covering System::Collections, IO, Text (including a full JSON implementation and Regex), Net, Threading, Xml, Globalization and Numerics.

🎮

Verified Against Real XNA

A 39-scene oracle corpus is rendered by a real C#/XNA reference renderer and diffed pixel-exactly against CNA's D3D9 output at zero tolerance, alongside differential testing against a running FNA build. 63 of the 86 official XNA 4.0 samples build on cna-samples, and CNA Craft plus the browser demos exercise the API under real game-code conditions.

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 backends

Swap between OpenGL (EasyGL), Vulkan, SDL_Renderer, SDL_GPU, bgfx, native Direct3D 9/11/12, DirectDraw-shaped Dx3, browser Canvas, experimental WebGPU, an ASCII-grid renderer, or the GPU-free Software and Headless backends at build time — without changing a line of game code.

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/Graphics/GraphicsDeviceManager.hpp"
#include "Microsoft/Xna/Framework/Graphics/SpriteBatch.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(CornflowerBlue);
        spriteBatch_->Begin();
        spriteBatch_->Draw(*logo_, 100.0f, 80.0f);
        spriteBatch_->End();
        getGraphicsDeviceProperty().Present();
    }

private:
    GraphicsDeviceManager graphics_;
    std::unique_ptr<SpriteBatch> spriteBatch_;
    std::unique_ptr<Texture2D> logo_;
};

int main() { MyGame game; game.Run(); }
Get Started →

Get running in 5 minutes

# 1. Clone CNA and its dependencies
git clone https://github.com/openeggbert/cna.git
git clone https://github.com/openeggbert/sharp-runtime.git
git clone https://github.com/openeggbert/easy-gl.git
cd cna
git submodule update --init --recursive

# 2. Build (EasyGL backend — requires OpenGL ES 3.0)
cmake -S . -B build -DCNA_GRAPHICS_BACKEND=EASYGL
cmake --build build --target CNA CnaTests

# 3. Run the tests
ctest --test-dir build --output-on-failure
Full Getting Started Guide → All Build Options →

Related projects & references

CNA draws inspiration from the XNA ecosystem, and is surrounded by a set of sibling projects that build on it. Each is linked as a sibling checkout via CMake — none is a submodule, and the dependency runs one way: CNA itself has no knowledge of them.

📝

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 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 ↗

cna-samples

C++ ports of the official Microsoft XNA Game Studio 4.0 sample collection: 86 samples, of which 63 currently build. The 23 that do not are almost all blocked by the same gap — compiled .fx shader bytecode.

cna-samples on GitHub ↗

cna-extended

A C++23 port of MonoGame.Extended, and the largest project in the ecosystem at ~65,000 lines. All 18 upstream subsystems are implemented, none of them skeletons — tilemaps (Tiled TMX, LDtk and Ogmo), particles, ECS, screens, tweening, collisions, bitmap fonts, input listeners, animations and more. It adds 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. 2,363 tests pass. Note its default build is headers-only — pass -DCNA_EXTENDED_LINK_CNA=ON to actually link.

cna-extended on GitHub ↗

cna-craft

A working port of Michael Fogleman's Craft — a creative-mode voxel sandbox with real multiplayer, not a Minecraft clone. 16³ chunks streamed by column, simplex terrain, 56 block types, a 27-neighbourhood ambient-occlusion meshing pass, an authoritative server speaking Craft's own ASCII wire protocol, and SQLite persistence of player edits. The cleanest codebase of the set: zero TODOs and zero stubs across 10,000 lines. Native builds work; the Emscripten build currently black-screens.

cna-craft on GitHub ↗

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. 60 demos are registered so far, covering Input (50) and Audio (10). Devices, Net, Media and both Graphics areas appear in the menu but are still empty, and there are no tests yet.

cna-examples on GitHub ↗

cna-template

The starting point for a new CNA game. The C++ is deliberately tiny — 140 lines that load a texture and move it with the arrow keys — because the build wiring is the actual product: 9 CMake presets, a complete Android gradle project, MinGW-w64 cross-compilation, Emscripten asset preloading, Windows DLL deployment, a dependencies.lock pinning exact CNA and sharp-runtime commits, and CI across Linux, Windows, web and Android.

cna-template on GitHub ↗

xna4-spec

A machine-readable XML database of the XNA 4.0 API surface, scraped from Microsoft's original documentation and validated against a hand-written XSD: 544 types across 19 namespaces, with 1,955 properties, 1,629 methods and 871 enum members catalogued. Useful as a checklist of what XNA 4.0 contains — but it carries only Microsoft's one-line summaries, with no semantics or conformance criteria, so it is not a specification in the strict sense. It is a reference artifact: CNA does not consume it at build time.

xna4-spec on GitHub ↗