Immediate-mode GUI library (C/C++) with an SDL3 Zig demo application.
MDGUI_Input in = { .mouse_x = mx, .mouse_y = my, .mouse_down = down, .mouse_pressed = pressed, .mouse_wheel = wheel };
mdgui_begin_frame(ctx, &in);
if (mdgui_begin_window(ctx, "Debug Panel", 20, 20, 220, 140)) {
static float volume = 0.6f;
mdgui_label(ctx, "Audio", 8, 6);
mdgui_slider(ctx, "Volume", &volume, 0.0f, 1.0f, 8, 6, -16);
if (mdgui_button(ctx, "Apply", 8, 10, 60, 12)) {
// handle click
}
mdgui_end_window(ctx);
}
mdgui_end_frame(ctx);include/: Public headers (mdgui_c.h, primitives/font headers)src/: C/C++ implementation (mdgui_c.cpp,mdgui_glue.cpp)demo/: Zig demo app entrypoint (main.zig)scripts/release.sh: Optional helper scripts for POSIX release packagingscripts/release.ps1: Optional PowerShell helper for Windows release packaging
Prerequisites:
- Zig
0.15.2or newer - C/C++ toolchain supported by your Zig target
Commands:
zig build
zig build runPOSIX (Linux/macOS):
./scripts/release.sh 0.1.0Windows PowerShell:
./scripts/release.ps1 release 0.1.0Artifacts:
- Linux/macOS:
mdgui-<version>-<os>-<arch>.tar.gz - Windows:
mdgui-<version>-win64.zip
- Window identity is keyed by window title (
mdgui_begin_windowtitle string). - For best behavior, keep titles stable across frames.
mdgui now uses a pluggable render backend API instead of hard-wiring widget draw calls to SDL renderer APIs.
- Backend-agnostic core primitives/font code:
src/mdgui_glue.cpp - SDL compatibility backend implementation:
src/mdgui_backend_sdl.cpp - OpenGL compatibility backend adapter:
src/mdgui_backend_opengl.cpp - Vulkan draw-data backend (command stream):
src/mdgui_backend_vulkan.cpp - UI/window logic:
src/mdgui_c.cpp - Backend helper declarations:
include/mdgui_backends.h
MDGUI_Context *ctx = mdgui_create(sdl_renderer);For non-SDL renderers, provide a MDGUI_RenderBackend and create with:
#include "mdgui_backends.h"
MDGUI_BackendCallbacks callbacks = { ... };
MDGUI_RenderBackend backend = { ... };
// OpenGL adapter (for direct callback-style drawing):
mdgui_make_opengl_backend(&backend, &callbacks);
MDGUI_Context *ctx = mdgui_create_with_backend(&backend);Heavily inspired by the old Nes Emulator "NESticle" by: Icer Addis
