SUCCESS IN PASSING A STRONG RANDOM GRAPHIC TEST

This commit is contained in:
Jean Sirmai 2023-10-02 21:25:20 +02:00
parent 131e6d6a27
commit 567a5ec07f
Signed by: jean
GPG Key ID: FB3115C340E057E3
1 changed files with 45 additions and 32 deletions

View File

@ -111,9 +111,12 @@ static void graphics_debug_callback(GLenum source, GLenum type, GLuint id,
/* -------------------------------------------------------------------------- */
/*
* void graphics_erase_line (GLuint a, GLuint b){} TODO and to use ?
* As, in this version only lines can be erased,
* similar functions for vertex and plans are not considered. But ?...
* TODO ?
* Should a function "graphics_erase_line (GLuint a, GLuint b)" be used ?
* symetric with graphics_write_line (GLuint a, GLuint b)
*
* NB in this version lines only can be erased,
* and similar functions for vertex and plans have not to be considered.
*/
/*
@ -636,9 +639,18 @@ static void show_buffers_states(int space_X, int space_Y, int space_Z, int arrow
buffer_lines_size_after_cubes, ((space_X+1) * (space_Y+1) + (space_X+1) * (space_Z+1) + (space_Y+1) * (space_Z+1)) * 2,
space_X+1, space_Y+1, space_X+1, space_Z+1, space_Y+1, space_Z+1);
printf("\n buffer_lines_offset after arrows = %6d\t%6d = %d + %d; <--> %d = (3 + 4) x 2 x %d (arrows_nb = %d)\n",\
printf("\n buffer_lines_offset after arrows = %6d\t%6d = %d + %d; <--> %d = (3 + 4) x 2 x %d (arrows_nb = %d)",\
buffer_lines_size, buffer_lines_size, buffer_lines_size_after_cubes,\
buffer_lines_size - buffer_lines_size_after_cubes, arrows_nb * 14, arrows_nb, arrows_nb);
if (arrows_nb < 0) // LOL ! This error no more exists !
printf("\n ERR : %d - %d = %d %d = %d x %d\n",\
arrows_nb * 14, buffer_lines_size - buffer_lines_size_after_cubes,\
arrows_nb * 14 - (buffer_lines_size - buffer_lines_size_after_cubes),\
arrows_nb * 14 - (buffer_lines_size - buffer_lines_size_after_cubes),\
(arrows_nb * 14 - (buffer_lines_size - buffer_lines_size_after_cubes)) / arrows_nb, arrows_nb);
printf("\n WARNING In this test, it may happens that two or several arrow basis are drawn superimposed (check the list).\n");
}
@ -763,25 +775,25 @@ void main_test_graphics (void)
// 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);
void srand(unsigned int seed); // printf ("Valeur max : %d\n", RAND_MAX); min + rand() % (max+1 - min);
int space_X = rand() % 13, space_Y = rand() % 11, space_Z = rand() % 7;
int arbitrary = 11;
int space_X = 1 + rand() % arbitrary, space_Y = 1 + rand() % arbitrary, space_Z = 1 + rand() % arbitrary;
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[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;
if (arrows_nb > 0)
for (int i = 0; i < arrows_nb; i ++) {
arrows[i * 5 + 0] = 1 + rand() % arbitrary; // load / weight
arrows[i * 5 + 1] = rand() % 6; // site
arrows[i * 5 + 2] = rand() % space_X; // x
arrows[i * 5 + 3] = rand() % space_Y; // y
arrows[i * 5 + 4] = rand() % space_Z; // z
};
//int arrows_nb = sizeof(arrows) / sizeof(arrows[0]) / 5; forget, during the random tests
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);
@ -795,32 +807,33 @@ void main_test_graphics (void)
/* ARROWS */
/* NB The 12 vertices required to draw 6 arrows in each cube
* are always defined (whether arrows are drawn or not). */
arrows_write_terminations (space_X, space_Y, space_Z);
if (arrows_nb > 0) arrows_write_terminations (space_X, space_Y, space_Z);
// 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;
for (int i = 0; i < arrows_nb; i++) {
weight = arrows[i * 5 + 0];
site = arrows[i * 5 + 1];
x = arrows[i * 5 + 2];
y = arrows[i * 5 + 3];
z = arrows[i * 5 + 4];
if (arrows_nb > 0)
for (int i = 0; i < arrows_nb; i++) {
weight = arrows[i * 5 + 0];
site = arrows[i * 5 + 1];
x = arrows[i * 5 + 2];
y = arrows[i * 5 + 3];
z = arrows[i * 5 + 4];
offset_up_to_this_cube_coords = 12 * (stx * x + sty * y + stz * z);
arrow_offset = offset_after_grids + offset_up_to_this_cube_coords;
offset_up_to_this_cube_coords = 12 * (stx * x + sty * y + stz * z);
arrow_offset = offset_after_grids + offset_up_to_this_cube_coords;
arrows_write_basis (arrow_offset);
arrows_write_basis (arrow_offset);
switch(site){
case EAST: case WEST: write_arrow_lines_east_west (arrow_offset, weight, site); break;
case ZENITH: case NADIR: write_arrow_lines_zenith_nadir (arrow_offset, weight, site); break;
case SOUTH: case NORTH: write_arrow_lines_south_north (arrow_offset, weight, site); break;
default: break;
switch(site){
case EAST: case WEST: write_arrow_lines_east_west (arrow_offset, weight, site); break;
case ZENITH: case NADIR: write_arrow_lines_zenith_nadir (arrow_offset, weight, site); break;
case SOUTH: case NORTH: write_arrow_lines_south_north (arrow_offset, weight, site); break;
default: break;
}
}
}
show_buffers_states(space_X, space_Y, space_Z, arrows_nb,
offset_after_grids, buffer_vertex_size,