What CNA offers
CNA provides a structured, incremental C++ implementation of the XNA 4.0 programming model. Below is a detailed overview of current and planned capabilities.
CNA implements 227 of the 245 public types in the XNA 4.0 API, measured against FNA. Every type in Graphics, Audio, Input, Media, Storage and the math namespace is present. Two things are deliberately absent and will shape any port: the .xnb content pipeline (raw assets plus JSON descriptors are used instead) and compiled .fx shader bytecode (custom shaders must be hand-written GLSL/SPIR-V). Verification is real: 4,373 unit tests and 490 GPU pixel-readback tests across four backends, plus differential testing against a running FNA build. 63 of the 86 official XNA samples build on it. APIs are still evolving — good for research, demos and porting experiments, not yet for shipping a commercial game.
XNA 4.0 API Implementation
CNA mirrors the Microsoft::Xna::Framework namespace hierarchy, translating XNA's C# API into idiomatic C++23.
Game Loop
The Game base class provides the full Initialize(), LoadContent(), Update(), Draw(), UnloadContent() lifecycle. GameTime, GameComponent, DrawableGameComponent, GameComponentCollection, GameWindow, and FrameworkDispatcher are all implemented.
SpriteBatch
Full 2D rendering abstraction. Supports all SpriteSortMode values, transform matrix, custom Effect, blend and sampler states. DrawString with SpriteFont included. Backend-agnostic across all supported backends.
Texture2D
Full texture lifecycle: load from disk, GetData/SetData for all mip levels, SaveAsPng/SaveAsJpeg, pixel cache. RenderTarget2D is a proper subclass with FBO + depth renderbuffer (EasyGL) or off-screen Vulkan images.
GraphicsDevice
Full render state API: BlendState, DepthStencilState, RasterizerState, SamplerState, scissor rect, viewport, render targets. DrawPrimitives, DrawIndexedPrimitives, DrawUserIndexedPrimitives, DrawInstancedPrimitives (EasyGL + Vulkan, hardware-accelerated instanced rendering), GetBackBufferData<Color> all implemented.
Math Types
Complete math library: Vector2/3/4, Matrix, Quaternion, Color, Rectangle, Point, BoundingBox, BoundingSphere, BoundingFrustum, Plane, Ray, MathHelper, Curve, CurveKey. All operators, static factories, and interpolation methods. 100% test coverage.
PackedVector Types
All 17 XNA 4.0 PackedVector types fully implemented in the Microsoft::Xna::Framework::Graphics::PackedVector namespace: Byte4, HalfSingle, HalfVector2/4, NormalizedByte2/4, NormalizedShort2/4, Rg32, Rgba1010102, Rgba64, Short2/4, Vector2/4. IEEE 754 half-float implemented from scratch (HalfTypeHelper) with full subnormal, ±∞, ±0, and NaN support.
Input
XNA-style input: Keyboard (full key set), Mouse (position, buttons, wheel), GamePad (all 4 players, axes, buttons, D-pad, triggers, dead-zone handling), TextInputEXT. TouchPanel is now ~98% behavior-complete: a byte-faithful FNA gesture-pipeline port (Tap, FreeDrag, Flick, Pinch...PinchComplete), fully wired end-to-end and tested with a deterministic clock.
Sensors (Accelerometer)
The XNA Accelerometer API is declared and compiles on all platforms. The SDL3 sensor backend for Android is structurally in place but needs runtime validation on hardware. On desktop (Linux/Windows) sensors are not applicable and return a zero-vector.
Audio
Implemented (SDL3_mixer): SoundEffect, SoundEffectInstance (volume, pitch, pan, looping), DynamicSoundEffectInstance, MediaPlayer/Song.
Also implemented (~97% functional): AudioEngine, SoundBank, WaveBank, Cue — a real .xgs/.xsb/.xwb XACT parser plus SDL3_mixer playback, with category/lifecycle/3D positioning/instance-limit and fade handling and continuous RPC volume/pitch curves. Microphone is wired to real SDL3 audio capture streams. Remaining gaps are documented accepted deviations (no HRTF/elevation, no AttackTime/ReleaseTime envelope tracking), not missing implementation.
Content System
Extensible ContentManager with ContentTypeReader<T> pattern. Built-in loaders: Texture2D (PNG/BMP/etc.), SpriteFont (.font.json), Model (.model.json), Effect (.shader.json), SoundEffect, Song, Video. No XNB pipeline — uses JSON descriptors instead.
GamerServices, Networking & Avatar
Complete XNA-shaped GamerServices API port: Gamer, SignedInGamer, GamerProfile, FriendGamer/FriendCollection, leaderboards, Guide, achievements — local/synthetic semantics, the same approach FNA itself uses for this namespace, not Xbox-Live-binary-compatible. Complete NetworkSession API (5 enums + 18 classes) with real ENet-backed (reliable UDP) networking for SystemLink sessions — hosting, joining, LAN discovery, and state broadcast all run over a genuine transport, verified across Linux (native, 2-process loopback), Windows (WinSock2 under Wine), Web/Emscripten (real ENet-over-WebSocket, client-only per browser sandbox), and Android (native ENet/UDP on a real x86_64 emulator). Avatar (AvatarAnimation/AvatarDescription/AvatarRenderer) is ported from a decompiled real Microsoft XNA 4.0 reference assembly — FNA itself never implemented Avatar at all.
3D Rendering Pipeline
Full 3D rendering is available today on the EasyGL (OpenGL ES 3.0) backend, including a playable 3D house demo in the browser.
3D Rendering
Four shader variants by vertex stride, depth test/write, blend, cull mode, matrix upload. Tested with the House 3D demo — procedural walls, roof, windows, door, floor with player movement and gravity. Also runs via WebGL 2 in the browser.
Effects System
Full XNA effects pipeline: BasicEffect, AlphaTestEffect, DualTextureEffect, EnvironmentMapEffect, SkinnedEffect, SpriteEffect. All IEffectMatrices, IEffectFog, IEffectLights interfaces. EffectParameter with all Get/Set overloads. SkinnedEffect supports up to 72 bones via a Uniform Buffer Object (UBO), with 1–4 skinning weights per vertex. Tested on EasyGL and Vulkan.
Vertex & Index Buffers
VertexBuffer, DynamicVertexBuffer, IndexBuffer (16/32-bit), DynamicIndexBuffer. All four VertexPosition* types: VertexPositionColor, VertexPositionTexture, VertexPositionColorTexture, VertexPositionNormalTexture.
Model System
Model::Draw with bone transforms, IEffectMatrices binding, and full mesh/part rendering pipeline. Models loaded from .model.json descriptors via ContentManager.
SpriteFont
Full glyph data model, MeasureString, and SpriteBatch::DrawString with three overloads. Fonts loaded from .font.json atlas descriptors.
Video Playback
FFmpeg-based frame decoding to RGBA texture via VideoPlayer. Supports MP4, OGV, WEBM, MKV, AVI, MOV. Available on Linux and Windows; excluded on Emscripten and Android.
MSAA 4× Anti-Aliasing
Multisample anti-aliasing at 4× is supported on the EasyGL and Vulkan backends. Enabled via GraphicsDeviceManager: set PreferMultiSampling = true and MultiSampleCount = 4 on PresentationParameters before device creation.
OcclusionQuery
Hardware occlusion queries are fully implemented and pixel-verified on EasyGL (OpenGL ES 3.0 GL_ANY_SAMPLES_PASSED). Useful for GPU-driven visibility culling. On Vulkan On bgfx, Begin/End wiring is real but pixel-verified correctness can't be confirmed in this project's CI sandbox. Not available on SDL_RENDERER (2D-only, no GPU query API).
Context-Loss Recovery
The EasyGL backend exposes DeviceLost and DeviceReset events on GraphicsDevice following the XNA pattern. Structural support for GPU context-loss events (relevant on Android and some desktop compositors) is in place; full automatic re-upload of all GPU resources is a work-in-progress.
SDL3 Foundation
SDL3 is the cross-platform foundation for windowing, input, audio, and surface lifecycle. CNA vendors SDL3 as a Git submodule - no system SDL packages are required.
Windowing & Events
SDL3 manages window creation, resizing, and the OS event loop. CNA wraps this through GameWindow and the Game run loop.
SDL3_mixer Audio
SDL3_mixer vendored as a submodule provides the audio backend. Mixer initialisation and basic playback are supported.
SDL3_image Loading
SDL3_image is used for loading PNG, JPG, and other texture formats into Texture2D. Vendored alongside SDL3.
Pluggable Rendering Backends
CNA separates the game-facing API from rendering implementation. A single CMake flag selects the backend at build time; all game code remains unchanged.
SDL_Renderer Backend
The most portable 2D backend. Uses SDL3's built-in hardware-accelerated renderer. Best for straightforward 2D workflows and broad platform compatibility. Selected with -DCNA_GRAPHICS_BACKEND=SDL_RENDERER.
EasyGL (OpenGL) Backend
Custom shader-driven rendering via the easy-gl helper library. Provides finer control over rendering behaviour and extensibility than the fixed SDL renderer. Selected with -DCNA_GRAPHICS_BACKEND=EASYGL.
bgfx Backend
Reached full 2D+3D pixel-verified parity with EasyGL and Vulkan as of Phase 72. Integration with the bgfx cross-platform graphics library (Vulkan, Metal, DX11/12, OpenGL). Integrated through CMake FetchContent. Selected with -DCNA_GRAPHICS_BACKEND=BGFX.
Known gaps: custom ShaderEffect (GLSL/SPIR-V source) compilation is unsupported — CreateEffectBackend returns nullptr. OcclusionQuery Begin/End wiring is real, but pixel-verified correctness can't be confirmed in this project's CI sandbox (software GL 2.1 driver, no dedicated-view architecture yet).
Vulkan Backend
Second-most mature backend after EasyGL. All five stock effects (BasicEffect, AlphaTestEffect, DualTextureEffect, EnvironmentMapEffect, SkinnedEffect) implemented. Supports instancing, RenderTarget2D/RenderTargetCube/MRT, MSAA 4x, per-slot sampler state, custom SPIR-V ShaderEffect, and GetBackBufferData pixel readback. DepthStencilState compare-op and stencil ops are fully real. Selected with -DCNA_GRAPHICS_BACKEND=VULKAN.
Fixed 2026-07-07: the multiple SpriteBatch::Begin()/End()-per-frame data-loss bug is resolved (Task 664). Known gaps: See the Roadmap.
Cross-Platform Architecture
CNA's SDL3 foundation makes it possible to target multiple operating systems and hardware platforms from a single codebase.
Linux (x86_64)
Primary development platform. GCC 12+ and Clang 15+ both tested. Both EASYGL and SDL_RENDERER backends are validated on Linux x86_64.
Windows (x86_64)
Supports MSVC 2022, clang-cl, and MinGW-w64. SDL_RENDERER backend cross-compiled with MinGW-w64 from Linux and verified running under Wine (not yet verified on native Windows hardware/CI).
Android
CNA runs on Android via SDL3's native Android support. CMake toolchain for the Android NDK is configured and validated on Android hardware.
Emscripten / Web
Full 2D and 3D rendering via EasyGL + WebGL 2. The House 3D Demo and CNA Demo are playable in the browser today. FFmpeg video excluded on this target.
Modern C++23 Codebase
C++23 Standard
CNA targets C++23 throughout. Requires GCC 12+, Clang 15+, or MSVC 2022 v17.8+.
CMake Build System
CMake 3.20+ with vendored SDL3/SDL3_image/SDL3_mixer as Git submodules. Backend selected with a single CMake flag.
Test Suite
GoogleTest unit suite (CnaTests): 4,371 of 4,373 pass, with 2 skipped because they need a physical accelerometer/gyroscope. Separately, 490 GPU pixel-readback tests run under ctest across all four backends — EasyGL 188/190, Vulkan 125/126, Bgfx 102/104, SDL_Renderer 67/67. The 5 open failures are each named and tracked; see Verification & Known Issues. All 17 PackedVector types are fully implemented with IEEE 754 half-float precision.
sharp-runtime
Sibling library providing .NET runtime type aliases (bytecs, intcs, Single, String), interfaces (IDisposable, IEquatable<T>), events, collections, and I/O — bridging C#/.NET conventions into C++23.