storing the return value of the nvgRGBA in a zig variable or constant leads to it being garbage. Even when correct value is passed see 3rd case the values at runtime from zig side seem fine but not rendering which could mean it passing garbage to c functions.
nanovg.c:
{
NVGcolor color;
// Use longer initialization to suppress warning.
color.r = r / 255.0f;
color.g = g / 255.0f;
color.b = b / 255.0f;
color.a = a / 255.0f;
return color;
}```
and nvgColor struct is:
```// nanovg.h
struct NVGcolor {
union {
float rgba[4];
struct {
float r,g,b,a;
};
};
};
typedef struct NVGcolor NVGcolor;
// c.zig
pub const struct_NVGcolor = extern struct {
unnamed_0: union_unnamed_1 = @import("std").mem.zeroes(union_unnamed_1),
pub const nvgLerpRGBA = __root.nvgLerpRGBA;
pub const nvgTransRGBA = __root.nvgTransRGBA;
pub const nvgTransRGBAf = __root.nvgTransRGBAf;
};
pub const NVGcolor = struct_NVGcolor;
this works:
c.nvgBeginPath(vg);
c.nvgRect(vg, 0, kb_y, screen_w, kb_h);
c.nvgFillColor(vg, c.nvgRGBA(0, 255, 0, 180));
c.nvgFill(vg);
this dosent:(when i check the value its garbage on desktop and mobile)
//...
c.nvgFillColor(vg, col);
c.nvgFill(vg);
this also doesn't work:
const col: c.NVGcolor = .{
.unnamed_0 = .{ .unnamed_0 = .{
.r = @as(f32, @floatFromInt(r_)) / 255.0,
.g = @as(f32, @floatFromInt(g_)) / 255.0,
.b = @as(f32, @floatFromInt(b_)) / 255.0,
.a = @as(f32, @floatFromInt(a_)) / 255.0,
} },
};
return col;
}
//and calling it here:
//...
c.nvgFillColor(vg, rgba(0, 255, 0, 180));
Please if this is a zig issue anyone please help me fix it