WIP: voyons, voyons... cette fois-ci, l'affichage console semble correct mais aucune flèche n'est dessinée
This commit is contained in:
parent
1182e65eb8
commit
d0dbc75d07
|
@ -552,6 +552,24 @@ bool graphics_shutdown(const void *gl_area)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Prints the arrows[] array
|
* Prints the arrows[] array
|
||||||
*
|
*
|
||||||
|
@ -589,35 +607,6 @@ static void show_user_choices(GLuint *arrows, int arrows_nb,
|
||||||
show_arrows_array (arrows, arrows_nb, space_size_x, space_size_y, space_size_z);
|
show_arrows_array (arrows, arrows_nb, space_size_x, space_size_y, space_size_z);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Prints the result of the function set_arrow()
|
|
||||||
* and indicates the reasons of the choice (call) this function makes (see this function)
|
|
||||||
*/
|
|
||||||
static void show_user_action(GLuint *arrows, int arrows_nb, int address, int requested_weight,
|
|
||||||
int current_weight, int site, int x, int y, int z)
|
|
||||||
{
|
|
||||||
if (address == -1 && requested_weight > 0) {printf("no such arrow found (%d,%d,%d,%d)\n\
|
|
||||||
requested weight == %d => CREATE",\
|
|
||||||
arrows[address + 1], arrows[address + 2], arrows[address + 3], arrows[address + 4], requested_weight); return;}
|
|
||||||
|
|
||||||
if (address >= 0 && requested_weight == 0) {printf("arrow (%d,%d,%d,%d) found at address %d; current_weight = %d;\n\
|
|
||||||
requested weight == %d => ERASE",\
|
|
||||||
arrows[address + 1], arrows[address + 2], arrows[address + 3], arrows[address + 4], address/5, current_weight, requested_weight); return;}
|
|
||||||
|
|
||||||
if (address >= 0 && current_weight != requested_weight) {printf("arrow (%d,%d,%d,%d) found at address %d; current_weight = %d;\n\
|
|
||||||
requested weight != current weight => MODIFY",\
|
|
||||||
arrows[address + 1], arrows[address + 2], arrows[address + 3], arrows[address + 4], address/5, current_weight); return;}
|
|
||||||
|
|
||||||
if (address >= 0 && current_weight == requested_weight){
|
|
||||||
printf("arrow (%d,%d,%d,%d) found at address %d;\n\
|
|
||||||
requested_weight == current_weight => END",\
|
|
||||||
arrows[address + 1], arrows[address + 2], arrows[address + 3], arrows[address + 4], address/5); return;}
|
|
||||||
|
|
||||||
if (address == -1 && requested_weight == 0) {printf("no such arrow found (%d,%d,%d,%d)\n\
|
|
||||||
requested weight == 0 => END",\
|
|
||||||
arrows[address + 1], arrows[address + 2], arrows[address + 3], arrows[address + 4]); return;}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Prints vertex and lines buffers_states (sizes) at major steps and at the end of a session.
|
* Prints vertex and lines buffers_states (sizes) at major steps and at the end of a session.
|
||||||
* Major steps are creation of grids and creation of arrows
|
* Major steps are creation of grids and creation of arrows
|
||||||
|
@ -656,6 +645,24 @@ static void show_buffers_states(int space_X, int space_Y, int space_Z, int arrow
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Assigns a new weight to the arrow at address (address)
|
* Assigns a new weight to the arrow at address (address)
|
||||||
|
@ -715,6 +722,8 @@ static int erase_arrow (GLuint *arrows, int arrows_nb, int address, int site, in
|
||||||
return arrows_nb;
|
return arrows_nb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void show_user_action(GLuint *arrows, int arrows_nb, int address, int requested_weight,
|
||||||
|
int current_weight, int site, int x, int y, int z);
|
||||||
/*
|
/*
|
||||||
* Calls one of the functions create_arrow(), erase_arrow() or rewrite_arrow()
|
* Calls one of the functions create_arrow(), erase_arrow() or rewrite_arrow()
|
||||||
* according to requested weight and address (coord site, x, y, z)
|
* according to requested weight and address (coord site, x, y, z)
|
||||||
|
@ -739,7 +748,7 @@ static int set_arrow (GLuint *arrows, int arrows_nb, int requested_weight, int s
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("\nset_arrow() invoked with requested weight = %d > ", requested_weight);
|
printf("\nset_arrow() invoked with requested weight = %2d > ", requested_weight);
|
||||||
|
|
||||||
show_user_action(arrows, arrows_nb, address, requested_weight, current_weight, site, x, y, z);
|
show_user_action(arrows, arrows_nb, address, requested_weight, current_weight, site, x, y, z);
|
||||||
|
|
||||||
|
@ -760,6 +769,83 @@ static int set_arrow (GLuint *arrows, int arrows_nb, int requested_weight, int s
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Prints the result of the function set_arrow()
|
||||||
|
* and indicates the reasons of the choice (call) this function makes (see this function)
|
||||||
|
*/
|
||||||
|
static void show_user_action(GLuint *arrows, int arrows_nb, int address, int requested_weight,
|
||||||
|
int current_weight, int site, int x, int y, int z)
|
||||||
|
{
|
||||||
|
if (address == -1 && requested_weight > 0) { // *(arrows + i * 5 + 0)
|
||||||
|
printf("no such arrow found (%2d,%2d,%2d,%2d)", site, x, y, z); //arrows[address + 1], arrows[address + 2], arrows[address + 3], arrows[address + 4]);
|
||||||
|
if (! TEST) printf("\n "); else printf(" ");
|
||||||
|
printf("requested weight == %2d => CREATE", requested_weight); return;}
|
||||||
|
|
||||||
|
if (address >= 0 && requested_weight == 0) {
|
||||||
|
printf("arrow (%2d,%2d,%2d,%2d) found at address %2d; current_weight = %2d;", site, x, y, z); // arrows[address + 1], arrows[address + 2], arrows[address + 3], arrows[address + 4], address/5, current_weight);
|
||||||
|
if (! TEST) printf("\n "); else printf(" ");
|
||||||
|
printf("requested weight == %2d => ERASE", requested_weight); return;}
|
||||||
|
|
||||||
|
if (address >= 0 && current_weight != requested_weight) {
|
||||||
|
printf("arrow (%2d,%2d,%2d,%2d) found at address %2d; current_weight = %2d;", site, x, y, z); // arrows[address + 1], arrows[address + 2], arrows[address + 3], arrows[address + 4], address/5, current_weight);
|
||||||
|
if (! TEST) printf("\n "); else printf(" ");
|
||||||
|
printf("requested weight != current weight => MODIFY"); return;}
|
||||||
|
|
||||||
|
if (address >= 0 && current_weight == requested_weight){
|
||||||
|
printf("arrow (%2d,%2d,%2d,%2d) found at address %2d;", site, x, y, z); // arrows[address + 1], arrows[address + 2], arrows[address + 3], arrows[address + 4], address/5);
|
||||||
|
if (! TEST) printf("\n "); else printf(" ");
|
||||||
|
printf("requested_weight == current_weight => END"); return;}
|
||||||
|
|
||||||
|
if (address == -1 && requested_weight == 0) {
|
||||||
|
printf("no such arrow found (%2d,%2d,%2d,%2d)", site, x, y, z); // arrows[address + 1], arrows[address + 2], arrows[address + 3], arrows[address + 4]);
|
||||||
|
if (! TEST) printf("\n "); else printf(" ");
|
||||||
|
printf("requested weight == 0 => END"); return;}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//#define RAND_MAX
|
//#define RAND_MAX
|
||||||
/*
|
/*
|
||||||
* Init space and arrows (= initial state)
|
* Init space and arrows (= initial state)
|
||||||
|
@ -779,8 +865,10 @@ void main_test_graphics (void)
|
||||||
int rand(void);
|
int rand(void);
|
||||||
void srand(unsigned int seed); // printf ("Valeur max : %d\n", RAND_MAX); min + rand() % (max+1 - min);
|
void srand(unsigned int seed); // printf ("Valeur max : %d\n", RAND_MAX); min + rand() % (max+1 - min);
|
||||||
|
|
||||||
int arbitrary = 11;
|
int arbitrary = 5;
|
||||||
int space_X = 1 + rand() % arbitrary, space_Y = 1 + rand() % arbitrary, space_Z = 1 + rand() % arbitrary;
|
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 density_max = space_X * space_Y * space_Z;
|
||||||
int arrows_nb = rand() % density_max / 3;
|
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
|
||||||
|
@ -795,30 +883,37 @@ void main_test_graphics (void)
|
||||||
arrows[i * 5 + 3] = rand() % space_Y; // y
|
arrows[i * 5 + 3] = rand() % space_Y; // y
|
||||||
arrows[i * 5 + 4] = rand() % space_Z; // z
|
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);
|
// forget the next two lines during the random tests
|
||||||
|
// arrows[] = {... some values ...}
|
||||||
|
// int arrows_nb = sizeof(arrows) / sizeof(arrows[0]) / 5;
|
||||||
|
|
||||||
/* GRID */
|
/* GRID */
|
||||||
grid_write_intersections (space_X, space_Y, space_Z);
|
grid_write_intersections (space_X, space_Y, space_Z);
|
||||||
if (pref_show_grids % 2 == 0) grid_write_x (space_X, space_Y, space_Z);
|
if (pref_show_grids % 2 == 0) grid_write_x (space_X, space_Y, space_Z);
|
||||||
if (pref_show_grids % 3 == 0) grid_write_y (space_X, space_Y, space_Z);
|
if (pref_show_grids % 3 == 0) grid_write_y (space_X, space_Y, space_Z);
|
||||||
if (pref_show_grids % 5 == 0) grid_write_z (space_X, space_Y, space_Z);
|
if (pref_show_grids % 5 == 0) grid_write_z (space_X, space_Y, space_Z);
|
||||||
if (pref_show_grids > 0) grid_write_ridges (space_X, space_Y, space_Z);
|
if (pref_show_grids > 0) grid_write_ridges (space_X, space_Y, space_Z);
|
||||||
int offset_after_grids = buffer_vertex_size / 3;
|
|
||||||
int buffer_lines_size_after_cubes = buffer_lines_size;
|
|
||||||
int offset_up_to_this_cube_coords = 0, x, y, z;
|
|
||||||
/* ARROWS */
|
/* ARROWS */
|
||||||
/* NB The 12 vertices required to draw 6 arrows in each cube
|
/* NB The 12 vertices required to draw 6 arrows in each cube
|
||||||
* are always defined (whether arrows are drawn or not). */
|
* are always defined (whether arrows are drawn or not). */
|
||||||
if (arrows_nb > 0) arrows_write_terminations (space_X, space_Y, space_Z);
|
/* Therefore: if (arrows_nb > 0) is not required (next line) */
|
||||||
|
arrows_write_terminations (space_X, space_Y, space_Z);
|
||||||
|
|
||||||
|
int offset_after_grids = buffer_vertex_size / 3;
|
||||||
|
int buffer_lines_size_after_cubes = buffer_lines_size;
|
||||||
|
int offset_up_to_this_cube_coords = 0, x, y, z;
|
||||||
|
|
||||||
// for (int k = 0; k < arbitrary * arbitrary; k++)
|
// for (int k = 0; k < arbitrary * arbitrary; k++)
|
||||||
for (int k = 0; k < 3; k++)
|
/* arrows_nb = set_arrow (arrows, arrows_nb, */
|
||||||
arrows_nb = set_arrow (arrows, arrows_nb,
|
/* rand() % arbitrary, // load / weight */
|
||||||
rand() % arbitrary, // load / weight
|
/* rand() % 6, // site, */
|
||||||
rand() % 6, // site,
|
/* MIN (rand() % space_X, space_X - 1), // x */
|
||||||
0,//MIN (rand() % space_X, space_X - 1), // x
|
/* MIN (rand() % space_Y, space_Y - 1), // y */
|
||||||
0,//MIN (rand() % space_Y, space_Y - 1), // y
|
/* MIN (rand() % space_Z, space_Z - 1)); // z */
|
||||||
0);//MIN (rand() % space_Z, space_Z - 1)); // z
|
|
||||||
|
show_user_choices(arrows, arrows_nb, space_X, space_Y, space_Z, pref_show_grids, 1);
|
||||||
|
|
||||||
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;
|
||||||
|
|
Loading…
Reference in New Issue