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

93%
XNA 4.0 types present
4,373
Unit tests
490
GPU pixel tests
63/86
XNA samples ported
4
Rendering backends

Development preview. Measured against FNA (the reference XNA 4.0 implementation), 227 of 245 XNA 4.0 public types are present in CNA — including every type in Graphics, Audio, Input, Media, Storage and the math namespace. Presence is not the same as fidelity: of the 26 major Graphics classes, 12 have no known behavioural gap, 11 have a narrow named gap, and 2 have a confirmed bug. Two things are genuinely absent by design: the .xnb content pipeline (CNA loads raw PNG/WAV/OGG assets plus JSON descriptors instead) and compiled .fx shader bytecode (custom shaders are hand-written GLSL/SPIR-V). Verified by 4,373 unit tests and 490 GPU pixel-readback tests across four backends, with 5 known open failures — all named and tracked. APIs are still evolving; not yet recommended for shipping production games.

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

Select a rendering backend at build time: SDL_RENDERER, EASYGL (OpenGL), BGFX, or VULKAN. Game code stays the same.

🏅

Native C++23

Full control over memory, lifetimes, and rendering. No garbage collector, no managed runtime - pure native performance.

🖥

Cross-Platform

Linux x86_64, Android, Emscripten/WebGL 2 (browser), and Windows (SDL_RENDERER backend, cross-compiled with MinGW-w64 and verified running under Wine) are all supported today.

🎮

Real-World Validated

The Speedy Blupi game has been ported to run on CNA, exercising SpriteBatch, input, audio, content loading, and game loop semantics simultaneously. Browser demos (House 3D + CNA Demo) run live via WebGL 2.

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 SDL_RENDERER, OpenGL (EasyGL), Vulkan, and bgfx 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 related open-source efforts.

📝

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. 63 of the 86 addressable samples are ported and enabled in the build — including Platformer, MarbleMaze, RolePlayingGame and CatapultWars.

cna-samples on GitHub ↗