WIP: RANDOM TEST > parfois, [Makefile:121: run] Exception en point flottant et parfois buffer_lines_offset after arrows mal calculé

This commit is contained in:
Jean Sirmai 2023-10-02 18:49:40 +02:00
parent 56e83bf658
commit 131e6d6a27
Signed by: jean
GPG Key ID: FB3115C340E057E3
1 changed files with 23 additions and 19 deletions

View File

@ -23,6 +23,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <stdlib.h>
#include <time.h>
#include "../../include/base.h" #include "../../include/base.h"
#include "../../include/ui.h" #include "../../include/ui.h"
#include "../../include/graphics.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) * Init space and arrows (= initial state)
* and allows ulterior creations, suppressions or modifications of the arrows[] array * 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 // assert : no more than one arrow per address TODO NOT checked before init
// notify : weights are replaced, NOT added (could be !) TODO // 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 int pref_show_grids = 0; // 0, 1, 2, 3, 5, 6, 10, 15, 30, etc
// xyz, 0, x, y, z, xy, xz, yz, xyz // xyz, 0, x, y, z, xy, xz, yz, xyz
GLuint arrows[] = {
1, 0, 0, 0, 0, GLuint arrows[arrows_nb * 5];
1, 1, 1, 0, 0,
1, 0, 2, 0, 0, for (int i = 0; i < arrows_nb; i ++) {
1, 1, 3, 0, 0, arrows[i * 5 + 0] = rand() % 19; // load / weight
// load, site, x, y, z 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); show_user_choices(arrows, arrows_nb, space_X, space_Y, space_Z, pref_show_grids, 1);
/* GRID */ /* GRID */
grid_write_intersections (space_X, space_Y, space_Z); 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). */ * are always defined (whether arrows are drawn or not). */
arrows_write_terminations (space_X, space_Y, space_Z); 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, 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);
int weight = 0, site = 0, int weight = 0, site = 0,
stx = space_Z * space_Y, sty = space_Z, stz = 1, arrow_offset = 0; stx = space_Z * space_Y, sty = space_Z, stz = 1, arrow_offset = 0;