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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
#if 0 /*
#/ ================================================================
#/
#/ graph.c
#/
#/ ================================================================
#/
#/ Self-compilation shell script
#/
SRC=${0##*./}
BIN=${SRC%.*}
gcc \
-Wall -Wextra -Werror -pedantic \
-Wno-old-style-declaration \
-Wno-missing-braces \
-Wno-unused-variable \
-Wno-unused-but-set-variable \
-Wno-unused-parameter \
-Wno-overlength-strings \
-O3 \
-fsanitize=undefined,address,leak -mshstk \
-lX11 -lm \
-o $BIN $SRC && \
./$BIN $@ && rm $BIN
exit $? # */
#endif
#include "../graphics.c"
i32 main(i32 argc, c8 **argv) {
(void) argc;
(void) argv;
platform = (Platform) {
.title = "Graph",
.frame_width = 960,
.frame_height = 720,
};
u32 WHITE = u32_from_rgb(1.f, 1.f, 1.f);
u32 BLACK = u32_from_rgb(0.f, 0.f, 0.f);
u32 RED = u32_from_rgb(1.f, 0.f, 0.f);
u32 BLUE = u32_from_rgb(0.f, 0.f, 1.f);
p_init();
while (!platform.done) {
p_wait_events();
i64 x = platform.frame_width / 2;
i64 y = platform.frame_height / 2;
fill_rectangle(OP_SET, WHITE, 0, 0, platform.frame_width, platform.frame_height);
fill_triangle(OP_SET, RED, 100, 100, 200, 100, 150, 200);
fill_line(OP_SET, BLUE, 100, 300, 300, 500, 30);
fill_ellipse(OP_SET, BLACK, x - 140, y - 100, 280, 200);
p_render_frame();
}
p_cleanup();
return 0;
}
|