From 674f8aa8f7a4e5a7197eae49c116727f4d681831 Mon Sep 17 00:00:00 2001 From: Mitya Selivanov Date: Wed, 13 Nov 2024 22:43:04 +0100 Subject: Remove shstk option --- examples/echo.c | 2 +- examples/game_of_life.c | 24 ++++---- examples/graph.c | 24 ++++---- examples/gravity.c | 156 ------------------------------------------------ examples/julia_set.c | 24 ++++---- examples/labyrinth.c | 24 ++++---- examples/landscape.c | 24 ++++---- examples/particles.c | 156 ++++++++++++++++++++++++++++++++++++++++++++++++ examples/ui.c | 24 ++++---- reduced_system_layer.c | 26 ++++---- rf64.c | 24 ++++---- 11 files changed, 254 insertions(+), 254 deletions(-) delete mode 100755 examples/gravity.c create mode 100755 examples/particles.c diff --git a/examples/echo.c b/examples/echo.c index 1a04fbb..efc6950 100755 --- a/examples/echo.c +++ b/examples/echo.c @@ -18,7 +18,7 @@ gcc \ -Wno-unused-parameter \ -Wno-overlength-strings \ -O3 \ - -fsanitize=undefined,address,leak -mshstk \ + -fsanitize=undefined,address,leak \ -lX11 -lm \ -o $BIN $SRC && \ ./$BIN $@ && rm $BIN diff --git a/examples/game_of_life.c b/examples/game_of_life.c index 7fee606..9210829 100755 --- a/examples/game_of_life.c +++ b/examples/game_of_life.c @@ -9,18 +9,18 @@ #/ 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 && \ +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 \ + -lX11 -lm \ + -o $BIN $SRC && \ ./$BIN $@ && rm $BIN exit $? # */ #endif diff --git a/examples/graph.c b/examples/graph.c index 685f8b7..d1ee2a9 100755 --- a/examples/graph.c +++ b/examples/graph.c @@ -9,18 +9,18 @@ #/ 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 && \ +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 \ + -lX11 -lm \ + -o $BIN $SRC && \ ./$BIN $@ && rm $BIN exit $? # */ #endif diff --git a/examples/gravity.c b/examples/gravity.c deleted file mode 100755 index d21a4f5..0000000 --- a/examples/gravity.c +++ /dev/null @@ -1,156 +0,0 @@ -#if 0 /* -#/ ================================================================ -#/ -#/ gravity.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" - -typedef struct { - f64 x; - f64 y; - f64 vx; - f64 vy; -} Entity; - -typedef struct { - i64 time; - i64 num_entities; - Entity entities[10 * 1024 * 1024]; -} World; - -World world = {0}; -u32 background; -i64 time_0; - -void update_and_render_frame(void) { - p_handle_events(); - - i64 time_elapsed = p_time() - time_0; - time_0 += time_elapsed; - - if (platform.key_pressed[BUTTON_LEFT]) { - i64 n = world.num_entities++; - - world.entities[n] = (Entity) { - .x = (f64) platform.cursor_x - (f64) platform.frame_width / 2, - .y = -((f64) platform.cursor_y - (f64) platform.frame_height / 2), - }; - } - - if (time_elapsed > 0) { - if (platform.key_down[BUTTON_RIGHT]) { - for (i64 n = 0; n < time_elapsed; ++n) - world.entities[world.num_entities + n] = (Entity) { - .x = (f64) platform.cursor_x - (f64) platform.frame_width / 2, - .y = -((f64) platform.cursor_y - (f64) platform.frame_height / 2), - }; - - world.num_entities += time_elapsed; - } - - for (i64 n = 0; n < world.num_entities; ++n) { - Entity *e = &world.entities[n]; - - for (i64 k = 0; k < n; ++k) { - Entity *u = &world.entities[k]; - - f64 dx = e->x - u->x; - f64 dy = e->y - u->y; - f64 d = dx * dx + dy * dy; - if (d < 1000.) continue; - - f64 r = sqrt(d); - dx /= r; - dy /= r; - - f64 a = (1. / d) * time_elapsed; - - if (d < 5000.) - a = -a; - - e->vx -= dx * a; - e->vy -= dy * a; - u->vx += dx * a; - u->vy += dy * a; - } - } - - for (i64 n = 0; n < world.num_entities; ++n) { - Entity *e = &world.entities[n]; - - e->x += e->vx * time_elapsed; - e->y += e->vy * time_elapsed; - - f64 z = (M_PI * 2.0) * (rand() % 10000) * .0001; - e->vx += .0001 * cos(z); - e->vy += .0001 * sin(z); - } - - world.time += time_elapsed; - } - - for (i32 j = 0; j < platform.frame_height; ++j) - for (i32 i = 0; i < platform.frame_width; ++i) - platform.pixels[j * platform.frame_width + i] = background; - - for (i64 n = 0; n < world.num_entities; ++n) { - Entity *e = &world.entities[n]; - - i32 x = platform.frame_width / 2 + (i32) floor(e->x + .5); - i32 y = platform.frame_height / 2 - (i32) floor(e->y + .5); - - for (i32 j = y - 10; j <= y + 10; ++j) { - if (j < 0 || j >= platform.frame_height) continue; - for (i32 i = x - 10; i <= x + 10; ++i) { - if (i < 0 || i >= platform.frame_width) continue; - if ((i - x) * (i - x) + (j - y) * (j - y) > 100) continue; - f64 v = (e->vx * e->vx + e->vy * e->vy) * 8.; - platform.pixels[j * platform.frame_width + i] = u32_from_rgb(-.2 + v * 2., .1 + v * .7, 1. - v); - } - } - } - - p_render_frame(); -} - -i32 main(i32 argc, c8 **argv) { - (void) argc; - (void) argv; - - platform = (Platform) { - .title = "Gravity", - .frame_width = 960, - .frame_height = 720, - }; - - background = u32_from_rgb(.0f, .0f, .08f); - time_0 = p_time(); - - srand(p_time()); - - p_event_loop(); - - return 0; -} diff --git a/examples/julia_set.c b/examples/julia_set.c index 0d6c5be..4cfb326 100755 --- a/examples/julia_set.c +++ b/examples/julia_set.c @@ -9,18 +9,18 @@ #/ 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 \ - -g -O3 \ - -fsanitize=undefined,address,leak -mshstk \ - -lX11 -lm \ - -o $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 \ + -g -O3 \ + -fsanitize=undefined,address,leak \ + -lX11 -lm \ + -o $BIN $SRC && \ ./$BIN $@ && rm $BIN exit $? # */ #endif diff --git a/examples/labyrinth.c b/examples/labyrinth.c index ef0e96d..fa03d75 100755 --- a/examples/labyrinth.c +++ b/examples/labyrinth.c @@ -9,18 +9,18 @@ #/ 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 && \ +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 \ + -lX11 -lm \ + -o $BIN $SRC && \ ./$BIN $@ && rm $BIN exit $? # */ #endif diff --git a/examples/landscape.c b/examples/landscape.c index 94b868f..9ee2e98 100755 --- a/examples/landscape.c +++ b/examples/landscape.c @@ -9,18 +9,18 @@ #/ 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 && \ +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 \ + -lX11 -lm \ + -o $BIN $SRC && \ ./$BIN $@ && rm $BIN exit $? # */ #endif diff --git a/examples/particles.c b/examples/particles.c new file mode 100755 index 0000000..0fcef37 --- /dev/null +++ b/examples/particles.c @@ -0,0 +1,156 @@ +#if 0 /* +#/ ================================================================ +#/ +#/ particles.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 \ + -lX11 -lm \ + -o $BIN $SRC && \ + ./$BIN $@ && rm $BIN +exit $? # */ +#endif + +#include "../graphics.c" + +typedef struct { + f64 x; + f64 y; + f64 vx; + f64 vy; +} Entity; + +typedef struct { + i64 time; + i64 num_entities; + Entity entities[10 * 1024 * 1024]; +} World; + +World world = {0}; +u32 background; +i64 time_0; + +void update_and_render_frame(void) { + p_handle_events(); + + i64 time_elapsed = p_time() - time_0; + time_0 += time_elapsed; + + if (platform.key_pressed[BUTTON_LEFT]) { + i64 n = world.num_entities++; + + world.entities[n] = (Entity) { + .x = (f64) platform.cursor_x - (f64) platform.frame_width / 2, + .y = -((f64) platform.cursor_y - (f64) platform.frame_height / 2), + }; + } + + if (time_elapsed > 0) { + if (platform.key_down[BUTTON_RIGHT]) { + for (i64 n = 0; n < time_elapsed; ++n) + world.entities[world.num_entities + n] = (Entity) { + .x = (f64) platform.cursor_x - (f64) platform.frame_width / 2, + .y = -((f64) platform.cursor_y - (f64) platform.frame_height / 2), + }; + + world.num_entities += time_elapsed; + } + + for (i64 n = 0; n < world.num_entities; ++n) { + Entity *e = &world.entities[n]; + + for (i64 k = 0; k < n; ++k) { + Entity *u = &world.entities[k]; + + f64 dx = e->x - u->x; + f64 dy = e->y - u->y; + f64 d = dx * dx + dy * dy; + if (d < 1000.) continue; + + f64 r = sqrt(d); + dx /= r; + dy /= r; + + f64 a = (1. / d) * time_elapsed; + + if (d < 5000.) + a = -a; + + e->vx -= dx * a; + e->vy -= dy * a; + u->vx += dx * a; + u->vy += dy * a; + } + } + + for (i64 n = 0; n < world.num_entities; ++n) { + Entity *e = &world.entities[n]; + + e->x += e->vx * time_elapsed; + e->y += e->vy * time_elapsed; + + f64 z = (M_PI * 2.0) * (rand() % 10000) * .0001; + e->vx += .0001 * cos(z); + e->vy += .0001 * sin(z); + } + + world.time += time_elapsed; + } + + for (i32 j = 0; j < platform.frame_height; ++j) + for (i32 i = 0; i < platform.frame_width; ++i) + platform.pixels[j * platform.frame_width + i] = background; + + for (i64 n = 0; n < world.num_entities; ++n) { + Entity *e = &world.entities[n]; + + i32 x = platform.frame_width / 2 + (i32) floor(e->x + .5); + i32 y = platform.frame_height / 2 - (i32) floor(e->y + .5); + + for (i32 j = y - 10; j <= y + 10; ++j) { + if (j < 0 || j >= platform.frame_height) continue; + for (i32 i = x - 10; i <= x + 10; ++i) { + if (i < 0 || i >= platform.frame_width) continue; + if ((i - x) * (i - x) + (j - y) * (j - y) > 100) continue; + f64 v = (e->vx * e->vx + e->vy * e->vy) * 8.; + platform.pixels[j * platform.frame_width + i] = u32_from_rgb(-.2 + v * 2., .1 + v * .7, 1. - v); + } + } + } + + p_render_frame(); +} + +i32 main(i32 argc, c8 **argv) { + (void) argc; + (void) argv; + + platform = (Platform) { + .title = "Gravity", + .frame_width = 960, + .frame_height = 720, + }; + + background = u32_from_rgb(.0f, .0f, .08f); + time_0 = p_time(); + + srand(p_time()); + + p_event_loop(); + + return 0; +} diff --git a/examples/ui.c b/examples/ui.c index dc54cc0..9576910 100755 --- a/examples/ui.c +++ b/examples/ui.c @@ -9,18 +9,18 @@ #/ 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 && \ +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 \ + -lX11 -lm \ + -o $BIN $SRC && \ ./$BIN $@ && rm $BIN exit $? # */ #endif diff --git a/reduced_system_layer.c b/reduced_system_layer.c index 38562eb..9c1e67e 100755 --- a/reduced_system_layer.c +++ b/reduced_system_layer.c @@ -51,19 +51,19 @@ #/ 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 \ - -D REDUCED_SYSTEM_LAYER_EXAMPLE \ - -lX11 -lm \ - -o $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 \ + -D REDUCED_SYSTEM_LAYER_EXAMPLE \ + -lX11 -lm \ + -o $BIN $SRC && \ ./$BIN $@ && rm $BIN exit $? # */ #endif diff --git a/rf64.c b/rf64.c index aeba85a..0a70794 100755 --- a/rf64.c +++ b/rf64.c @@ -15,18 +15,18 @@ #/ 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 \ - -D RF64_TESTS \ - -o $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 \ + -D RF64_TESTS \ + -o $BIN $SRC && \ ./$BIN $@ && rm $BIN exit $? # */ #endif -- cgit v1.2.3