From 131e6d6a27bd2df40e256cf804a45d26f44a2414 Mon Sep 17 00:00:00 2001 From: Jean Sirmai Date: Mon, 2 Oct 2023 18:49:40 +0200 Subject: [PATCH] =?UTF-8?q?WIP:=20RANDOM=20TEST=20=20>=20=20parfois,=20[Ma?= =?UTF-8?q?kefile:121:=20run]=20Exception=20en=20point=20flottant=20et=20p?= =?UTF-8?q?arfois=20buffer=5Flines=5Foffset=20after=20arrows=20mal=20calcu?= =?UTF-8?q?l=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/graphics/graphics.c | 42 ++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/src/graphics/graphics.c b/src/graphics/graphics.c index b327f5d..9c0b063 100644 --- a/src/graphics/graphics.c +++ b/src/graphics/graphics.c @@ -23,6 +23,8 @@ * along with this program. If not, see . */ +#include +#include #include "../../include/base.h" #include "../../include/ui.h" #include "../../include/graphics.h" @@ -744,7 +746,7 @@ static int set_arrow (GLuint *arrows, int arrows_nb, int requested_weight, int s } - +//#define RAND_MAX /* * Init space and arrows (= initial state) * and allows ulterior creations, suppressions or modifications of the arrows[] array @@ -758,17 +760,28 @@ void main_test_graphics (void) // assert : no more than one arrow per address TODO NOT checked before init // notify : weights are replaced, NOT added (could be !) TODO - int space_X = 4, space_Y = 1, space_Z = 1; + // Initialisation du générateur pseudo-aléatoire + srand(time(NULL)); + int rand(void); + void srand(unsigned int seed); // printf ("Valeur max : %d\n", RAND_MAX); + + int space_X = rand() % 13, space_Y = rand() % 11, space_Z = rand() % 7; + int density_max = space_X * space_Y * space_Z; + int arrows_nb = rand() % density_max / 3; + int pref_show_grids = 0; // 0, 1, 2, 3, 5, 6, 10, 15, 30, etc // xyz, 0, x, y, z, xy, xz, yz, xyz - GLuint arrows[] = { - 1, 0, 0, 0, 0, - 1, 1, 1, 0, 0, - 1, 0, 2, 0, 0, - 1, 1, 3, 0, 0, - // load, site, x, y, z + + GLuint arrows[arrows_nb * 5]; + + for (int i = 0; i < arrows_nb; i ++) { + arrows[i * 5 + 0] = rand() % 19; // load / weight + arrows[i * 5 + 1] = rand() % 7; // site + arrows[i * 5 + 2] = rand() % (space_X + 1); // x + arrows[i * 5 + 3] = rand() % (space_Y + 1); // y + arrows[i * 5 + 4] = rand() % (space_Z + 1); // z }; - int arrows_nb = sizeof(arrows) / sizeof(arrows[0]) / 5; + //int arrows_nb = sizeof(arrows) / sizeof(arrows[0]) / 5; show_user_choices(arrows, arrows_nb, space_X, space_Y, space_Z, pref_show_grids, 1); /* GRID */ grid_write_intersections (space_X, space_Y, space_Z); @@ -784,16 +797,7 @@ void main_test_graphics (void) * are always defined (whether arrows are drawn or not). */ arrows_write_terminations (space_X, space_Y, space_Z); - arrows_nb = set_arrow (arrows, arrows_nb, 0, 0, 0, 0, 0); - arrows_nb = set_arrow (arrows, arrows_nb, 0, 0, 2, 0, 0); - arrows_nb = set_arrow (arrows, arrows_nb, 0, 1, 1, 0, 0); - arrows_nb = set_arrow (arrows, arrows_nb, 0, 1, 3, 0, 0); - arrows_nb = set_arrow (arrows, arrows_nb, 1, 0, 1, 0, 0); - arrows_nb = set_arrow (arrows, arrows_nb, 1, 1, 2, 0, 0); - arrows_nb = set_arrow (arrows, arrows_nb, 8, 1, 3, 0, 0); - arrows_nb = set_arrow (arrows, arrows_nb, 8, 1, 3, 0, 0); - arrows_nb = set_arrow (arrows, arrows_nb, 0, 1, 3, 0, 0); - arrows_nb = set_arrow (arrows, arrows_nb, 0, 1, 1, 0, 0); +// arrows_nb = set_arrow (arrows, arrows_nb, 0, 0, 0, 0, 0); int weight = 0, site = 0, stx = space_Z * space_Y, sty = space_Z, stz = 1, arrow_offset = 0;