diff --git a/src/graphics/graphics.c b/src/graphics/graphics.c index 32702f1..90891fb 100644 --- a/src/graphics/graphics.c +++ b/src/graphics/graphics.c @@ -47,9 +47,9 @@ static volatile int buffer_plans_size = 0; static int pref_show_grids = 0; // 0, 1, 2, 3, 5, 6, 10, 15, 30, etc // xyz, 0, x, y, z, xy, xz, yz, xyz -static int xxx = 0; -static int yyy = 0; -static int zzz = 0; +static int space_X = 0; +static int space_Y = 0; +static int space_Z = 0; static void show_user_choices(GLuint *arrows, int arrows_nb, int space_size_x, int space_size_y, int space_size_z, @@ -65,17 +65,17 @@ static void show_user_choices(GLuint *arrows, int arrows_nb, < initial 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 (arrows_nb > 0) printf("\n -------------------------------\n");} } static void get_model_data_and_user_preferences(GLuint *arrows, int arrows_nb) { - xxx = 1; // 0 < model_space_size_x - yyy = 1; // 0 < model_space_size_y - zzz = 1; // 0 < model_space_size_z + space_X = 4; // 0 < model_space_size_x + space_Y = 1; // 0 < model_space_size_y + space_Z = 1; // 0 < model_space_size_z pref_show_grids = 0; // 0, 1, 2, 3, 5, 6, 10, 15, 30, etc // xyz, 0, x, y, z, xy, xz, yz, xyz - show_user_choices(arrows, arrows_nb, xxx, yyy, zzz, pref_show_grids, 1); + show_user_choices(arrows, arrows_nb, space_X, space_Y, space_Z, pref_show_grids, 1); } /* -------------------------------------------------------------------------- */ @@ -127,11 +127,11 @@ static bool rewrite_arrow (GLuint *arrows, int arrows_nb, int address, int weigh static bool create_arrow (GLuint *arrows, int arrows_nb, int weight, int site, int x, int y, int z) { - if (1) printf("creating the new arrow (%d, %d, %d, %d, %d)\n",\ + 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 * 2 * sizeof(GLuint)); + buffer_lines_origin = g_realloc(buffer_lines_origin, buffer_lines_size * sizeof(GLuint)); *(arrows + arrows_nb * 5 + 0) = weight; *(arrows + arrows_nb * 5 + 1) = site; @@ -139,8 +139,9 @@ static bool create_arrow (GLuint *arrows, int arrows_nb, int weight, int site, i *(arrows + arrows_nb * 5 + 3) = y; *(arrows + arrows_nb * 5 + 4) = z; - show_arrows_array(arrows, arrows_nb, -1, -1, weight, site, x, y, z); - printf("\nbuffer_lines_size = %d weight = %d site = %d x = %d y = %d z = %d ",\ + show_arrows_array(arrows, arrows_nb + 1, -1, -1, weight, site, x, y, z); + + printf("buffer_lines_size = %d\tarrow (%d, %d, %d, %d, %d) was created",\ buffer_lines_size, weight, site, x, y, z); return 1; @@ -175,7 +176,8 @@ static void show_arrows_array (GLuint *arrows, int arrows_nb, int address, int c 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 not found > new arrow will be created at line [%d]\n", buffer_lines_size, arrows_nb); + 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); @@ -822,27 +824,18 @@ void main_test_graphics (void) if (0) printf("buffer_vertex_offset_before_grid = %d\n", buffer_vertex_size / 3); // assert : l'emplacement des flèches est contraint -// par model_space_size_x, y, z et le nombre de sites. TODO -// assert : pas de doublons (une seule flèche max par site possible). TODO +// par model_space_size_x, y, z et le nombre de sites. TODO +// assert : pas de doublons (une seule flèche max par site). TODO GLuint arrows[] = { 1, 0, 0, 0, 0, - 1, 1, 0, 0, 0, // 1, 1, 0, 0, 0, -// 1, 0, 2, 0, 0, - /* 1, 1, 1, 0, 0, */ - /* 1, 1, 2, 0, 0, */ - /* 1, 1, 3, 0, 0, */ - /* 1, 0, 4, 0, 0, */ - /* 1, 1, 4, 0, 0, */ - /* 1, 1, 5, 0, 0, */ - /* 1, 1, 6, 0, 0, */ - /* 1, 1, 7, 0, 0, */ - /* 1, 0, 7, 0, 0, */ -// 1, 2, 0, 0, 0, -// 1, 3, 0, 0, 0, -// 1, 4, 0, 0, 0, -// 1, 5, 0, 0, 0, +// 1, 0, 1, 0, 0, +// 1, 1, 1, 0, 0, + 1, 0, 2, 0, 0, + 1, 1, 2, 0, 0, +// 1, 0, 3, 0, 0, + 1, 1, 3, 0, 0, // load, site, x, y, z }; @@ -850,16 +843,16 @@ void main_test_graphics (void) get_model_data_and_user_preferences(arrows, arrows_nb); long weight = 0, site = 0, - stx = zzz * yyy, sty = zzz, stz = 1, arrow_offset = 0; + stx = space_Z * space_Y, sty = space_Z, stz = 1, arrow_offset = 0; /* GRID */ - grid_write_intersections (xxx, yyy, zzz); + grid_write_intersections (space_X, space_Y, space_Z); - if (pref_show_grids % 2 == 0) grid_write_x (xxx, yyy, zzz); - if (pref_show_grids % 3 == 0) grid_write_y (xxx, yyy, zzz); - if (pref_show_grids % 5 == 0) grid_write_z (xxx, yyy, zzz); + 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 % 5 == 0) grid_write_z (space_X, space_Y, space_Z); - if (pref_show_grids > 0) grid_write_ridges (xxx, yyy, zzz); + 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; @@ -868,16 +861,16 @@ void main_test_graphics (void) /* ARROWS */ - arrows_write_terminations (xxx, yyy, zzz); // Independent of the number of arrows + arrows_write_terminations (space_X, space_Y, space_Z); // Independent of the number of arrows -// set_arrow (arrows, arrows_nb, 0, 0, 0, 0, 0); arrows_nb = sizeof(arrows) / sizeof(arrows[0]) / 5; // arrows_nb --; -// set_arrow (arrows, arrows_nb, 0, 0, 7, 0, 0); arrows_nb = sizeof(arrows) / sizeof(arrows[0]) / 5; // arrows_nb --; -// set_arrow (arrows, arrows_nb, 0, 1, 1, 0, 0); arrows_nb = sizeof(arrows) / sizeof(arrows[0]) / 5; // arrows_nb --; -// set_arrow (arrows, arrows_nb, 0, 1, 0, 0, 0); arrows_nb = sizeof(arrows) / sizeof(arrows[0]) / 5; // arrows_nb --; + set_arrow (arrows, arrows_nb, 0, 1, 2, 0, 0); arrows_nb --; + set_arrow (arrows, arrows_nb, 1, 1, 2, 0, 0); arrows_nb ++; +// set_arrow (arrows, arrows_nb, 0, 1, 1, 0, 0); arrows_nb --; +// set_arrow (arrows, arrows_nb, 0, 1, 0, 0, 0); arrows_nb --; -// set_arrow (arrows, arrows_nb, 1, 0, 5, 0, 0); arrows_nb = sizeof(arrows) / sizeof(arrows[0]) / 5; // arrows_nb ++; -// set_arrow (arrows, arrows_nb, 1, 1, 1, 0, 0); arrows_nb = sizeof(arrows) / sizeof(arrows[0]) / 5; // arrows_nb ++; -// set_arrow (arrows, arrows_nb, 1, 0, 0, 0, 0); arrows_nb = sizeof(arrows) / sizeof(arrows[0]) / 5; // arrows_nb ++; +// set_arrow (arrows, arrows_nb, 1, 0, 5, 0, 0); arrows_nb ++; +// set_arrow (arrows, arrows_nb, 1, 1, 1, 0, 0); arrows_nb ++; +// set_arrow (arrows, arrows_nb, 1, 0, 0, 0, 0); arrows_nb ++; for (int i = 0; i < arrows_nb; i++) { weight = arrows[i * 5 + 0]; @@ -900,15 +893,15 @@ void main_test_graphics (void) int offset_after_arrows = buffer_vertex_size / 3, difference = offset_after_arrows - offset_after_grids; - if (1) printf("\n buffer_vertex_offset_after grids = %6d\t%6d = (x+1)*(y+1)*(z+1); <--> (x,y,z = %d,%d,%d)",\ - offset_after_grids, (xxx + 1)*(yyy + 1)*(zzz + 1), xxx, yyy, zzz); - if (1) printf("\n buffer_vertex_offset_after arrows = %6d\t%6d = %d + %d; <--> %d = 12 x %d (there are %d cubes)",\ + if (1) printf("\n buffer_vertex_offset_after grids = %6d\t%6d = (x+1)*(y+1)*(z+1); <--> (x,y,z = %d,%d,%d)",\ + offset_after_grids, (space_X + 1)*(space_Y + 1)*(space_Z + 1), space_X, space_Y, space_Z); + if (1) printf("\n buffer_vertex_offset_after arrows = %6d\t%6d = %d + %d; <--> %d = 12 x %d (there are %d cubes)",\ offset_after_arrows, offset_after_arrows, offset_after_grids,\ difference, difference, difference / 12, difference / 12); - if (1) printf("\n buffer_lines_offset after cubes = %6d\t%6d = 2 * (%dx%d + %dx%d + %dx%d); <--> 2 * (x*y + x*z + y*z)",\ - buffer_lines_size_after_cubes, ((xxx+1) * (yyy+1) + (xxx+1) * (zzz+1) + (yyy+1) * (zzz+1)) * 2, - xxx+1, yyy+1, xxx+1, zzz+1, yyy+1, zzz+1); - if (1) printf("\n buffer_lines_offset after arrows = %6d\t%6d = %d + %d; <--> %d = (3 + 4) x 2 x %d (arrows_nb = %d)\n", buffer_lines_size,\ + if (1) printf("\n buffer_lines_offset after cubes = %6d\t%6d = 2 * (%dx%d + %dx%d + %dx%d); <--> 2 * (x*y + x*z + y*z)",\ + 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); + if (1) printf("\n buffer_lines_offset after arrows = %6d\t%6d = %d + %d; <--> %d = (3 + 4) x 2 x %d (arrows_nb = %d)\n", 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);