We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I'm struggling to make a working switch statement for Color type, I've tried this:
game_state.color = switch (game_state.color.toInt()) { rl.Color.lime.toInt() => rl.Color.purple, rl.Color.purple.toInt() => rl.Color.magenta, rl.Color.magenta.toInt() => rl.Color.black, rl.Color.black.toInt() => rl.Color.lime, else => unreachable, };
It fails because .toInt() tries to call external C function, and can't do so at compile time. I also tried like this:
.toInt()
game_state.color = switch (game_state.color) { rl.Color.lime => rl.Color.purple, rl.Color.purple => rl.Color.magenta, rl.Color.magenta => rl.Color.black, rl.Color.black => rl.Color.lime, else => unreachable, };
But zig can't switch on extern types, here's error for that one:
src/game.zig:99:46: error: switch on type 'raylib.Color' game_state.color = switch (game_state.color) { ~~~~~~~~~~^~~~~~ /home/bleb1k/.cache/zig/p/122058d3ea6318efb819d0bffba630afd1a459fa3a99b4bfe4b680a937d5de04d2fc/lib/raylib.zig:719:26: note: struct declared here pub const Color = extern struct { ~~~~~~~^~~~~~
The text was updated successfully, but these errors were encountered:
fixed by changing fn toInt to
pub fn toInt(self: Color) i32 { return if (@inComptime()) (@as(i32, self.r) << 24) | (@as(i32, self.g) << 16) | (@as(i32, self.b) << 8) | @as(i32, self.a) else rl.colorToInt(self); }
This change makes this compile:
If this change is acceptable, may I fork this repo and make a PR?
Sorry, something went wrong.
No branches or pull requests
I'm struggling to make a working switch statement for Color type, I've tried this:
It fails because
.toInt()
tries to call external C function, and can't do so at compile time.I also tried like this:
But zig can't switch on extern types, here's error for that one:
The text was updated successfully, but these errors were encountered: