From 98e95abbd68b59460f7d4449efc93a0e18890c64 Mon Sep 17 00:00:00 2001 From: Jean Sirmai Date: Wed, 27 Sep 2023 09:10:14 +0200 Subject: [PATCH] =?UTF-8?q?WIP:=20un=20peu=20de=20nettoyage=20et=20de=20co?= =?UTF-8?q?sm=C3=A9tique=20avant=20de=20commencer=20le=20travail=20s=C3=A9?= =?UTF-8?q?rieux?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/graphics/graphics.c | 135 +++++++++++++--------------------------- 1 file changed, 42 insertions(+), 93 deletions(-) diff --git a/src/graphics/graphics.c b/src/graphics/graphics.c index 90891fb..581e666 100644 --- a/src/graphics/graphics.c +++ b/src/graphics/graphics.c @@ -42,75 +42,11 @@ static volatile int buffer_lines_size = 0; static volatile int buffer_colors_size = 0; static volatile int buffer_plans_size = 0; - -// model_data_and_user_preferences : - 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 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, - int prefer, int show_all) -{ - printf("model + user constraints :\tspace size x,y,z = %d,%d,%d\t", space_size_x, space_size_y, space_size_z); - if (prefer == 0) printf("prefer = %d <> show all grids", prefer); - if (prefer == 1) printf("prefer = %d <> show no grid", prefer); - if (prefer > 1) printf("pref_show_grids = %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 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 -------------------------------\n");} -} - -static void get_model_data_and_user_preferences(GLuint *arrows, int arrows_nb) -{ - 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, space_X, space_Y, space_Z, pref_show_grids, 1); -} - -/* -------------------------------------------------------------------------- */ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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); @@ -819,29 +755,48 @@ bool graphics_shutdown(const void *gl_area) /* -------------------------------------------------------------------------- */ +static void show_user_choices(GLuint *arrows, int arrows_nb, + int space_size_x, int space_size_y, int space_size_z, + int prefer, int show_all) +{ + printf("model + user constraints :\tspace size x,y,z = %d,%d,%d\t", space_size_x, space_size_y, space_size_z); + if (prefer == 0) printf("prefer = %d <> show all grids", prefer); + if (prefer == 1) printf("prefer = %d <> show no grid", prefer); + if (prefer > 1) printf("pref_show_grids = %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 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 -------------------------------\n");} +} + 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). TODO +// assert : space dimensions (x,y,z) > 0 TODO +// assert : arrows localization within space and sites TODO +// assert : no more than one arrow per address TODO + space_X = 4; space_Y = 1; space_Z = 1; + 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[] = { 1, 0, 0, 0, 0, -// 1, 1, 0, 0, 0, -// 1, 0, 1, 0, 0, -// 1, 1, 1, 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 }; int arrows_nb = sizeof(arrows) / sizeof(arrows[0]) / 5; - get_model_data_and_user_preferences(arrows, arrows_nb); + show_user_choices(arrows, arrows_nb, space_X, space_Y, space_Z, pref_show_grids, 1); + long weight = 0, site = 0, stx = space_Z * space_Y, sty = space_Z, stz = 1, arrow_offset = 0; @@ -861,16 +816,13 @@ void main_test_graphics (void) /* ARROWS */ - arrows_write_terminations (space_X, space_Y, space_Z); // Independent of the number of arrows + /* The 12 vertices required to draw 6 arrows in each cube + * are always defined (whether arrows are drawn or not). */ - 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 --; + arrows_write_terminations (space_X, space_Y, space_Z); +// set_arrow (arrows, arrows_nb, 0, 0, 0, 0, 0); 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]; @@ -881,6 +833,7 @@ void main_test_graphics (void) 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); switch(site){ @@ -893,20 +846,16 @@ 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, (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,\ + 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); + 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, ((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); - - if (0) printf("main_test_graphics [ok]\n"); + 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); + 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); } - -