OK ? No. 'Almost OK' I'm sure that at least ONE bug remains in it...
This commit is contained in:
parent
1e3c560eda
commit
6182edc95b
|
@ -539,75 +539,13 @@ bool graphics_shutdown(const void *gl_area)
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static void show_arrows_array (GLuint *arrows, int arrows_nb, int x, int y, int z)
|
||||
{
|
||||
printf("\n [rank] load | site x y z");
|
||||
for (int i = 0; i < arrows_nb; i++)
|
||||
printf("\n [%4d] = %2d | %2d, %2d, %2d, %2d", i, *(arrows + i * 5 + 0),\
|
||||
*(arrows + i * 5 + 1), *(arrows + i * 5 + 2), *(arrows + i * 5 + 3), *(arrows + i * 5 + 4));
|
||||
}
|
||||
|
||||
static void show_user_choices(GLuint *arrows, int arrows_nb,
|
||||
int space_size_x, int space_size_y, int space_size_z,
|
||||
|
@ -617,95 +555,37 @@ static void show_user_choices(GLuint *arrows, int arrows_nb,
|
|||
if (prefer == 0) printf("prefer = %d <> show all grids", prefer);
|
||||
if (prefer == 1) printf("prefer = %d <> show no grid", prefer);
|
||||
if (prefer > 1) printf("show grids according rule (%d)", prefer);
|
||||
if (show_all) {
|
||||
printf("\n\t\t\t\t\t buffer_vertex_size = %d\t buffer_lines_size = %d", buffer_vertex_size, buffer_lines_size);
|
||||
if (arrows_nb > 0) printf("\n [%2d] load | site x y z\
|
||||
< initial arrows data\n -------------------------------", arrows_nb);
|
||||
for (int i = 0; i < arrows_nb; i++) printf("\n [%2d] = %2d | %2d %2d %2d %2d",\
|
||||
i, *(arrows + i * 5 + 0), *(arrows + i * 5 + 1), *(arrows + i * 5 + 2), *(arrows + i * 5 + 3), *(arrows + i * 5 + 4));
|
||||
if (arrows_nb > 0) printf("\n -------------------------------");}
|
||||
if (show_all) printf("\n\
|
||||
initial arrows data arrows_nb = %d", arrows_nb);
|
||||
show_arrows_array (arrows, arrows_nb, space_size_x, space_size_y, space_size_z);
|
||||
}
|
||||
|
||||
|
||||
/* static void show_arrows_array_old (GLuint *arrows, int arrows_nb, int address, int current_weigh, int weight, int site, int x, int y, int z) */
|
||||
/* { */
|
||||
/* printf("\nset_arrow (%d | %2d %2d %2d %2d) <> ", weight, site, x, y, z); */
|
||||
|
||||
/* if (arrows_nb == 0 && weight == 0) printf("buffer_lines_size = %d\tno arrow in space + no arrows to be created > end function set_arrow()\n", buffer_lines_size); */
|
||||
/* if (address == -1 && weight == 0) printf("buffer_lines_size = %d\tarrow not found + no arrows to be created > end function set_arrow()\n", buffer_lines_size); */
|
||||
/* if (address == -1 && weight > 0) printf("buffer_lines_size = %d\tarrow (%d, %d, %d, %d, %d) not found > new arrow will be created at line [%d]\n",\ */
|
||||
/* buffer_lines_size, arrows_nb, weight, site, x, y, z); */
|
||||
/* if (address >= 0 && weight == 0) printf("buffer_lines_size = %d\tarrow found at line [%d] > will be erased\n", buffer_lines_size, address / 5); */
|
||||
/* if (address >= 0 && weight > 0) { */
|
||||
/* if (current_weigh != weight) printf("buffer_lines_size = %d\tarrow found at line [%d] > will be modified\n", buffer_lines_size, address / 5); */
|
||||
/* if (current_weigh == weight) printf("buffer_lines_size = %d\tarrow found at line [%d] > will not be modified\n", buffer_lines_size, address / 5); */
|
||||
/* } */
|
||||
|
||||
/* printf(" [rank] load | site x y z\n"); */
|
||||
/* for (int i = 0; i < arrows_nb; i++) */
|
||||
/* { */
|
||||
/* if (address == -1 && weight == 0) printf("(address == -1 && weight == 0) > END"); */
|
||||
/* if (address == -1 && weight > 0) {printf("(address == %d && weight == %d) > Create", address/5, weight); create_arrow (arrows, arrows_nb, weight, site, x, y, z);} */
|
||||
/* if (address >= 0 && weight == 0) {printf("(address == %d && weight == %d) > Erase", address/5, weight); erase_arrow (arrows, arrows_nb, address, site, x, y, z);} */
|
||||
/* if (address >= 0 && current_weight == weight) printf("(address found && current_weight == weight) > END"); */
|
||||
/* if (address >= 0 && current_weight != weight) {printf("(address == %d && %d != %d) > Modify", address/5, current_weight, weight); */
|
||||
/* rewrite_arrow (arrows, arrows_nb, address/5, weight, site, x, y, z);} */
|
||||
|
||||
/* printf(" [%4d] = %2d | %2d, %2d, %2d, %2d ",\ */
|
||||
/* i, *(arrows + i * 5 + 0), *(arrows + i * 5 + 1), *(arrows + i * 5 + 2),\ */
|
||||
/* *(arrows + i * 5 + 3), *(arrows + i * 5 + 4)); */
|
||||
/* if (weight == 0 && i == address / 5) printf(" <<<| < - > (%d, %d, %d, %d) moved at [%2d]",\ */
|
||||
/* *(arrows + i * 5 + 1), *(arrows + i * 5 + 2),\ */
|
||||
/* *(arrows + i * 5 + 3), *(arrows + i * 5 + 4), address / 5); */
|
||||
/* if (address >= 0 && current_weigh != weight) */
|
||||
/* printf(" <<< < + > (%d, %d, %d, %d) added at [%2d]",\ */
|
||||
/* *(arrows + i * 5 + 1), *(arrows + i * 5 + 2),\ */
|
||||
/* *(arrows + i * 5 + 3), *(arrows + i * 5 + 4), address / 5); */
|
||||
/* if (weight > 0 && current_weigh == weight && i == address / 5) printf(" <"); */
|
||||
/* if (weight == 0 && i > address / 5 && i < arrows_nb - 1) printf(" |"); */
|
||||
/* if (weight == 0 && i == arrows_nb - 1 && i != address / 5) printf(" |"); */
|
||||
/* printf("\n"); */
|
||||
/* } */
|
||||
/* } */
|
||||
|
||||
static void show_arrows_array (GLuint *arrows, int arrows_nb, int address, int current_weigh, int weight, int site, int x, int y, int z)
|
||||
{
|
||||
printf("\n [rank] load | site x y z");
|
||||
for (int i = 0; i < arrows_nb; i++)
|
||||
printf("\n [%4d] = %2d | %2d, %2d, %2d, %2d", i, *(arrows + i * 5 + 0),\
|
||||
*(arrows + i * 5 + 1), *(arrows + i * 5 + 2), *(arrows + i * 5 + 3), *(arrows + i * 5 + 4));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* replaces the current load of the arrow at address (address) by the new load 'weight' */
|
||||
/*
|
||||
* assigns a new weight to the arrow at address (address)
|
||||
*/
|
||||
static int rewrite_arrow (GLuint *arrows, int arrows_nb, int address, int weight, int site, int x, int y, int z)
|
||||
{
|
||||
*(arrows + address * 5 + 0) = weight;
|
||||
show_arrows_array (arrows, arrows_nb, address, *(arrows + address + 0), weight, site, x, y, z);
|
||||
|
||||
show_arrows_array (arrows, arrows_nb, x, y, z);
|
||||
|
||||
return arrows_nb;
|
||||
}
|
||||
|
||||
static int create_arrow (GLuint *arrows, int arrows_nb, int weight, int site, int x, int y, int z)
|
||||
{
|
||||
if (0) printf("\ncreating the new arrow (%d, %d, %d, %d, %d)",\
|
||||
weight, site, x, y, z);
|
||||
|
||||
buffer_lines_size += (3 + 4) * 2;
|
||||
buffer_lines_origin = g_realloc(buffer_lines_origin, buffer_lines_size * sizeof(GLuint));
|
||||
|
||||
arrows_nb --; //////////////////////////////////////////////// ?
|
||||
|
||||
*(arrows + arrows_nb * 5 + 0) = weight;
|
||||
*(arrows + arrows_nb * 5 + 1) = site;
|
||||
*(arrows + arrows_nb * 5 + 2) = x;
|
||||
*(arrows + arrows_nb * 5 + 3) = y;
|
||||
*(arrows + arrows_nb * 5 + 4) = z;
|
||||
|
||||
show_arrows_array(arrows, arrows_nb + 1, -1, -1, weight, site, x, y, z);
|
||||
arrows_nb ++;
|
||||
|
||||
printf("buffer_lines_size = %d\tarrow (%d, %d, %d, %d, %d) was created",\
|
||||
buffer_lines_size, weight, site, x, y, z);
|
||||
show_arrows_array(arrows, arrows_nb, x, y, z);
|
||||
|
||||
return arrows_nb;
|
||||
}
|
||||
|
@ -714,17 +594,19 @@ static int erase_arrow (GLuint *arrows, int arrows_nb, int address, int site, in
|
|||
{
|
||||
arrows_nb --;
|
||||
|
||||
if (arrows_nb > 0) {
|
||||
if (arrows_nb > 0)
|
||||
{
|
||||
*(arrows + address + 0) = *(arrows + arrows_nb * 5 + 0);
|
||||
*(arrows + address + 1) = *(arrows + arrows_nb * 5 + 1);
|
||||
*(arrows + address + 2) = *(arrows + arrows_nb * 5 + 2);
|
||||
*(arrows + address + 3) = *(arrows + arrows_nb * 5 + 3);
|
||||
*(arrows + address + 4) = *(arrows + arrows_nb * 5 + 4);
|
||||
}
|
||||
// buffer_lines_size -= (3 + 4) * 2; Warum ?
|
||||
|
||||
buffer_lines_origin = g_realloc(buffer_lines_origin, buffer_lines_size * sizeof(GLuint));
|
||||
|
||||
show_arrows_array(arrows, arrows_nb, address, -1, 0, site, x, y, z);
|
||||
show_arrows_array(arrows, arrows_nb, x, y, z);
|
||||
|
||||
return arrows_nb;
|
||||
}
|
||||
|
||||
|
@ -751,18 +633,26 @@ static int set_arrow (GLuint *arrows, int arrows_nb, int requested_weight, int s
|
|||
|
||||
printf("\nset_arrow() invoked with requested weight = %d > ", requested_weight);
|
||||
|
||||
if (address == -1 && requested_weight == 0) {printf("no such arrow found && requested weight == 0 => END"); return arrows_nb;}
|
||||
if (address == -1 && requested_weight > 0) {printf("(no such arrow found && requested weight == %d) => Create", requested_weight); return create_arrow (arrows, arrows_nb, requested_weight, site, x, y, z);}
|
||||
if (address == -1 && requested_weight > 0) {printf("no such arrow found\n\
|
||||
requested weight == %d => CREATE", requested_weight);
|
||||
return create_arrow (arrows, arrows_nb, requested_weight, site, x, y, z);}
|
||||
|
||||
if (address >= 0 && requested_weight == 0) {printf("arrow (%d,%d,%d,%d) found at address %d; current_weight = %d;\n\
|
||||
requested weight == %d => Erase",\
|
||||
requested weight == %d => ERASE",\
|
||||
arrows[address + 1],arrows[address + 2],arrows[address + 3],arrows[address + 4], address/5, current_weight, requested_weight);
|
||||
return erase_arrow (arrows, arrows_nb, address, site, x, y, z);}
|
||||
if (address >= 0 && current_weight == requested_weight) {printf("arrow (%d,%d,%d,%d) found at address %d; current_weight == requested_weight => END",\
|
||||
arrows[address + 1],arrows[address + 2],arrows[address + 3],arrows[address + 4], address); return arrows_nb;}
|
||||
|
||||
if (address >= 0 && current_weight != requested_weight) {printf("arrow (%d,%d,%d,%d) found at address %d; current_weight = %d;\n\
|
||||
current weight != requested weight => Modify",\
|
||||
requested weight != current weight => MODIFY",\
|
||||
arrows[address + 1],arrows[address + 2],arrows[address + 3],arrows[address + 4], address/5, current_weight);
|
||||
return rewrite_arrow (arrows, arrows_nb, address/5, requested_weight, site, x, y, z);}
|
||||
|
||||
if (address >= 0 && current_weight == requested_weight) {
|
||||
printf("arrow (%d,%d,%d,%d) found at address %d; current_weight == requested_weight => END",\
|
||||
arrows[address + 1], arrows[address + 2], arrows[address + 3], arrows[address + 4], address); return arrows_nb;}
|
||||
|
||||
if (address == -1 && requested_weight == 0) {printf("no such arrow found && requested weight == 0 => END"); return arrows_nb;}
|
||||
|
||||
return arrows_nb;
|
||||
}
|
||||
|
||||
|
@ -798,13 +688,24 @@ void main_test_graphics (void)
|
|||
int buffer_lines_size_after_cubes = buffer_lines_size;
|
||||
int offset_up_to_this_cube_coords = 0, x, y, z;
|
||||
/* ARROWS */
|
||||
/* The 12 vertices required to draw 6 arrows in each cube
|
||||
* are always defined (whether arrows are drawn or not). */
|
||||
/* 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);
|
||||
|
||||
arrows_nb = set_arrow (arrows, arrows_nb, 0, 0, 0, 0, 0);
|
||||
arrows_nb = set_arrow (arrows, arrows_nb, 8, 1, 3, 0, 0);
|
||||
arrows_nb = set_arrow (arrows, arrows_nb, 0, 1, 1, 0, 0);
|
||||
arrows_nb = set_arrow (arrows, arrows_nb, 1, 2, 0, 0, 0);
|
||||
arrows_nb = set_arrow (arrows, arrows_nb, 1, 3, 0, 0, 0);
|
||||
arrows_nb = set_arrow (arrows, arrows_nb, 0, 0, 2, 0, 0);
|
||||
arrows_nb = set_arrow (arrows, arrows_nb, 0, 3, 0, 0, 0);
|
||||
arrows_nb = set_arrow (arrows, arrows_nb, 0, 1, 3, 0, 0);
|
||||
arrows_nb = set_arrow (arrows, arrows_nb, 0, 2, 0, 0, 0);
|
||||
arrows_nb = set_arrow (arrows, arrows_nb, 0, 0, 0, 0, 0);
|
||||
arrows_nb = set_arrow (arrows, arrows_nb, 7, 0, 1, 0, 0);
|
||||
arrows_nb = set_arrow (arrows, arrows_nb, 5, 1, 2, 0, 0);
|
||||
arrows_nb = set_arrow (arrows, arrows_nb, 5, 1, 2, 0, 0);
|
||||
arrows_nb = set_arrow (arrows, arrows_nb, 3, 1, 2, 0, 0);
|
||||
|
||||
int weight = 0, site = 0,
|
||||
stx = space_Z * space_Y, sty = space_Z, stz = 1, arrow_offset = 0;
|
||||
|
|
Loading…
Reference in New Issue