Closed dmbfm closed 1 year ago
Thiis seems to be the same type of issue: https://github.com/ziglang/zig/issues/10560, and the cause is that the C abi compatibility is not complete yet: https://github.com/ziglang/zig/issues/1481.
The ARM: struct & union parameters
is still not implemented, so this should be the issue here.
I could verify that indeed this was the issue by creating a wrapper function in c:
#include "../raylib-zig/raylib/src/raylib.h"
void _DrawTextureExWrapper(Texture2D tex, float x, float y, float rotation, float scale, Color color) {
Vector2 pos = { .x = x, .y = y };
DrawTextureEx(tex, pos, rotation, scale, color);
}
When I called this function from zig, rendering of the texture worked as expected.
Late to the party, but wanted to throw this out there:
https://github.com/pfgithub/mousegame
This project is old, but seems to have an interesting approach to working around this in the aptly named 'workaround' c, h, and zig files. Not sure how well it works in practice, but wanted to put it here for others to find and spur on more creative solutions, if nothing else.
The way mousegame works around the issue indeed seems to be the only way at the moment. For raylib 3.0 there is the workaround
branch, but since struct parameters are supported on x86_64 it's no longer maintained. Fixing these C ABI issues is way out of scope for raylib-zig, but feel free to update the branch with a PR
With https://github.com/ziglang/zig/issues/1481 being closed, could you check this again?
Passing structs smaller than 16 bytes is still broken when enabling any of the release optimizations in the latest 0.11.0-dev compiler. This breaks raymath completely, as it relies heavily on Vector2
and Vector3
. Only solution is to stick to debug builds, for now.
The way mousegame works around the issue indeed seems to be the only way at the moment.
Another workaround is adding unused fields to the C structs. E.g. giving Vector3
a w
component and assigning a default 0 in the zig bindings.
https://github.com/ziglang/zig/issues/13830 and by extension https://github.com/ziglang/zig/issues/14262 are closed. Could you check this again?
Didn't retest the changes. But as long as these bindings officially only target zig 0.10.X, we should keep the issue open. The fix for sub-16 byte structs only exists in the 0.11.X branch.
Good note. Once 0.11 is released I'll update the binding accordingly and all this will hopefully work
I was trying to draw scaled textures and I was not able to. While
DrawTexture
works, any of the other texture drawing methods that allow for scaling seem to be broken.If I try this zig code:
I only get a while screen, while the same code in C gives me the correct result:
I have tried with both system and compiled raylib and get the same results. I am using macOS: