1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
use types::c;
export const MOUSE_BUTTON_LEFT = 0;
export const MOUSE_BUTTON_RIGHT = 1;
export const FLAG_WINDOW_RESIZABLE: uint = 4;
export const KEY_N = 78;
export type color = struct {
r: u8,
g: u8,
b: u8,
a: u8
};
export type vector2 = struct {
x: f32,
y: f32
};
export @symbol("WindowShouldClose") fn window_should_close() bool;
export @symbol("BeginDrawing") fn begin_drawing() void;
export @symbol("EndDrawing") fn end_drawing() void;
export @symbol("ClearBackground") fn clear_background(color) void;
export @symbol("DrawRectangleV") fn draw_rectangle_v(vector2, vector2, color) void;
export @symbol("IsMouseButtonPressed") fn is_mouse_button_pressed(int) bool;
export @symbol("GetMousePosition") fn get_mouse_position() vector2;
export @symbol("GetScreenHeight") fn get_screen_height() int;
export @symbol("GetScreenWidth") fn get_screen_width() int;
export @symbol("SetConfigFlags") fn set_config_flags(uint) void;
export @symbol("IsKeyPressed") fn is_key_pressed(int) bool;
@symbol("InitWindow") fn InitWindow(int, int, *c::char) void;
export fn init_window(width: int, height: int, title: str) void = {
let c_title = c::fromstr(title)!;
defer free(c_title);
InitWindow(width, height, c_title);
};
@symbol("DrawText") fn DrawText(*c::char, int, int, int, color) void;
export fn draw_text(text: str, x: int, y: int, sz: int, c: color) void = {
let c_str = c::fromstr(text)!;
defer free(c_str);
DrawText(c_str, x, y, sz, c);
};
@symbol("MeasureText") fn MeasureText(*c::char, int) int;
export fn measure_text(text: str, sz: int) int = {
let c_str = c::fromstr(text)!;
defer free(c_str);
return MeasureText(c_str, sz);
};
|