#Running GLFW + CGLM is causing my code to crash
1 messages · Page 1 of 1 (latest)
If you really do want to allocate them, make sure you use the right type. You're using [4]f32 rather than c.vec4, and the cglm vec4 type has additional alignment constraints on it
However, I'm not sure that those alignment constraints will be translated correctly by cInclude, since Zig handles alignment annotations differently than C, so you may need to use allocator.allocWithOptions, which gets a bit messy
In summary, the best option is to try var vec: c.vec4 = .{ 1.0, 0.0, 0.0, 1.0 }; etc, instead of your current allocated stuff, or if that doesn't work, var vec: align(16) [4]f32 = .{ 1.0, 0.0, 0.0, 1.0 };
Thanks
Although I am still confused as to how using glfw makes the error actually occur
It doesn't, the issue is always there, just when you call glfw functions the memory gets shuffled around so the alignment changes