Low cortisol graphics
Find a file
2026-08-14 01:15:10 +01:00
examples Added imgui example | Added getRawFrame() 2026-08-14 01:15:10 +01:00
src Added imgui example | Added getRawFrame() 2026-08-14 01:15:10 +01:00
tools HelloWorld 2026-08-11 21:06:28 +01:00
zig-out/bin Low cortisol depth management 2026-08-12 20:31:05 +01:00
.gitignore Low cortisol depth management 2026-08-12 20:31:05 +01:00
build.zig Added imgui example | Added getRawFrame() 2026-08-14 01:15:10 +01:00
build.zig.zon added stuff and improved stuff | added getRaw(resource) that returns tagged union of backend specific raw resources instead of getRaw(backend)(resource) | much cleaner 2026-08-13 00:37:11 +01:00
compile.sh Added imgui example | Added getRawFrame() 2026-08-14 01:15:10 +01:00
imgui.ini Added imgui example | Added getRawFrame() 2026-08-14 01:15:10 +01:00
README.md Added imgui example | Added getRawFrame() 2026-08-14 01:15:10 +01:00
zls.json Let there be images 2026-08-12 14:52:27 +01:00

NYXGFX

Low cortisol crossplatform RHI (Rendering Hardware Interface)

Backends

  • Vulkan
  • OpenGL
  • DX12

Features

  • Fire and forget
  • Dead simple + Performance + Flexible
  • Generational Handles
  • Auto managed
  • No hidden control flow
  • No hidden memory allocations
  • No preprocessor, no macros

Architecture

examples/simple/simple.zig

src/gfx.zig
  └─ Selected Backend

src/rhi/root.zig
  └─ Common / Handles / Configs

src/rhi/vulkan/vulkan.zig
  └─ Vulkan Backend / RHI

src/rhi/vulkan/resource.zig
  └─ Adapter / Device / Shader
Function Description
makeX(...) Creates an RHI resource and returns its handle
deleteX(handle) Releases the resource and invalidates the handle
releaseX(handle) Releases the resource but keeps the handle valid
getXInfo(handle) Returns backend-independent information about the resource
getRawX(handle) Returns backend-specific raw GPU handle
getRawFrame() Returns backend-specific raw GPU frame resources

Example

Core

const adapter = try gfx.makeAdapter(.{});
const surface = try gfx.makeSurface();
const device = try gfx.makeDevice(adapter, surface);
const swapchain = try gfx.makeSwapchain(adapter, device, surface);

Buffers

const vbuf = try gfx.makeBuffer(vertices, .vertex, adapter, device);
const ibuf = try gfx.makeBuffer(indices, .index, adapter, device);

Shaders

const simple_vert = try gfx.makeShader("examples/assets/shaders/compiled/simple.vert.spv", device);
const simple_frag = try gfx.makeShader("examples/assets/shaders/compiled/simple.frag.spv", device);

Pipelines

const pipeline = try gfx.makePipeline(.{
    .vertex_attributes = &.{
        .{ .location = 0, .format = .vec2, .offset = @offsetOf(Vertex, "pos") },
        .{ .location = 1, .format = .vec2, .offset = @offsetOf(Vertex, "normal") },
        .{ .location = 2, .format = .vec2, .offset = @offsetOf(Vertex, "uv") },
    },
    .vertex_binding = .{ .stride = @sizeOf(Vertex) },

    .uniforms = &.{
        .{ .name = "material", .offset = 0, .size = @sizeOf(UnlitMaterial) },
    },

    .textures = &.{texture},

    .blend_mode = .alpha,

    .vert_shader = simple_vert,
    .frag_shader = simple_frag,

    .device = device,
    .swapchain = swapchain,
});

Render Pass

if (gfx.beginPass(swapchain, .{
    .clear_color = .{ 0.01, 0.01, 0.01, 1.0 },
})) |pass| {
    defer pass.end();

    try vbuf.bind();
    try ibuf.bind();

    try pipeline.setUniform("material", material);

    try pipeline.bind();
    pass.drawIndexed(indices.len, 1, 0, 0, 0);
}

House

switch (try gfx.getRawAdapter(adapter)) {
    .vulkan => |v| std.debug.print("---> {}\n", .{v}),
}

switch (try gfx.getRawDevice(device)) {
    .vulkan => |v| std.debug.print("---> {}\n", .{v}),
}

switch (try gfx.getRawFrame()) {
    .vulkan => |v| {
        const draw_data = im.ImGui_GetDrawData() orelse return;

        im_vk.cImGui_ImplVulkan_RenderDrawData(
            @ptrCast(draw_data),
            @ptrCast(v.cmd_buf),
        );
    },
}

Examples

  • zig build run-simple
  • zig build run-3D
  • zig build run-imgui