.NET 10 bindings for Nuklear, a single-header immediate-mode GUI library written in C.
Status: incomplete. Not all Nuklear widgets and API surface are wrapped. The high-level C# layer covers the core widget set and rendering pipeline, but several Nuklear features remain either unbound or untested. See Missing features.
| Project | Description |
|---|---|
Nuklear.Net |
High-level C# API (Context, InputFrame, NuklearDevice, …) |
Nuklear.Net.Native |
P/Invoke bindings generated by CppSharp against NuklearNetNative |
Nuklear.Net.NativeGen |
Code-gen driver (CppSharp) – run to regenerate the bindings |
Examples/ |
Backend integrations: Silk.NET/OpenGL, OpenTK 4, MonoGame |
Pre-built packages for all supported platforms are uploaded as the nuget-packages artifact on every CI run. Download them from the latest Build action — expand the run, scroll to Artifacts, and download nuget-packages.
No NuGet feed is published; the packages must be consumed from a local folder source or a private feed.
- .NET 10 SDK
- CMake ≥ 3.16
- A C99 compiler (GCC / Clang / MSVC)
The native shared library must be built before the managed projects can compile.
Linux / macOS
./scripts/build-native.sh linux-x64 # or linux-arm64 / osx-x64 / osx-arm64Windows
.\scripts\build-native.ps1 -Rid win-x64 # or win-arm64The script runs CMake, builds the shared library, and copies it to Nuklear.Net.Native/runtimes/<rid>/native/.
dotnet build Nuklear.Net.slnxdotnet run --project Examples/SilkNet/Nuklear.Net.Examples.SilkNet.csproj
dotnet run --project Examples/OpenTK/Nuklear.Net.Examples.OpenTK.csproj
dotnet run --project Examples/MonoGame/Nuklear.Net.Examples.MonoGame.csprojSee Examples/README.md for backend implementation details.
// 1. Create the context once.
using var ctx = new Context();
ctx.Initialize(device, NuklearRenderingOptions.CreatePixelPerfect());
// 2. Each frame:
ctx.RunFrame(device,
input =>
{
input.MousePosition = new Vec2(mouseX, mouseY);
input.SetMouseButton(MouseButton.Left, leftPressed);
},
() =>
{
// Nuklear UI built here via ctx.Native (NkContext)
});NuklearDevice is the rendering contract backends must implement:
CreateTexture– uploads RGBA pixel data (font atlas, etc.)SetDrawBuffers– receives converted vertex/index buffers fromnk_convertRenderDrawCommand– issues one draw call per Nuklear draw command (scissor + texture)
Context owns the Nuklear context lifetime, the font atlas, input dispatch, display metrics, and HiDPI scaling.
The following Nuklear functionality is not yet surfaced through the managed API:
- Custom font loading (only the built-in default font is exposed)
nk_plot/nk_plot_function(charts)nk_color_picker/nk_color_*widgetsnk_combo/nk_comboboxvariants beyond the basic bindingnk_popup_*managed wrappersnk_tooltipconvenience APInk_style_*full style struct access from C# (only uniform scaling is applied)- Multi-font support and glyph range selection
nk_list_view(fieldendis intentionally ignored by the generator)
Raw access through ctx.Native (the generated NkContext) is always available as a workaround for any missing wrapper.
dotnet run --project Nuklear.Net.NativeGen/Nuklear.Net.NativeGen.csprojRequires the native build for the host RID to already exist. Output is written to Nuklear.Net.Native/Generated/.