diff --git a/include/arrows.h b/include/arrows.h index 98ac46d..5857feb 100644 --- a/include/arrows.h +++ b/include/arrows.h @@ -37,7 +37,7 @@ void arrows_write_terminations (long x, long y, long z); /* - * Writes lines for arrow oriented to the east into lines buffer + * Writes lines for arrow oriented to the east or west into lines buffer * * @param s, * weight, @@ -45,10 +45,10 @@ void arrows_write_terminations (long x, long y, long z); * * @return void */ -void write_arrow_lines_east (long s, int weight, int site); +void write_arrow_lines_east_west (long s, int weight, int site); /* - * Writes lines for arrow oriented to the west into lines buffer + * Writes lines for arrow oriented to the zenith or nadir into lines buffer * * @param s, * weight, @@ -56,10 +56,10 @@ void write_arrow_lines_east (long s, int weight, int site); * * @return void */ -void write_arrow_lines_west (long s, int weight, int site); +void write_arrow_lines_zenith_nadir (long s, int weight, int site); /* - * Writes lines for arrow oriented to the zenith into lines buffer + * Writes lines for arrow oriented to the south or north into lines buffer * * @param s, * weight, @@ -67,47 +67,12 @@ void write_arrow_lines_west (long s, int weight, int site); * * @return void */ -void write_arrow_lines_zenith (long s, int weight, int site); +void write_arrow_lines_south_north (long s, int weight, int site); /* - * Writes lines for arrow oriented to the nadir into lines buffer + * Writes the three lines that draw arrow basis (central star) into lines buffer * - * @param s, - * weight, - * site - * - * @return void - */ -void write_arrow_lines_nadir (long s, int weight, int site); - -/* - * Writes lines for arrow oriented to the south into lines buffer - * - * @param s, - * weight, - * site - * - * @return void - */ -void write_arrow_lines_south (long s, int weight, int site); - -/* - * Writes lines for arrow oriented to the north into lines buffer - * - * @param s, - * weight, - * site - * - * @return void - */ -void write_arrow_lines_north (long s, int weight, int site); - -/* - * Writes lines for arrow basis into lines buffer - * - * @param n, - * weight, - * site + * @param n * * @return void */ diff --git a/src/graphics/graphics.c b/src/graphics/graphics.c index 678e445..a265476 100644 --- a/src/graphics/graphics.c +++ b/src/graphics/graphics.c @@ -32,16 +32,6 @@ #define VERTEX_SHADER_FILE "src/shaders/shader.vert" #define FRAG_SHADER_FILE "src/shaders/shader.frag" -static GLuint arrows[] = { - 1, 0, 3, 2, 1, - 1, 1, 3, 2, 1, - 1, 2, 3, 2, 1, - 1, 3, 3, 2, 1, - 1, 4, 3, 2, 1, - 1, 5, 3, 2, 1, -// load, site, x, y, z -}; - static int model_space_size_x = 0; static int model_space_size_y = 0; static int model_space_size_z = 0; @@ -58,14 +48,87 @@ static volatile int buffer_vertex_size = 0; static int buffer_colors_size = 0; static int buffer_lines_size = 0; static int buffer_plans_size = 0; + +// assert : l'emplacement des flèches est contraint +// par model_space_size_x, y, z et le nombre de sites +static GLuint arrows[] = { + 1, 0, 1, 0, 0, + 1, 1, 1, 0, 0, + 1, 2, 1, 0, 0, + 1, 3, 1, 0, 0, + 1, 4, 1, 0, 0, + 1, 5, 1, 0, 0, +// load, site, x, y, z +}; + +static void show_user_choices(long space_size_x, + long space_size_y, + long space_size_z, + GLuint *arrows, + int prefer) +{ + int arrows_nb = 3 * sizeof(arrows) / sizeof(arrows[0]); + printf("model + user constraints : space size x,y,z = %ld,%ld,%ld ", space_size_x, space_size_y, space_size_z); + if (arrows_nb > 0) printf("[%d] arrows ", 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("pref_show_grids = %d ", prefer); + if (arrows_nb == 0) printf("\tbuffer_vertex_size = %d\t lines = %d\n", buffer_vertex_size, buffer_lines_size); + if (arrows_nb > 0) printf("\n--- < arrows array >\ + ---\n[ n] load site x y z \n-----------------------------\n"); + for (int i = 0; i < arrows_nb; i++) printf("[%2d] = %2d, %2d, %2d, %2d, %2d \n",\ + i, *(arrows + i * 5 + 0), *(arrows + i * 5 + 1), *(arrows + i * 5 + 2), *(arrows + i * 5 + 3), *(arrows + i * 5 + 4)); +} + +static void get_model_data_and_user_preferences() +{ + model_space_size_x = 3; // 0 < model_space_size_x + model_space_size_y = 1; // 0 < model_space_size_y + model_space_size_z = 1; // 0 < model_space_size_z + central_stars_nb = sizeof(arrows) / sizeof(arrows[0]); + 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(model_space_size_x, model_space_size_y, model_space_size_z, + arrows, pref_show_grids); +} + +/* -------------------------------------------------------------------------- */ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + /* * Dynamic array of ptrs to dynamically allocated gl_area_entry */ struct gl_area_entry **gl_area_array = NULL; -/* -------------------------------------------------------------------------- */ - /* * Prints verbose human-readable debug messages * @@ -127,59 +190,6 @@ static void graphics_debug_callback(GLenum source, GLenum type, GLuint id, /* -------------------------------------------------------------------------- */ -/* - * DEBUG - * - */ -static void show_user_choices(long space_size_x, - long space_size_y, - long space_size_z, - GLuint *arrows, - int prefer) -{ - int arrows_nb = 3 * sizeof(arrows) / sizeof(arrows[0]); - printf("model + user constraints : space size x,y,z = %ld,%ld,%ld ", space_size_x, space_size_y, space_size_z); - if (arrows_nb > 0) printf("[%d] arrows ", arrows_nb); - if (prefer == 1) printf("prefer = %d <> show no grid ", prefer); - if (prefer == 0) printf("prefer = %d <> show all grids ", prefer); - if (prefer == 2) printf("prefer = %d <> show grid xy ", prefer); - if (prefer == 3) printf("prefer = %d <> show grid xz ", prefer); - if (prefer == 5) printf("prefer = %d <> show grid yz ", prefer); - if (prefer == 6) printf("prefer = %d <> show grids xy & xz ", prefer); - if (prefer == 10) printf("prefer = %d <> show grids xy & yz ", prefer); - if (prefer == 15) printf("prefer = %d <> show grids xz & yz ", prefer); - if (arrows_nb == 0) printf("\tbuffer_vertex_size = %d\t lines = %d\n",\ - buffer_vertex_size, buffer_lines_size); - if (arrows_nb > 0) printf("\n--- < arrows array >\ - ---\n[ n] load site x y z \n-----------------------------\n"); - for (int i = 0; i < arrows_nb; i++) - printf("[%2d] = %2d, %2d, %2d, %2d, %2d \n",\ - i, *(arrows + i * 5 + 0), *(arrows + i * 5 + 1), *(arrows + i * 5 + 2), *(arrows + i * 5 + 3), *(arrows + i * 5 + 4)); -} - -static void get_model_data_and_user_preferences() -{ - model_space_size_x = 7; // 0 < model_space_size_x - model_space_size_y = 5; // 0 < model_space_size_y - model_space_size_z = 3; // 0 < model_space_size_z - // assert : l'emplacement des flèches est contraint - // par model_space_size_x, y, z et le nombre de sites - - central_stars_nb = 0; // à calculer TODO - // ! WARNING ! Pour l'instant égal au nombre de flèches ! (central stars réécrites) - central_stars_nb = sizeof(arrows) / sizeof(arrows[0]); - - 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(model_space_size_x, model_space_size_y, model_space_size_z, - arrows, pref_show_grids); - - -} - -/* -------------------------------------------------------------------------- */ - /* * Writes values to describe a line from a to b into the line buffer * @@ -625,10 +635,9 @@ void main_test_graphics (void) stz = 1; long arrow_offset = 0; - printf("offset_before_grid = %d\n", buffer_vertex_size / 3); + if (0) printf("buffer_vertex_offset_before_grid = %d\n", buffer_vertex_size / 3); /* GRID */ - grid_write_intersections (x, y, z); if (pref_show_grids % 2 == 0) grid_write_x (x, y, z); @@ -639,12 +648,12 @@ void main_test_graphics (void) int offset_after_grid = buffer_vertex_size / 3; - printf("offset_after_ grid = %d\n", offset_after_grid); + if (1) printf("buffer_vertex_offset_after_ grid = %d\n", offset_after_grid); /* ARROWS */ arrows_write_terminations (x, y, z); - int arrows_nb_ad_hoc = 6; // 3 * sizeof(arrows) / sizeof(arrows[0]) ??? + int arrows_nb_ad_hoc = 6; // 3 * sizeof(arrows) / sizeof(arrows[0]) ??? TODO for (int i = 0; i < arrows_nb_ad_hoc; i++) { site = arrows[i * 5 + 1]; @@ -664,7 +673,10 @@ void main_test_graphics (void) } } - printf("main_test_graphics [ok]\n"); + // TODO Qu'est-ce que j'affiche, là ?! < À vérifier + if (1) printf("buffer_vertex_offset_after arrows = %d\n", offset_after_grid + arrows_nb_ad_hoc * 12); + if (0) printf("main_test_graphics [ok]\n"); } + diff --git a/src/main.c b/src/main.c index da36c5e..6e1cc88 100644 --- a/src/main.c +++ b/src/main.c @@ -36,8 +36,8 @@ int main(int argc, char **argv) int res; // bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); - // bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); - // textdomain (GETTEXT_PACKAGE); + // bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); + // textdomain (GETTEXT_PACKAGE); app = gem_graph_client_application_new("org.alec.gemgraph", G_APPLICATION_DEFAULT_FLAGS);