Giter Site home page Giter Site logo

zig-gamedev / zig-gamedev Goto Github PK

View Code? Open in Web Editor NEW
2.0K 31.0 145.0 58.18 MB

Main monorepo for @zig-gamedev libs and example applications

License: MIT License

Zig 4.63% C++ 27.40% C 56.25% CMake 0.05% Objective-C 10.63% R 0.72% Roff 0.01% Rez 0.32%
gamedev zig libraries demos graphics directx12 math d3d12 simd ziglang

zig-gamedev's Introduction

Libraries - Getting Started - Sample applications - Others using zig-gamedev

zig-gamedev project

We build game development ecosystem for Zig programming language, every day since July 2021. Please consider supporting the project. We create:

Vision

  • Very modular "toolbox of libraries", user can use only the components she needs
  • Just Zig is required to build on Windows, macOS and Linux - no Visual Studio, Build Tools, Windows SDK, gcc, dev packages, system headers/libs, cmake, ninja, etc. is needed
  • Building is as easy as zig build
  • Libraries are written from scratch in Zig or provide Ziggified bindings for carefully selected C/C++ libraries
  • Uses native wgpu implementation (Dawn) or OpenGL for cross-platform graphics and DirectX 12 for low-level graphics on Windows

Getting Started

Download the latest archive or clone/submodule with Git.

Note: If using Git then you will need Git LFS to be installed.

Get Zig

Our main branch is currenly tracking Zig 0.13.0-dev.46+3648d7df1.

zigup is recommended for managing compiler versions. Alternatively, you can download and install manually using the links below:

OS/Arch Download link
Windows x86_64 zig-windows-x86_64-0.13.0-dev.46+3648d7df1.zip
Linux x86_64 zig-linux-x86_64-0.13.0-dev.46+3648d7df1.tar.xz
macOS x86_64 zig-macos-x86_64-0.13.0-dev.46+3648d7df1.tar.xz
macOS aarch64 zig-macos-aarch64-0.13.0-dev.46+3648d7df1.tar.xz

If you need to use a more recent version of Zig, you can try our unstable branch. But this is not generally recommended.

Build and run the Samples

To get started on Windows/Linux/macOS try out physically based rendering (wgpu) sample:

zig build physically_based_rendering_wgpu-run

To get a list of all available build steps:

zig build -l

Using the Libraries

Copy each library to a subdirectory in your project and add them as local package dependencies. For example:

build.zig.zon

.{
    .name = "MyGame",
    .version = "0.0.0",
    .dependencies = .{
        .zglfw = .{ .path = "libs/zglfw" },
        .system_sdk = .{ .path = "libs/system-sdk" },
    },
    .paths = "",
}

build.zig

pub fn build(b: *std.Build) void {
   const exe = b.addExecutable(.{ ... });

   const zglfw = b.dependency("zglfw", .{});
   exe.root_module.addImport("zglfw", zglfw.module("root"));
   exe.linkLibrary(zglfw.artifact("glfw"));
}

Refer to each lib's README.md for further usage intructions.

Option to download packages using Zig Package Manager coming soon!

Libraries

Library Description
zaudio Cross-platform audio using miniaudio
zbullet Build package, C API and bindings for Bullet physics
zd3d12 Helper library for DirectX 12
zflecs Build package and bindings for flecs ECS
zglfw Build package & bindings for GLFW
zgpu Small helper library built on top of Dawn native WebGPU implementation
zgui Build package and bindings for Dear Imgui (includes ImPlot)
zjobs Generic job queue implementation
zmath SIMD math library for game developers
zmesh Loading, generating, processing and optimizing triangle meshes
znoise Build package & bindings for FastNoiseLite
zopengl OpenGL loader (supports 4.2 Core Profile and ES 2.0 Profile)
zopenvr Bindings for OpenVR
zphysics Build package, C API and bindings for Jolt Physics
zpix Support for GPU profiling with PIX for Windows
zpool Generic pool & handle implementation
zsdl Bindings for SDL2 and SDL3
zstbi Image reading, writing and resizing with stb libraries
ztracy Support for CPU profiling with Tracy
zwin32 Bindings for Win32 API (d3d12, d3d11, xaudio2, directml, wasapi and more)
zxaudio2 Helper library for XAudio2

Sample applications (native wgpu)

Some of the sample applications are listed below. More can be found in samples directory.

  1. physically based rendering (wgpu): This sample implements physically-based rendering (PBR) and image-based lighting (IBL) to achive realistic looking rendering results.
    zig build physically_based_rendering_wgpu-run

    physically based rendering (wgpu)

  2. audio experiments (wgpu): This sample lets the user experiment with audio and observe data that feeds the hardware.
    zig build audio_experiments_wgpu-run

    audio experiments (wgpu)

  3. bullet physics test (wgpu): This sample application demonstrates how to use full 3D physics engine in your Zig programs.
    zig build bullet_physics_test_wgpu-run

    bullet physics test (wgpu)

  4. procedural mesh (wgpu): This sample shows how to efficiently draw several procedurally generated meshes.
    zig build procedural_mesh_wgpu-run

    procedural mesh (wgpu)

  5. gui test (wgpu): This sample shows how to use our zgui library.
    zig build gui_test_wgpu-run

    gui test (wgpu)

Sample applications (DirectX 12)

Some of the sample applications are listed below. More can be found in samples directory. They can be built and run on Windows and Linux (Wine + VKD3D-Proton 2.8+):

  1. bindless: This sample implements physically based shading and image based lighting to achieve realistic looking rendering results. It uses bindless textures and HLSL 6.6 dynamic resources.
    zig build bindless-run

    bindless

  2. rasterization: This sample application shows how GPU rasterizes triangles in slow motion.
    zig build rasterization-run

    rasterization

  3. simple raytracer: This sample implements basic hybrid renderer. It uses rasterization to resolve primary rays and raytracing (DXR) for shadow rays.
    zig build simple_raytracer-run

    simple raytracer

  4. mesh shader test: This sample shows how to use DirectX 12 Mesh Shader.
    zig build mesh_shader_test-run

    mesh shader test

Others using zig-gamedev

  • Tides of Revival - First-person, open-world, fantasy RPG being developed in the open
  • Simulations - GPU Accelerated agent-based modeling to visualize and simulate complex systems
  • krateroid - 3D strategy game
  • blokens - Voxel game
  • Delve Framework - Simple game framework for making games with Lua
  • jok - A minimal 2D/3D game framework for Zig
  • Aftersun - Top-down 2D RPG
  • Pixi - Pixel art editor made with Zig

zig-gamedev's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

zig-gamedev's Issues

It looks like tracy integrations has issues with names and colors

Hi,

I was trying the tracy integration but it seems to work different than expected. Having never used tracy before and being new to Zig I might be doing something wrong though.

When I extend the intro2 sample with the following (silly) code

// Draw dear imgui widgets (not used in this demo).
    {
        if (true) {
            const tracy_zone = tracy.zoneNC(@src(), "B", 0x00ffff00, 1);
            defer tracy_zone.end();
            {
                {
                    const tracy_zone1 = tracy.zoneNC(@src(), "B1", 0x0000ff00, 1);
                    defer tracy_zone1.end();
                    std.time.sleep(std.time.ns_per_ms * 20);
                }
                {
                    const tracy_zone2 = tracy.zoneNC(@src(), "B2", 0x000000ff, 1);
                    defer tracy_zone2.end();
                    std.time.sleep(std.time.ns_per_ms * 30);
                }
            }

            std.time.sleep(std.time.ns_per_ms * 50);
        }
        demo.guictx.draw(gctx);
    }

I get the following->

image

The timings, lengths of the bars, are OK but the names and colors not.
The behavior isn't the same al the time though. Sometimes it work as intended and sometimes it shows "?" as names. But the image above is what I get most often.

Apart from that I am really impressed by what I have seen of your work.

Samples wishlist

Hey! I really love the progress and currently also learning Zig. Maybe you have some paticular samples which you would to code, but just haven't time, so I or community could contribute?

MacOS doesn't show imgui interface

Hello again Michal,

I just pulled down zig-gamedev (version 2684288) on Win10 (with a Vega64 card, bottom left), Arch Linux (R9 380 card, bottom right) and an M1 Mac (Big Sur, top right). Everything seemed to build and run fine at first glance (except the error with tests previously mentioned in #51), but then I clued in to the fact that the MacOS version doesn't have any imgui interface for the wgpu examples. Here is a pic of all three running the triangle example:
Zig-GameDev-MacOS-Linux-Win10

Perhaps the MacOS version shouldn't have the interface and I just missed it in the docs? Or is this a bug on my machine?

P.S. Also, one small difference I noticed between these three programs is that the Win10 spinning triangles actually stop spinning when I drag the window around...then the spinning starts again after I stop dragging the window around (or even if I just right click on the window header! ). The Arch/Mac triangles continue to spin if I drag the window around. A Win10 quirk with the driver? Not sure...and not a big deal, I am just mentioning it as a curiosity.

Triangle sample build faild on linux

Building main branch with latest zig on linux(nixos)

  zig-gamedev/samples/triangle on  main via ↯ v0.9.0 via ❄️  impure (Autotools - flake) 
  ❯ ~/Apps/zig-dev/zig build run
  /ComboDrive/Work/zig/zig-gamedev/libs/common/graphics.zig:669:22: error: expected type 'i32', found 'c_long'
              .right = @intCast(c_long, gr.viewport_width),
                       ^
  /ComboDrive/Work/zig/zig-gamedev/libs/common/graphics.zig:669:22: note: signed 32-bit int cannot represent all possible signed 64-bit values
              .right = @intCast(c_long, gr.viewport_width),
                       ^
  triangle...The following command exited with error code 1:
  /home/js/Apps/zig-dev/zig build-exe /ComboDrive/Work/zig/zig-gamedev/samples/triangle/src/triangle.zig -lc -lc++ -limm32 -cflags  -- /ComboDrive/Work/zig/zig-gamedev/external/src/imgui/imgui.cpp -cflags  -- /ComboDrive/Work/zig/zig-gamedev/external/src/imgui/imgui_widgets.cpp -cflags  -- /ComboDrive/Work/zig/zig-gamedev/external/src/imgui/imgui_tables.cpp -cflags  -- /ComboDrive/Work/zig/zig-gamedev/external/src/imgui/imgui_draw.cpp -cflags  -- /ComboDrive/Work/zig/zig-gamedev/external/src/imgui/imgui_demo.cpp -cflags  -- /ComboDrive/Work/zig/zig-gamedev/external/src/cimgui.cpp --cache-dir /ComboDrive/Work/zig/zig-gamedev/samples/triangle/zig-cache --global-cache-dir /home/js/.cache/zig --name triangle -rdynamic --pkg-begin build_options /ComboDrive/Work/zig/zig-gamedev/samples/triangle/zig-cache/options/3v24a7wLqcnNNUn8gLQ5X0sqr6l7MwvahZWuq0JJ7H9LGiwKhDhczT85kkusiJHX --pkg-end --pkg-begin win32 /ComboDrive/Work/zig/zig-gamedev/libs/win32/win32.zig --pkg-end --pkg-begin common /ComboDrive/Work/zig/zig-gamedev/libs/common/common.zig --pkg-begin win32 /ComboDrive/Work/zig/zig-gamedev/libs/win32/win32.zig --pkg-end --pkg-begin build_options /ComboDrive/Work/zig/zig-gamedev/samples/triangle/zig-cache/options/3v24a7wLqcnNNUn8gLQ5X0sqr6l7MwvahZWuq0JJ7H9LGiwKhDhczT85kkusiJHX --pkg-end --pkg-end -I /ComboDrive/Work/zig/zig-gamedev/external/src -fno-lto --enable-cache 
  error: the following build command failed with exit code 1:
  /ComboDrive/Work/zig/zig-gamedev/samples/triangle/zig-cache/o/fce1bedc82f303e56f85153783ad1a1a/build /home/js/Apps/zig-dev/zig /ComboDrive/Work/zig/zig-gamedev/samples/triangle /ComboDrive/Work/zig/zig-gamedev/samples/triangle/zig-cache /home/js/.cache/zig run

Zig version

~/Apps/zig-dev/zig env
  {
   "zig_exe": "/home/js/Apps/zig-dev/zig",
   "lib_dir": "/home/js/Apps/zig-dev/lib",
   "std_dir": "/home/js/Apps/zig-dev/lib/std",
   "global_cache_dir": "/home/js/.cache/zig",
   "version": "0.10.0-dev.724+27cfbf949"
  }

Any plan on 2D game support?

Hi @michal-z , I've being following your work closely, nice work!

A quick question, will you consider add libs for 2d games? e.g. box2d/vector graphics/spine animation etc.

I'm asking because I think most indie developers choose 2d over 3d game (at least initially), since a decent 3d game requires way more expertise and amount of work.

[zgpu] mach-glfw build fails on fresh install

I followed the "getting started" guide in the zgpu readme. I cloned the zig-gamedev repository and copied the zgpu, zmath and zpool directories into my project's vendor directory. The following happened on the first build attempt:

$ zig build test --verbose
fatal: not a git repository (or any of the parent directories): .git
downloading https://github.com/hexops/mach-gpu-dawn/releases/download/release-f90302f/libdawn_x86_64-linux-gnu_debug.a.gz..
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 26.5M  100 26.5M    0     0  12.0M      0  0:00:02  0:00:02 --:--:-- 19.2M
downloading https://github.com/hexops/mach-gpu-dawn/releases/download/release-f90302f/headers.json.gz..
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 46762  100 46762    0     0  87555      0 --:--:-- --:--:-- --:--:-- 87555
fatal: not a git repository (or any of the parent directories): .git
/home/boop/bin/zig/zig build-lib /home/boop/code/zig/hexaflex/wgpu/vendor/zgpu/libs/mach-glfw/src/main.zig -cflags -D_GLFW_X11 -D_GLFW_WAYLAND -I/home/boop/code/zig/hexaflex/wgpu/vendor/zgpu/libs/mach-glfw/upstream/glfw/src -- /home/boop/code/zig/hexaflex/wgpu/vendor/zgpu/libs/mach-glfw/src/sources_all.c /home/boop/code/zig/hexaflex/wgpu/vendor/zgpu/libs/mach-glfw/src/sources_linux.c /home/boop/code/zig/hexaflex/wgpu/vendor/zgpu/libs/mach-glfw/src/sources_linux_x11.c /home/boop/code/zig/hexaflex/wgpu/vendor/zgpu/libs/mach-glfw/src/sources_linux_wayland.c -lc -lX11 -lxcb -lXau -lXdmcp --cache-dir /home/boop/code/zig/hexaflex/wgpu/zig-cache --global-cache-dir /home/boop/.cache/zig --name glfw -static -target native-native-gnu -mcpu skylake -I /home/boop/code/zig/hexaflex/wgpu/vendor/zgpu/libs/mach-glfw/upstream/glfw/include -I /home/boop/code/zig/hexaflex/wgpu/vendor/zgpu/libs/mach-glfw/upstream/vulkan_headers/include -isystem /home/boop/.local/share/hexops/sdk-linux-x86_64/root/usr/include -isystem /home/boop/.local/share/hexops/sdk-linux-x86_64/root/usr/share/wayland-generated -L /home/boop/.local/share/hexops/sdk-linux-x86_64/root/usr/lib/x86_64-linux-gnu -D WL_MARSHAL_FLAG_DESTROY --enable-cache 

[b]error(compilation): clang failed with stderr: /home/boop/code/zig/hexaflex/wgpu/vendor/zgpu/libs/mach-glfw/src/sources_linux_wayland.c:2:10: fatal error: 'wl_monitor.c' file not found[/b]

[b]error(compilation): clang failed with stderr: /home/boop/code/zig/hexaflex/wgpu/vendor/zgpu/libs/mach-glfw/src/sources_all.c:2:10: fatal error: 'monitor.c' file not found[/b]

[b]error(compilation): clang failed with stderr: /home/boop/code/zig/hexaflex/wgpu/vendor/zgpu/libs/mach-glfw/src/sources_linux_x11.c:2:10: fatal error: 'x11_init.c' file not found[/b]

[b]error(compilation): clang failed with stderr: /home/boop/code/zig/hexaflex/wgpu/vendor/zgpu/libs/mach-glfw/src/sources_linux.c:2:10: fatal error: 'posix_time.c' file not found[/b]

/home/boop/code/zig/hexaflex/wgpu/vendor/zgpu/libs/mach-glfw/src/sources_linux_wayland.c:1:1: error: unable to build C object: clang exited with code 1
/home/boop/code/zig/hexaflex/wgpu/vendor/zgpu/libs/mach-glfw/src/sources_all.c:1:1: error: unable to build C object: clang exited with code 1
/home/boop/code/zig/hexaflex/wgpu/vendor/zgpu/libs/mach-glfw/src/sources_linux_x11.c:1:1: error: unable to build C object: clang exited with code 1
/home/boop/code/zig/hexaflex/wgpu/vendor/zgpu/libs/mach-glfw/src/sources_linux.c:1:1: error: unable to build C object: clang exited with code 1
error: glfw...
error: The following command exited with error code 1:
/home/boop/bin/zig/zig build-lib /home/boop/code/zig/hexaflex/wgpu/vendor/zgpu/libs/mach-glfw/src/main.zig -cflags -D_GLFW_X11 -D_GLFW_WAYLAND -I/home/boop/code/zig/hexaflex/wgpu/vendor/zgpu/libs/mach-glfw/upstream/glfw/src -- /home/boop/code/zig/hexaflex/wgpu/vendor/zgpu/libs/mach-glfw/src/sources_all.c /home/boop/code/zig/hexaflex/wgpu/vendor/zgpu/libs/mach-glfw/src/sources_linux.c /home/boop/code/zig/hexaflex/wgpu/vendor/zgpu/libs/mach-glfw/src/sources_linux_x11.c /home/boop/code/zig/hexaflex/wgpu/vendor/zgpu/libs/mach-glfw/src/sources_linux_wayland.c -lc -lX11 -lxcb -lXau -lXdmcp --cache-dir /home/boop/code/zig/hexaflex/wgpu/zig-cache --global-cache-dir /home/boop/.cache/zig --name glfw -static -target native-native-gnu -mcpu skylake -I /home/boop/code/zig/hexaflex/wgpu/vendor/zgpu/libs/mach-glfw/upstream/glfw/include -I /home/boop/code/zig/hexaflex/wgpu/vendor/zgpu/libs/mach-glfw/upstream/vulkan_headers/include -isystem /home/boop/.local/share/hexops/sdk-linux-x86_64/root/usr/include -isystem /home/boop/.local/share/hexops/sdk-linux-x86_64/root/usr/share/wayland-generated -L /home/boop/.local/share/hexops/sdk-linux-x86_64/root/usr/lib/x86_64-linux-gnu -D WL_MARSHAL_FLAG_DESTROY --enable-cache 
error: the following build command failed with exit code 1:
/home/boop/code/zig/hexaflex/wgpu/zig-cache/o/1afd7bb5a1309a11ae9f25bdff3939b6/build /home/boop/bin/zig/zig /home/boop/code/zig/hexaflex/wgpu /home/boop/code/zig/hexaflex/wgpu/zig-cache /home/boop/.cache/zig test --verbose

After the build I checked the vendor/zgpu/libs/mach-glfw directory and noticed the upstream directory is empty. The glfw C sources are not present. I am assuming that the upstream directory needs to be filled by the mach-glfw build script. This is not happening.

Error running audio_experiments_wgpu-run on M1 Mac

Apple M1 Max. macOS Version 12.5 (Build 21G72)
Zig stage1 version 0.10.0-dev.3361

➜  zig-gamedev git:(main) git log -1 | tee
commit 01ed4717fa531b28e58c1b871b849f8d0ec2daa6
Author: Michal Ziulek <[email protected]>
Date:   Wed Jul 27 23:14:24 2022 +0200

    zaudio: getChannels() -> getNumChannels().
➜  zig-gamedev git:(main) stage1 build audio_experiments_wgpu-run
/Users/jonas/src/zig/zig/build/stage1/lib/zig/std/fmt.zig:458:5: error: invalid format string 'd' for type '.zgpu.wgpu.CreatePipelineAsyncStatus'
    @compileError("invalid format string '" ++ fmt ++ "' for type '" ++ @typeName(@TypeOf(value)) ++ "'");
    ^
/Users/jonas/src/zig/zig/build/stage1/lib/zig/std/fmt.zig:524:55: note: called from here
                if (actual_fmt.len != 0) invalidFmtErr(fmt, value);
                                                      ^
/Users/jonas/src/zig/zig/build/stage1/lib/zig/std/fmt.zig:183:23: note: called from here
        try formatType(
                      ^
/Users/jonas/src/zig/zig/build/stage1/lib/zig/std/io/writer.zig:28:34: note: called from here
            return std.fmt.format(self, format, args);
                                 ^
/Users/jonas/src/zig/zig/build/stage1/lib/zig/std/debug.zig:93:27: note: called from here
    nosuspend stderr.print(fmt, args) catch return;
                          ^
./libs/zgpu/src/zgpu.zig:525:32: note: called from here
                std.debug.print(
                               ^
./libs/zgpu/src/zgpu.zig:517:29: note: called from here
        ) callconv(.C) void {

col-major matrices

Awesome work on the lib! I was wondering if you had any plans to support col-major matrices for those of use who aren't on Windows and are stuck without DirectX.

HLSL DynamicResources and SM 6.6 support

Hello there. I wanted to try the new DynamicResources feature introduced with Shader Model 6.6, and I had a quick go at enabling them in graphics.zig.

Here's the link to the specs: https://microsoft.github.io/DirectX-Specs/d3d/HLSL_SM_6_6_DynamicResources.html

And here's the link to the commit on my fork: gmodarelli@3d895bd

I see how "forcing" Shader Model 6.6 could restrict a bit the pool of supported devices. That's why I didn't go directly for a PR and wanted your input on this.

Have a nice day!

zgpu doesn't catch vulkan load error

When running a program using zgpu in a linux environment where vulkan is not available, a "null" adapter is acquired and the code path for handling the error is not reached.

I see 2 problems here:

  1. Dawn should fallback to an OpenGL backend (out of scope for zgpu)
  2. mach/gpu produces a Null adapter rather than an error and zgpu tries to treat this as valid

The end result is an empty window and the following stdout would not be visible to an end-user:

Error: Couldn't load Vulkan. Searched /home/chris/zig-gamedev/zig-out/bin/libvulkan.so.1, libvulkan.so.1.
    at operator() (/home/runner/work/mach-gpu-dawn/mach-gpu-dawn/libs/dawn/src/dawn/native/vulkan/BackendVk.cpp:201)
    at Initialize (/home/runner/work/mach-gpu-dawn/mach-gpu-dawn/libs/dawn/src/dawn/native/vulkan/BackendVk.cpp:206)
    at Create (/home/runner/work/mach-gpu-dawn/mach-gpu-dawn/libs/dawn/src/dawn/native/vulkan/BackendVk.cpp:168)
    at operator() (/home/runner/work/mach-gpu-dawn/mach-gpu-dawn/libs/dawn/src/dawn/native/vulkan/BackendVk.cpp:423)

[zgpu] High-performance device has been selected:
[zgpu]   Name: Null backend
[zgpu]   Driver: 
[zgpu]   Adapter type: CPU
[zgpu]   Backend type: Null

triangle_wpgu crashes when pressing alt+printscreen

It reaches this unreachable:

pub inline fn pollEvents() error{PlatformError}!void {
    internal_debug.assertInitialized();
    c.glfwPollEvents();
    getError() catch |err| return switch (err) {
        Error.NotInitialized => unreachable,
        Error.PlatformError => |e| e,
        else => unreachable,
    };
}

On WIndows 10.

git error: Filename too long on Windows when using zig-gamedev as a submodule

Please let me know if this is out-of-scope of zig-gamedev, but I just hit this error trying to test my project on Windows.

My project uses zig-gamedev as a submodule within src/deps, but when cloning the project recursively, I get an error:

C:\Users\foxnne\dev\proj\aftersun\src\deps\zig-gamedev\libs\zgpu\libs\mach-gpu-dawn\libs\dawn\test\tint\unittest\reader\spirv\PreserveFloatCoords_NonArrayed_SpvParserHandleTest_ImageCoordsTest_MakeCoordinateOperandsForImageAccess_0.spvasm.expected.glsl [204ms]
[2022-08-25T19:07:09.305Z] error: unable to create file test/tint/unittest/reader/spirv/PreserveFloatCoords_NonArrayed_SpvParserHandleTest_ImageCoordsTest_MakeCoordinateOperandsForImageAccess_0.spvasm.expected.glsl: Filename too long

It appears that there is a really long filename within mach-gpu-dawn that, when combined with being several submodules deep ends up hitting the max file length Windows supports.

Is there a workaround for this, or do you suggest a different way of including zig-gamedev in projects? The only other way I can think that wouldn't involve checking in potentially really large files into git, would be to use build.zig to download zig-gamedev into src/deps and use .gitignore to avoid checking it into git at all, but I assume I would still end up hitting a max file length issue there as well.

Any information would be great, thanks!

build of zgpu crashes on new version of zig

➜  zig build
./libs/zgpu/libs/mach-gpu-dawn/build.zig:1458:54: error: no member named 'iterate' in struct 'std.fs.Dir.OpenDirOptions'
    var dir = try std.fs.openDirAbsolute(abs_dir, .{ .iterate = true });
                                                     ^

works on zig-macos-aarch64-0.10.0-dev.2751+08459ff1c
crashes on zig-macos-aarch64-0.10.0-dev.3027+0e26c6149

The latest version of mach-gpu-dawn build uses

var dir = try std.fs.openIterableDirAbsolute(abs_dir, .{});

btw The readme.md tells us that
Project requires Zig 0.10.0-dev.2412 (master) or newer to compile.
but I'm wondering what should be the correct wording here. The language is quite unstable and it looks like we need the explicit latest working version number as well?

dxc.exe cannot start or run due to incompatibilities with 64-bit versions of windows

I followed the instructions saying that a zig build should be sufficient, but I get this,

image

zig env
{
 "zig_exe": "C:\\work\\zig\\zig.exe",
 "lib_dir": "C:\\work\\zig\\lib",
 "std_dir": "C:\\work\\zig\\lib\\std",
 "global_cache_dir": "C:\\Users\\Charles\\AppData\\Local\\zig",
 "version": "0.10.0-dev.895+df38c46be"
}
Processor	AMD Ryzen 5 4500U with Radeon Graphics            2.38 GHz
Installed RAM	8.00 GB (7.39 GB usable)
System type	64-bit operating system, x64-based processor
Pen and touch	Pen and touch support with 10 touch points
Edition	Windows 11 Pro
Version	21H2
Installed on	‎30/‎11/‎2021
OS build	22000.493
Experience	Windows Feature Experience Pack 1000.22000.493.0

Please let me know if I can provide better information, this project looks great!

Include all Imgui Bindings?

I currently have a build script working for zgpu with the Zig-ImGui library giving me access to all ImGui bindings. It adds the Zig-ImGui library as another submodule in zgpu. Would this be a direction for the project your interested in? I'm building a personal project with this, and eventually want to integrate the ImPlot library as well.

Failing audio tests on MacOS

The sound sample app still works on my M1 Max. But tests are failing.

[zgpu]   Name: Apple M1 Max
[zgpu]   Driver: Metal driver on macOS Version 12.4 (Build 21F79)
[zgpu]   Adapter type: Discrete GPU
[zgpu]   Backend type: Metal

➜  zig-gamedev git:(main) git log -1 | tee
commit 61f16e5faba9c63b369f5e62edf9c5f3653c23a0
Author: Michal Ziulek <[email protected]>
Date:   Thu Jun 30 12:59:04 2022 +0200

    zgpu: Fixed crashes on Linux.
➜  zig-gamedev git:(main) stage1 version
0.10.0-dev.2803+c248af3bd
➜  zig-gamedev git:(main) zig build test
All 9 tests passed.
All 4 tests passed.
All 73 tests passed.
All 1 tests passed.
All 3 tests passed.
All 30 tests passed.
Test [1/5] test "zaudio.engine.basic"... Channels: 2, SampleRate: 44100, NumListeners: 1, ClosestListener: 0
Test [2/5] test "zaudio.soundgroup.basic"... FAIL (TestUnexpectedResult)
/Users/jonas/src/zig/zig/build/stage1/lib/zig/std/testing.zig:347:14: 0x104df416b in std.testing.expect (test)
    if (!ok) return error.TestUnexpectedResult;
             ^
/Users/jonas/src/zig/zig-gamedev/libs/zaudio/src/zaudio.zig:1063:9: 0x104df4ad7 in test "zaudio.soundgroup.basic" (test)
        try expect(dir[0] == 1.0 and dir[1] == 2.0 and dir[2] == 3.0);
        ^
4 passed; 0 skipped; 1 failed.
error: the following test command failed with exit code 1:
/Users/jonas/src/zig/zig-gamedev/zig-cache/o/721444e8321989591ec942dfa7114cd5/test /Users/jonas/src/zig/zig/build/stage1/bin/zig
test...The following command exited with error code 1:
/Users/jonas/src/zig/zig/build/stage1/bin/zig test /Users/jonas/src/zig/zig-gamedev/libs/zaudio/src/zaudio.zig /Users/jonas/src/zig/zig-gamedev/zig-cache/o/6b32838f26a53d4df3966191e9625182/libzaudio.a -lc --cache-dir /Users/jonas/src/zig/zig-gamedev/zig-cache --global-cache-dir /Users/jonas/.cache/zig --name test -I /Users/jonas/src/zig/zig-gamedev/libs/zaudio/libs/miniaudio -framework CoreFoundation -framework AudioUnit -framework AudioToolbox -framework CoreAudio --enable-cache
error: the following build command failed with exit code 1:
/Users/jonas/src/zig/zig-gamedev/zig-cache/o/ea2a3a45b78e3fd5b9422ebd450e3c91/build /Users/jonas/src/zig/zig/build/stage1/bin/zig /Users/jonas/src/zig/zig-gamedev /Users/jonas/src/zig/zig-gamedev/zig-cache /Users/jonas/.cache/zig test

Can't build `physically_based_rendering_wgpu` on macOS aarch64 with latest zig

I'm not sure what to make of this. Perhaps there are breaking changes between zig 0.10.0-dev.2412 and 0.10.0-dev.2432?

I'm running this on an M1 MacBook Pro:

$ which zig
/opt/homebrew/bin/zig

$ zig version
0.10.0-dev.2432+22cb69388

$ zig build physically_based_rendering_wgpu-run -Dzgpu-dawn-from-source=true
physically_based_rendering_wgpu...The following command terminated unexpectedly:
/opt/homebrew/Cellar/zig/HEAD-22cb693/bin/zig build-exe /Users/garett/Dropbox/Garett/GitHub/zig-gamedev/samples/physically_based_rendering_wgpu/src/physically_based_rendering_wgpu.zig /Users/garett/Dropbox/Garett/GitHub/zig-gamedev/zig-cache/o/a0c8aa40f2e181dae0eeb5eb755e6c16/libglfw.a -lc -lobjc /Users/garett/Dropbox/Garett/GitHub/zig-gamedev/zig-cache/o/21728128ca4896a8d9f2b9fe46c6bd76/libdawn.a /Users/garett/Dropbox/Garett/GitHub/zig-gamedev/zig-cache/o/2b87efb10438e9ae9b25a6dc94173d96/libzgpu.a /Users/garett/Dropbox/Garett/GitHub/zig-gamedev/zig-cache/o/f9eea545a46bb68b7cf9b59731e0da3f/libzmesh.a -lc -lobjc -lc++ -lc -lobjc -lobjc -lc -lobjc -lc -lobjc -lc -lobjc -lc -lobjc -lc++ -lc -lobjc -lobjc -lc -lobjc -lc -lobjc -lc -lc++ --cache-dir /Users/garett/Dropbox/Garett/GitHub/zig-gamedev/zig-cache --global-cache-dir /Users/garett/.cache/zig --name physically_based_rendering_wgpu --pkg-begin build_options /Users/garett/Dropbox/Garett/GitHub/zig-gamedev/zig-cache/options/KimUQtjc7RFpo30ttlCeCnEVoKTO4Fp3KObMkkFf-lXXItBkl11o3Of7QhylyeSP --pkg-end --pkg-begin zmesh /Users/garett/Dropbox/Garett/GitHub/zig-gamedev/libs/zmesh/src/main.zig --pkg-begin zmesh_options /Users/garett/Dropbox/Garett/GitHub/zig-gamedev/zig-cache/options/WxkzBf3w9kJGY9q5y7SiPj0jvFY2DjkNCi-Ovg_84iimoERP7gmh4g7gb2By0gxe --pkg-end --pkg-end --pkg-begin glfw /Users/garett/Dropbox/Garett/GitHub/zig-gamedev/libs/mach-glfw/src/main.zig --pkg-end --pkg-begin zgpu /Users/garett/Dropbox/Garett/GitHub/zig-gamedev/libs/zgpu/src/zgpu.zig --pkg-begin zgpu_options /Users/garett/Dropbox/Garett/GitHub/zig-gamedev/zig-cache/options/YlIhfB2NyOIjaFu_elfbPcNHrz1bry-eT_AAiCBXWsahD6UwUcWXZUFIetT057fK --pkg-end --pkg-begin glfw /Users/garett/Dropbox/Garett/GitHub/zig-gamedev/libs/mach-glfw/src/main.zig --pkg-end --pkg-end --pkg-begin zmath /Users/garett/Dropbox/Garett/GitHub/zig-gamedev/libs/zmath/src/zmath.zig --pkg-end --pkg-begin zgpu_options /Users/garett/Dropbox/Garett/GitHub/zig-gamedev/zig-cache/options/YlIhfB2NyOIjaFu_elfbPcNHrz1bry-eT_AAiCBXWsahD6UwUcWXZUFIetT057fK --pkg-end --pkg-begin zmesh_options /Users/garett/Dropbox/Garett/GitHub/zig-gamedev/zig-cache/options/WxkzBf3w9kJGY9q5y7SiPj0jvFY2DjkNCi-Ovg_84iimoERP7gmh4g7gb2By0gxe --pkg-end -isystem /Users/garett/Library/Application Support/hexops/sdk-macos-12.0/root/usr/include -I /Users/garett/Dropbox/Garett/GitHub/zig-gamedev/libs/mach-glfw/upstream/glfw/include -I /Users/garett/Dropbox/Garett/GitHub/zig-gamedev/libs/mach-glfw/upstream/vulkan_headers/include -isystem /Users/garett/Library/Application Support/hexops/sdk-macos-12.0/root/usr/include -I /Users/garett/Dropbox/Garett/GitHub/zig-gamedev/libs/mach-gpu-dawn/libs/dawn/out/Debug/gen/include -I /Users/garett/Dropbox/Garett/GitHub/zig-gamedev/libs/mach-gpu-dawn/libs/dawn/include -I /Users/garett/Dropbox/Garett/GitHub/zig-gamedev/libs/mach-gpu-dawn/src/dawn -I /Users/garett/Dropbox/Garett/GitHub/zig-gamedev/libs/zgpu/libs -I /Users/garett/Dropbox/Garett/GitHub/zig-gamedev/libs/zmesh/libs/cgltf -L /Users/garett/Library/Application Support/hexops/sdk-macos-12.0/root/usr/lib -L /Users/garett/Library/Application Support/hexops/sdk-macos-12.0/root/usr/lib -iframework /Users/garett/Library/Application Support/hexops/sdk-macos-12.0/root/System/Library/Frameworks -F /Users/garett/Library/Application Support/hexops/sdk-macos-12.0/root/System/Library/Frameworks -iframework /Users/garett/Library/Application Support/hexops/sdk-macos-12.0/root/System/Library/Frameworks -F /Users/garett/Library/Application Support/hexops/sdk-macos-12.0/root/System/Library/Frameworks -framework CoreFoundation -framework Foundation -framework CoreGraphics -framework QuartzCore -framework Metal -framework IOSurface -framework IOKit -framework CoreServices -framework AppKit --enable-cache 
error: the following build command failed with exit code 11:
/Users/garett/Dropbox/Garett/GitHub/zig-gamedev/zig-cache/o/e8d626cab16e47049ee12462c311d972/build /opt/homebrew/Cellar/zig/HEAD-22cb693/bin/zig /Users/garett/Dropbox/Garett/GitHub/zig-gamedev /Users/garett/Dropbox/Garett/GitHub/zig-gamedev/zig-cache /Users/garett/.cache/zig physically_based_rendering_wgpu-run -Dzgpu-dawn-from-source=true

Incorrect keyboard navigation in demo apps on MacOS

Keyboard navigation using 'a' and 'd' move in the wrong direction for app 'bullet_physics_test_wgpu'. Both Intel and ARM Mac.

Keyboard navigation using 'a', 'd', 's' and 'w' move in the wrong direction for app 'audio_experiments_wgpu'. Both Intel and ARM Mac.

Keyboard navigation using 'a', 'd', 's' and 'w' move in the wrong direction for app 'physically_based_rendering_wgpu'. Both Intel and ARM Mac.

➜  zig-gamedev git:(main) zig version
0.10.0-dev.3840+2b92c5a23
➜  zig-gamedev git:(main) git log -1 | tee
commit 44c93d79b33d2efb280863bed6123fb6774bc4bd
Author: Michal Ziulek <[email protected]>
Date:   Thu Sep 1 07:54:19 2022 +0200

    znetowrk: @byteSwap() breaking change. We now require latest Zig compiler (0.10.0-dev.3838).

➜  zig-gamedev git:(main) sw_vers;clang --version
ProductName:	macOS
ProductVersion:	12.5.1
BuildVersion:	21G83
Homebrew clang version 14.0.6
Target: arm64-apple-darwin21.6.0
Thread model: posix
InstalledDir: /opt/homebrew/opt/llvm/bin
➜  zig-gamedev git:(main) sw_vers;clang --version
ProductName:	macOS
ProductVersion:	12.5.1
BuildVersion:	21G83
Apple clang version 13.1.6 (clang-1316.0.21.2.5)
Target: x86_64-apple-darwin21.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

Running any sample fails with "panic: HRESULT error detected (0x80070057, error.E_INVALIDARG)"

Hi! Looks like a cool project, thanks for sharing it, and good luck on your full-time zig gamedev adventure!

I cloned the repo, initialized LFS, got the latest zig nightly and ran build_all_samples.bat to completion with no errors. When I try to run any sample though, I get the following error:

D:\Projects\zig-gamedev\samples\simple_raytracer\zig-out\bin>simple_raytracer.exe
info: [graphics] Graphics pipeline hash: 3860400860
thread 16028 panic: HRESULT error detected (0x80070057, error.E_INVALIDARG).
D:\zig\lib\std\debug.zig:256:22: 0x7ff7f23f6a1e in std.debug.panicExtra (simple_raytracer.obj)
    std.builtin.panic(msg, trace);
                     ^
D:\zig\lib\std\debug.zig:232:15: 0x7ff7f23b1ecc in std.debug.panic (simple_raytracer.obj)
    panicExtra(null, format, args);
              ^
D:\Projects\zig-gamedev\libs\common\library.zig:29:10: 0x7ff7f238b8ca in .common.library.hrPanic (simple_raytracer.obj)
    panic(
         ^
D:\Projects\zig-gamedev\libs\common\graphics.zig:937:26: 0x7ff7f239b288 in .common.graphics.GraphicsContext::.common.graphics.GraphicsContext.createGraphicsShaderPipeline (simple_raytracer.obj)
            hrPanicOnFail(gr.device.CreateGraphicsPipelineState(
                         ^
D:\Projects\zig-gamedev\samples\simple_raytracer\src\simple_raytracer.zig:533:53: 0x7ff7f238d643 in init (simple_raytracer.obj)
        break :blk grfx.createGraphicsShaderPipeline(
                                                    ^
D:\Projects\zig-gamedev\samples\simple_raytracer\src\simple_raytracer.zig:1464:20: 0x7ff7f238bcfd in main (simple_raytracer.obj)
    var demo = init(gpa);
                   ^
D:\zig\lib\std\start.zig:527:37: 0x7ff7f23bb134 in std.start.callMain (simple_raytracer.obj)
            const result = root.main() catch |err| {
                                    ^
D:\zig\lib\std\start.zig:419:36: 0x7ff7f23945b9 in std.start.callMainWithArgs (simple_raytracer.obj)
    return initEventLoopAndCallMain();
                                   ^
D:\zig\lib\std\start.zig:434:12: 0x7ff7f23944eb in std.start.main (simple_raytracer.obj)
    return @call(.{ .modifier = .always_inline }, callMainWithArgs, .{ @intCast(usize, c_argc), c_argv, envp });
           ^
Unable to dump stack trace: InvalidDebugInfo

I'm running on Windows 10 x64 (build 19043.1288) laptop with an NVIDIA GeForce RTX 2060 GPU (and an Intel UHD Graphics 630 chipset).

Large binaries in git tree

Various dlls, exes and pdbs are checked into the repo. Could these be moved to LFS so that they may only be fetched if/when required?

See libs/zwin32/bin/

Bug | zmath: segfault on returning an anonymous struct directly

OS: MacOS
System: Intel i7 (Macbook Pro 2019)
Zig Version: 0.9.1

EXC_BAD_ACCESS (code=EXC_I386_GPFLT)

I am not sure if this is a library issue:

// causes a segfault on accesing sc[1] (address is supposedly 0x0?)
pub fn rotationZ(angle: f32) Mat {
    const sc = sincos(angle);
    return .{
        f32x4(sc[1], sc[0], 0.0, 0.0),
        f32x4(-sc[0], sc[1], 0.0, 0.0),
        f32x4(0.0, 0.0, 1.0, 0.0),
        f32x4(0.0, 0.0, 0.0, 1.0),
    };
}
// this 'fixed' version works fine
pub fn rotationZ(angle: f32) Mat {
    const sc = sincos(angle);
    const result = .{
        f32x4(sc[1], sc[0], 0.0, 0.0),
        f32x4(-sc[0], sc[1], 0.0, 0.0),
        f32x4(0.0, 0.0, 1.0, 0.0),
        f32x4(0.0, 0.0, 0.0, 1.0),
    };

    return result;
}

Shader Interop

Hello there, I don't think this is really an "issue", but I wanted to know if there are plans to introduce some form of shader interoperability between Zig and HLSL.

I haven't had a need for it until yesterday and my first idea was to declare structs and DEFINEs in a C header file and import it in Zig and include it into my HLSL shaders.

Any thoughts on it?
Thank you :)

Samples do not compile

I have tried using zig 0.9.0 from master but that gave me an error. So I tried zig 0.8.1 and it gave me another error, this one:

.\build.zig:11:55: error: no member named 'custom' in union 'std.build.InstallDir'
        .{ .source_dir = "content", .install_dir = .{ .custom = "" }, .install_subdir = "bin/content" },
                                                      ^

you may want to re-think using Git LFS (or GitHub)

👋 super cool stuff, just wanted to say that you might want to re-think using Git LFS on GitHub in specific.

The free tier only grants you 1GB of data transfer, even for open source repos. After that, Git LFS will be blocked unless you want to pay for bandwidth. https://docs.github.com/en/repositories/working-with-files/managing-large-files/about-storage-and-bandwidth-usage

I ran into this with a game engine I was writing in Go ~1 year ago. azul3d/engine#156

Alternatives: GitLab offers free Git LFS, you can also just keep assets in a separate Git repo and blow the repo away if needed.

Undefined symbol _sincosf on an M1 Mac mini with Big Sur installed

Hello Michal,

Just opening a separate issue from #50, as suggested.

I am getting the error below when trying to run the tests on my M1 Mac mini (Big Sur) with zig master branch built today (0.10.0-dev.1860+7b090df66):

 wilsonk  ~  zig-gamedev   main  zig build test -Drelease-fast -Ddawn-from-source=true
All 9 tests passed.
All 4 tests passed.
LLVM Emit Object... error(link): undefined reference to symbol '_sincosf'
error(link):   first referenced in '/Users/wilsonk/zig-gamedev/zig-cache/o/bede7d83f1692d97996a78a4dce04395/test.o'
thread 2335881 panic: attempt to unwrap error: UndefinedSymbolReference
/Users/wilsonk/Downloads/zig/src/link/tapi/yaml.zig:59:28: 0x10337fa83 in link.tapi.yaml.Value.asList (zig1)
        if (self != .list) return error.TypeMismatch;
.
.
.

I get the error with or without -Dtarget=aarch64-macos-gnu and in Debug or Release. This seems to be a problem with zig/macos, as per this thread: ziglang/zig#10318

can't build on linux

Maybe this is not a requirement but it looks like I run into an error when trying to run "dxc.exe" when building on linux. If building on linux is not a requirement then feel free to close. If it is, then I'd be willing to help out getting this to work. Could you provide documentation on how dxc is built and where it comes from (put somewhere in the repo itself)?

wgpu examples fail on Linux/MacOS

Building the examples on Linux and MacOS today with an updated zig (as of April 17, 2022) works, but the examples won't actually load/run because of these errors:

Linux:

Warning: loader_scanned_icd_add: Driver /usr/lib/amdvlk64.so says it supports interface version 6 but still exports core entrypoints (Policy #LDP_DRIVER_6)
Warning: terminator_CreateInstance: Failed to CreateInstance in ICD 0.  Skipping ICD.
[zgpu] High-performance device has been selected:
[zgpu]   Name: AMD RADV TONGA
[zgpu]   Driver: radv: Mesa 22.0.1
[zgpu]   Adapter type: Discrete GPU
[zgpu]   Backend type: Vulkan
triangle_wgpu: /home/wilsonk/zig-gamedev/libs/zgpu/libs/imgui/imgui_draw.cpp:2384: bool ImFontAtlasBuildWithStbTruetype(ImFontAtlas *): Assertion `font_offset >= 0 && "FontData is incorrect, or FontNo cannot be found."' failed.
Aborted (core dumped)

MacOS:

[zgpu] High-performance device has been selected:
[zgpu]   Name: Apple M1
[zgpu]   Driver: Metal driver on macOS Version 11.6.5 (Build 20G527)
[zgpu]   Adapter type: Discrete GPU
[zgpu]   Backend type: Metal
Assertion failed: (font_offset >= 0 && "FontData is incorrect, or FontNo cannot be found."), function ImFontAtlasBuildWithStbTruetype, file /Users/wilsonk/zig-gamedev/libs/zgpu/libs/imgui/imgui_draw.cpp, line 2384.
Abort trap: 6

The Roboto-medium font is in each directory and I can see that relative addressing is being used to find the font file...not sure why this doesn't work. I tried a different font, just in case the Roboto file was corrupted, but ended up with the same error. Any ideas?

Tracy calling InitThread() trigger error

Importing ztracy and calling InitThread causes following error:

$ zig build -Dztracy-enable=true run-game-of-life
.\deps\zig-gamedev\libs\ztracy\src\ztracy.zig:321:10: error: container '.ztracy.cimport:242:15' has no member called '___tracy_init_thread'
        c.___tracy_init_thread();
         ^

Seem like the library works otherwise so maybe this function has been renamed?

executables can't be launched from explorer

Looks like the resulting executables can't be launched from Windows explorer. My guess is because they can't find the corresponding assets which live relative to the sample directory.

I suggest that the samples instead use the executable directory to find the assets. You can use std.fs.selfExePath for this.

cbullet compile failed on linux

Hi @michal-z, I'm trying to compile cbullet on linux/x64, got following error:

cbullet.cpp:628:1: error: static_assert failed due to requirement '(sizeof(btTriangleIndexVertexArray) % 16) == 0' "sizeof(btTriangleIndexVertexArray) is not multiple of 16"
cbullet.cpp:814:1: error: static_assert failed due to requirement '(sizeof(btRigidBody) % 16) == 0' "sizeof(btRigidBody) is not multiple of 16"
cbullet.cpp:816:1: error: static_assert failed due to requirement '((sizeof(btRigidBody) + sizeof(btDefaultMotionState)) % 16) == 0' "sizeof(btRigidBody) + sizeof(btDefaultMotionState) is not multiple of 16"

My zig version is latest release 0.9.0.

mac webgpu build error

New to zig so probably a problem on my end.
with zig 0.9.1
on mac 12.3

cd zig-gamedev
zig build triangle_wgpu-run

results in the following

~/code/zig-gamedev (main) » zig build triangle_wgpu-run                                                                                                      dev@chroma
./libs/mach-gpu-dawn/build.zig:238:9: error: no member named 'addLibraryPath' in struct 'std.build.LibExeObjStep'
    step.addLibraryPath(target_cache_dir);
        ^
./libs/mach-gpu-dawn/build.zig:398:66: error: no member named 'mode' in struct 'std.fs.file.OpenFlags'
    var file = try std.fs.openFileAbsolute(src_absolute_path, .{ .mode = .read_only });

Complete zmath v0.3

  • adjustSaturation()
  • adjustContrast()
  • rgbToHsl()
  • hslToRgb()
  • hsvToRgb()
  • rgbToHsv()
  • fft()
  • ifft()
  • rgbToSrgb()
  • srgbToRgb()
  • improve docs (README and code comments)

triangle_wgpu-run sample stopped working on Mac

Hi, great work on your library!

Looks like there is a regression on Mac after adding imgui. I am using zig 0.10.0-dev.1768+9c509f152. Here is the last commit that displays triangles for me

➜  zig-gamedev git:(7d51e80) zig build triangle_wgpu-run
[zgpu] High-performance device has been selected:
[zgpu]   Name: Apple M1 Max
[zgpu]   Driver: Metal driver on macOS Version 12.3.1 (Build 21E258)
[zgpu]   Adapter type: Discrete GPU
[zgpu]   Backend type: Metal

The next commit crashes. I don't have a Windows machine available right now and haven't been able to debug it yet. Any idea what is missing?

➜  zig-gamedev git:(main) git checkout cdd868222a3fa496daa7b11d526889a62a5ef7c8
HEAD is now at cdd8682 triangle_wgpu: Draw imgui demo window.

➜  zig-gamedev git:(main) zig build triangle_wgpu-run
[zgpu] High-performance device has been selected:
[zgpu]   Name: Apple M1 Max
[zgpu]   Driver: Metal driver on macOS Version 12.3.1 (Build 21E258)
[zgpu]   Adapter type: Discrete GPU
[zgpu]   Backend type: Metal
Assertion failed: (font_offset >= 0 && "FontData is incorrect, or FontNo cannot be found."), function ImFontAtlasBuildWithStbTruetype, file imgui_draw.cpp, line 2384.
The following command terminated unexpectedly:
cd /Users/jonas/src/zig/zig-gamedev && /Users/jonas/src/zig/zig-gamedev/zig-out/bin/triangle_wgpu
error: the following build command failed with exit code 1

bullet_physics_test: build error because Git symlinks on Windows are flaky

Low priority, zig version 0.10.0-dev.625+e42b5e76b, Windows 10

I get a build error in bullet_physics_test (all other samples build & run fine):

> zig build
D:\tmp\zig-tests\zig-gamedev\samples\bullet_physics_test\build.zig:4:25: error: unable to load 'D:\tmp\zig-tests\zig-gamedev\samples\bullet_physics_test\libs\zbullet\build.zig': FileNotFound
const zbullet = @import("libs/zbullet/build.zig");

That's broken for me since 1c5c343 Added zbullet (wip).

I found out that it's a git + windows + directory symlink problem, because everything works fine if I delete the Git placeholder file zig-gamedev\samples\bullet_physics_test\lib\zbullet for the symlink and replace it with a Windows symlink using mklink.

This is unfortunate for an example because out of the box it will probably not work for a lot of Windows users, because you have to setup git and windows in a fairly specific way (see https://stackoverflow.com/questions/5917249/git-symlinks-in-windows).

It would be preferable to handle this in the zig.build file if possible. I tried and failed to do that by changing
zig-gamedev\samples\bullet_physics_test\build.zig in line 148-149:

    // old version that only works with symlinks
    // exe.addPackagePath("zbullet", "libs/zbullet/src/zbullet.zig");
    // @import("libs/zbullet/build.zig").link(b, exe);

    // use relative paths to avoid git symlink problems on windows
    exe.addPackagePath("zbullet", "../../../libs/zbullet/src/zbullet.zig");
    @import("../../../libs/zbullet/build.zig").link(b, exe);
    
    // results in this error:
    // .\build.zig:151:5: error: import of file outside package path: '../../libs/zbullet/build.zig'
    // @import("../../libs/zbullet/build.zig").link(b, exe);
    // ^

Is there maybe another solution, maybe using a git submodule for zbullet or something like that?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.