Vulkan port

This commit is contained in:
2025-11-16 21:53:29 +01:00
parent 258dfe8ef5
commit 444d20243c
14 changed files with 32918 additions and 237 deletions

View File

@@ -1,13 +1,22 @@
const std = @import("std");
const cimgui = @import("cimgui");
const sokol = @import("sokol");
const zon = @import("build.zig.zon");
pub fn build(b: *std.Build) !void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const cimgui_conf = cimgui.getConfig(false);
const vulkan_dep = b.dependency("vulkan_zig", .{ .registry = b.path("vendor/vk.xml") });
const zglfw_dep = b.dependency("zglfw", .{ .import_vulkan = true });
const zstbi_dep = b.dependency("zstbi", .{});
const vulkan_mod = vulkan_dep.module("vulkan-zig");
const zglfw_mod = zglfw_dep.module("root");
const zstbi_mod = zstbi_dep.module("root");
zglfw_mod.addImport("vulkan", vulkan_mod);
const zglfw_lib = zglfw_dep.artifact("glfw");
const exe_mod = b.createModule(.{
.root_source_file = b.path("src/main.zig"),
@@ -15,40 +24,14 @@ pub fn build(b: *std.Build) !void {
.optimize = optimize,
});
const cimgui_dep = b.dependency("cimgui", .{
.target = target,
.optimize = optimize,
});
const sokol_dep = b.dependency("sokol", .{
.target = target,
.optimize = optimize,
.with_sokol_imgui = true,
});
sokol_dep.artifact("sokol_clib").addIncludePath(cimgui_dep.path(cimgui_conf.include_dir));
const zstbi_dep = b.dependency("zstbi", .{});
const sokol_mod = sokol_dep.module("sokol");
const shdc_dep = sokol_dep.builder.dependency("shdc", .{});
const shaders_mod = try sokol.shdc.createModule(b, "shaders", sokol_mod, .{
.shdc_dep = shdc_dep,
.input = "assets/shaders.glsl",
.output = "shaders.zig",
.slang = .{
.glsl430 = true,
.hlsl5 = true,
.metal_macos = true,
},
});
const zstbi_mod = zstbi_dep.module("root");
exe_mod.addImport("cimgui", cimgui_dep.module(cimgui_conf.module_name));
exe_mod.addImport("shaders", shaders_mod);
exe_mod.addImport("sokol", sokol_mod);
exe_mod.addImport("vulkan", vulkan_mod);
exe_mod.addImport("zglfw", zglfw_mod);
exe_mod.addImport("zstbi", zstbi_mod);
exe_mod.linkLibrary(zglfw_lib);
const options = b.addOptions();
options.addOption([]const u8, "version", zon.version);
exe_mod.addOptions("config", options);
const exe = b.addExecutable(.{
.name = "voxel-game",