Skip to content

SimonSeider/Nuklear.Net

Repository files navigation

Nuklear.Net

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


Projects

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

NuGet packages

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.

Requirements

  • .NET 10 SDK
  • CMake ≥ 3.16
  • A C99 compiler (GCC / Clang / MSVC)

Building the native library

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

Windows

.\scripts\build-native.ps1 -Rid win-x64   # or win-arm64

The script runs CMake, builds the shared library, and copies it to Nuklear.Net.Native/runtimes/<rid>/native/.

Building the solution

dotnet build Nuklear.Net.slnx

Running examples

dotnet 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.csproj

See Examples/README.md for backend implementation details.

Basic usage

// 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)
    });

Architecture

NuklearDevice is the rendering contract backends must implement:

  • CreateTexture – uploads RGBA pixel data (font atlas, etc.)
  • SetDrawBuffers – receives converted vertex/index buffers from nk_convert
  • RenderDrawCommand – 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.

Missing features

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_* widgets
  • nk_combo / nk_combobox variants beyond the basic binding
  • nk_popup_* managed wrappers
  • nk_tooltip convenience API
  • nk_style_* full style struct access from C# (only uniform scaling is applied)
  • Multi-font support and glyph range selection
  • nk_list_view (field end is intentionally ignored by the generator)

Raw access through ctx.Native (the generated NkContext) is always available as a workaround for any missing wrapper.

Regenerating bindings

dotnet run --project Nuklear.Net.NativeGen/Nuklear.Net.NativeGen.csproj

Requires the native build for the host RID to already exist. Output is written to Nuklear.Net.Native/Generated/.

Star History

Star History Chart

About

No description or website provided.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages