Since I just bookmarked it and it seems to fit: here’s an article about how to build a SpriteBatcher with SDL_GPU.
In the breakout example, with zig 0.13.0, I get
debug: SDL build time version: 3.2.0
debug: SDL build time revision: SDL-3.2.0 (…)
debug: SDL runtime version: 3.2.0
debug: SDL runtime revision: SDL-3.2.0 (…)
Illegal instruction at address 0xb7cc99
C:[…]\src\video\windows\SDL_windowsmouse.c:648:0: 0xb79ade in WIN_InitMouse (SDL3.lib)
WIN_UpdateMouseSystemScale();
[…]
The game works correctly with zig build run --release=fast
.
I am on windows 10, with an AMD Ryzen 5 CPU. I’ve uploaded the contents of zig-out/bin here: Unique Download Link | WeTransfer
I’m not sure of how else to help.
Sometimes this can happen if the underlying native C code does unaligned pointer casts. These checks are disabled when building a release build. There’s no easy to read error message when this happens, at least not on Windows.
I don’t know if this is the same problem you’re having, but it looks like it. I had this happen to me recently when I built “microui” into my game project, and that code uses unaligned pointers (in a sort of correct way, even, but not in a way that co-operates with UBSan). Lldb didn’t work for me on Windows, so it was a little tricky to figure out why the code is crashing.
In my project, I was able to fix the problem by disabling this feature for the source files that were doing funky pointer casts:
step.addCSourceFile(.{ .file = b.path("src/microui-2.02/src/microui.c"), .flags = &[_][]const u8{"-fno-sanitize=all"} });
step.addCSourceFile(.{ .file = b.path("src/microui_renderer.c"), .flags = &[_][]const u8{"-fno-sanitize=all"} });
Here’s a github issue about UBSAN error message (or lack thereof): Give more info when a UB trap is detected in zig cc debug mode · Issue #5163 · ziglang/zig · GitHub
Like @nurpax already mentioned, this is because of Clang’s UBSan which is enabled in Debug
and ReleaseSafe
optimization modes. In this specific case the trap happens when your configured Windows cursor speed is less than 6, which will cause a left bitwise shift of a negative value which is undefined behavior in C.
Someone else already reported the very same issue and I submitted a patch to the upstream SDL repo which was merged and will be included in SDL 3.2.2. So a good thing about this is that Zig’s defaults are helping catch UB and potential bugs in well-established C projects.
it is :3
why? it caught a potential problem, why would you avoid a tool that catches problems?
no idea what the rest of your msg is supposed to mean
btw the more helpful ubsan messages was merged Devlog ⚡ Zig Programming Language
I don’t think there is any advantage to converting SDL_shadercross from CMake to Zig Build as it’s a build tool that just needs to the installed every now and then as-and-when it changes.
Here’s a python script I wrote to fetch and build it on macOS, Linux and Windows. You need to be mindful of the pre-reqs and that also on Windows you need to run it from within a Developer Command Prompt for Visual Studio in order to find the compiler.
Updated the package for Zig 0.14.0 and SDL 3.2.8 and dropped support for older Zig versions.
SDL_shadercross is not only a build-time tool but can also be used to translate shaders at runtime, so there is still some value in being able to easily build and include it with your application. I would suggest reading the intro blog post which explains the motivation for the different use cases for SDL_shadercross.
Thank you for migrating it, too many publications are left unmaintained.
Personally, I work with the night version.
Maybe the day stable version 1 is released then … But let them take their time so as not to fall into the trap of absolutely wanting to release version 1 and in the process the n … patches…
Used this lib to make odin able to cross compile with sdl3 static dep
an odin compiler on PATH is a required dependency but I think that is reasonable.
I didnt bother with web setup, but might add it in the future.
Beginner SDL-question: Is there anyway of importing textures other than bmp, without SDL_image, solely with your port?
EDIT: nevermind, i read up on this and found an answer. Looks like i have to install SDL3_image separately. Would be super sweet to get a port of that and SDL3_ttf in the future!