From 53784a02bf54c75d3c9a243a31e9b4c10b33afc7 Mon Sep 17 00:00:00 2001 From: Jean Sirmai Date: Tue, 4 Jul 2023 20:07:21 +0200 Subject: [PATCH] =?UTF-8?q?WIP:=20=C3=87a=20s'all=C3=A8ge.=20Il=20y=20a=20?= =?UTF-8?q?plus=20de=20choses=20qui=20marchent=20que=20l'inverse=20!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/buffers.h | 7 +- src/graphics/buffers.c | 166 ++++++++++++++++------------------------ src/graphics/graphics.c | 21 +++-- 3 files changed, 74 insertions(+), 120 deletions(-) diff --git a/include/buffers.h b/include/buffers.h index 4cbc4fd..96bcc0e 100644 --- a/include/buffers.h +++ b/include/buffers.h @@ -42,11 +42,6 @@ bool compute_space_and_arrows(int model_space_size_x, GLfloat *vertex_origin, GLfloat *color_origin, GLubyte *line_origin, - GLubyte *plan_origin, - - int buffer_vertex_size, - int buffer_colors_size, - int buffer_lines_size, - int buffer_plans_size); + GLubyte *plan_origin); diff --git a/src/graphics/buffers.c b/src/graphics/buffers.c index cce78b6..e1ad0ff 100644 --- a/src/graphics/buffers.c +++ b/src/graphics/buffers.c @@ -191,12 +191,7 @@ static int compute_arrow_2D(int space_size_x, GLfloat *vertex_origin, GLfloat *color_origin, GLubyte *line_origin, - GLubyte *plan_origin, - - int buffer_vertex_size, - int buffer_colors_size, - int buffer_lines_size, - int buffer_plans_size) + GLubyte *plan_origin) { printf("compute_arrow_2D load = %d site = %d x = %d\n", weight, site, x); float zero = 0.0f; @@ -442,12 +437,7 @@ static bool compute_arrow_3D(int space_size_x, GLfloat *vertex_origin, GLfloat *color_origin, GLubyte *line_origin, - GLubyte *plan_origin, - - int buffer_vertex_size, - int buffer_colors_size, - int buffer_lines_size, - int buffer_plans_size) + GLubyte *plan_origin) { float zero = 0.0f; @@ -455,9 +445,6 @@ static bool compute_arrow_3D(int space_size_x, float tip = center + (2 * site - 1) * (1.0f / space_size_x); float base = center + (2 * site - 1) * (0.1f / space_size_x); - if (A3) printf("arrow_3D (vertices %d to %d) ",\ - (buffer_vertex_size + space_size_x * 12 - 15), (buffer_vertex_size + space_size_x * 12)); - *(vertex_origin + space_size_x * 12 + 0) = center + (2 * site - 1) * (1.0f / space_size_x - 0.01f); *(vertex_origin + space_size_x * 12 + 1) = zero; *(vertex_origin + space_size_x * 12 + 2) = zero; @@ -549,12 +536,7 @@ static void show_user_choices(int model_space_size_x, int pref_3D_xor_2D_arrows, int pref_mark_unit_space, int pref_style_lines_planes, - int pref_style_mix_colors, - - int buffer_vertex_size, - int buffer_colors_size, - int buffer_lines_size, - int buffer_plans_size) + int pref_style_mix_colors) { printf("model + user constraints : x,y,z = (%d, %d, %d) ", model_space_size_x, model_space_size_y, model_space_size_z); if (pref_3D_xor_2D_space == 0) printf("3D space "); @@ -570,11 +552,12 @@ static void show_user_choices(int model_space_size_x, if (pref_style_lines_planes > 0)printf("style_lines_planes = %d ", pref_style_lines_planes); if (! pref_style_mix_colors) printf("style_mix_colors = 0 "); if (pref_style_mix_colors > 0) printf("style_mix_colors = %d ", pref_style_mix_colors); - printf("\n----------------- alloc : %4d/3 = %3d vertices, %4d/3 = %3d colors,\ - %4d/2 = %3d lines, %4d/3 = %3d plans\n[ n] load site x ---- < arrows array >\ - ----------------------------------------------------------------------\n", - buffer_vertex_size, buffer_vertex_size / 3, buffer_colors_size, buffer_colors_size / 3, - buffer_lines_size, buffer_lines_size / 2, buffer_plans_size, buffer_plans_size / 3); + printf("\n[ n] load site x ---- < arrows array >\ + ----------------------------------------------------------------------\n"); + // arrows = { 1, 1, 0, 1, 2, 1, 1, 1, 10, 1, 2, 11, 1, 1, 20, 1, 2, 21 } + if (SA) for (int i = 0; i < model_arrows_nb; i++) + printf("[%2d] = %2d, %2d, %2d \n",\ + i, *(arrows + i * 3), *(arrows + i * 3 + 1), *(arrows + i * 3 + 2)); } bool compute_space_and_arrows(int model_space_size_x, @@ -593,12 +576,7 @@ bool compute_space_and_arrows(int model_space_size_x, GLfloat *vertex_origin, GLfloat *color_origin, GLubyte *line_origin, - GLubyte *plan_origin, - - int buffer_vertex_size, - int buffer_colors_size, - int buffer_lines_size, - int buffer_plans_size) + GLubyte *plan_origin) { if (SA) show_user_choices(model_space_size_x, @@ -612,90 +590,74 @@ bool compute_space_and_arrows(int model_space_size_x, pref_3D_xor_2D_arrows, pref_mark_unit_space, pref_style_lines_planes, - pref_style_mix_colors, + pref_style_mix_colors); - buffer_vertex_size, - buffer_colors_size, - buffer_lines_size, - buffer_plans_size); + if (pref_3D_xor_2D_space) compute_space_2D ( + model_space_size_x, + model_space_size_y, + model_space_size_z, - if (pref_3D_xor_2D_space) compute_space_2D (model_space_size_x, - model_space_size_y, - model_space_size_z, + pref_mark_unit_space, + pref_style_lines_planes, + pref_style_mix_colors, - pref_mark_unit_space, - pref_style_lines_planes, - pref_style_mix_colors, + vertex_origin, + color_origin, + line_origin, + plan_origin); - vertex_origin, - color_origin, - line_origin, - plan_origin); + else compute_space_3D ( + model_space_size_x, + model_space_size_y, + model_space_size_z, - else compute_space_3D (model_space_size_x, - model_space_size_y, - model_space_size_z, + pref_mark_unit_space, + pref_style_lines_planes, + pref_style_mix_colors, - pref_mark_unit_space, - pref_style_lines_planes, - pref_style_mix_colors, + vertex_origin, + color_origin, + line_origin, + plan_origin); - vertex_origin, - color_origin, - line_origin, - plan_origin); + for (int i = 0; i < model_arrows_nb; i++) + if (pref_3D_xor_2D_arrows) compute_arrow_2D( + model_space_size_x, + model_space_size_y, + model_space_size_z, + *(arrows + i * 3 + 0), // weight + *(arrows + i * 3 + 1), // site + *(arrows + i * 3 + 2), // x + 0, // y + 0, // z - // arrows = { 1, 1, 0, 1, 2, 1, 1, 1, 10, 1, 2, 11, 1, 1, 20, 1, 2, 21 } - if (SA) for (int i = 0; i < model_arrows_nb; i++) - printf("[%2d] = %2d, %2d, %2d \n",\ - i, *(arrows + i * 3), *(arrows + i * 3 + 1), *(arrows + i * 3 + 2)); + pref_style_lines_planes, + pref_style_mix_colors, - for (int i = 0; i < model_arrows_nb; i++) if (pref_3D_xor_2D_arrows) compute_arrow_2D(model_space_size_x, - model_space_size_y, - model_space_size_z, + vertex_origin, + color_origin, + line_origin, + plan_origin); - *(arrows + i * 3 + 0), // weight - *(arrows + i * 3 + 1), // site - *(arrows + i * 3 + 2), // x - 0, // y - 0, // z + else compute_arrow_3D( + model_space_size_x, + model_space_size_y, + model_space_size_z, - pref_style_lines_planes, - pref_style_mix_colors, + *(arrows + i * 3 + 0), // weight + *(arrows + i * 3 + 1), // site + *(arrows + i * 3 + 2), // x + 0, // y + 0, // z - vertex_origin, - color_origin, - line_origin, - plan_origin, + pref_style_lines_planes, + pref_style_mix_colors, - buffer_vertex_size, - buffer_colors_size, - buffer_lines_size, - buffer_plans_size); - - else compute_arrow_3D(model_space_size_x, - model_space_size_y, - model_space_size_z, - - *(arrows + i * 3 + 0), // weight - *(arrows + i * 3 + 1), // site - *(arrows + i * 3 + 2), // x - 0, // y - 0, // z - - pref_style_lines_planes, - pref_style_mix_colors, - - vertex_origin, - color_origin, - line_origin, - plan_origin, - - buffer_vertex_size, - buffer_colors_size, - buffer_lines_size, - buffer_plans_size); + vertex_origin, + color_origin, + line_origin, + plan_origin); return 0; } diff --git a/src/graphics/graphics.c b/src/graphics/graphics.c index 51dad7a..f61e019 100644 --- a/src/graphics/graphics.c +++ b/src/graphics/graphics.c @@ -527,11 +527,11 @@ GLubyte arrows[] = { 1, 1, 0, 1, 0, 1, 1, 1, 4, 1, 0, 5, 1, 1, 8, 1, 0, 9 static void get_model_data_and_user_preferences(){ model_space_size_x = 11; // 2 < model_space_size_x < 32 - model_arrows_nb = 6; // assert : l'emplacement des flèches est contraint + model_arrows_nb = 1; // assert : l'emplacement des flèches est contraint // par model_space_size_x, y, z et le nombre de sites - pref_3D_xor_2D_space = 0; // 0 = 3D 1 = 2D + pref_3D_xor_2D_space = 1; // 0 = 3D 1 = 2D pref_3D_xor_2D_arrows = 0; // 0 = 3D 1 = 2D - pref_mark_unit_space = 3; // 0 = no marks, 1 = 1st, 2 = last, 3 = both + pref_mark_unit_space = 2; // 0 = no marks, 1 = 1st, 2 = last, 3 = both pref_style_lines_planes = 0; // 0 = arrows as lines, 1 = as planes, 2 = mix pref_style_mix_colors = 0; // TODO } @@ -557,7 +557,7 @@ static void get_model_data_and_user_preferences(){ - +#define S 1 static void compute_buffers_sizes(int model_space_size_x, int model_space_size_y, int model_space_size_z, @@ -593,8 +593,10 @@ static void compute_buffers_sizes(int model_space_size_x, /* buffer_plans_size est fonction de : model_space_size_x, model_arrows_nb et de pref_style_lines_planes */ - if (0) printf("graphics.buffers_sizes : %u vertices, %u colors, %u lines, %u plans. (space_size_x = %d)\n", - buffer_vertex_size, buffer_colors_size, buffer_lines_size, buffer_plans_size, model_space_size_x); + if (S) printf("allocated buffers sizes :%4d/3 = %3d vertices, %4d/3 = %3d colors,\ + %4d/2 = %3d lines, %4d/3 = %3d plans. (space_size_x = %d)\n", + buffer_vertex_size, buffer_vertex_size / 3, buffer_colors_size, buffer_colors_size / 3, + buffer_lines_size, buffer_lines_size / 2, buffer_plans_size, buffer_plans_size / 3, model_space_size_x); } @@ -647,12 +649,7 @@ void graphics_init_buffers(const void *gl_area) buffer_vertex_origin, buffer_colors_origin, buffer_lines_origin, - buffer_plans_origin, - - buffer_vertex_size, - buffer_colors_size, - buffer_lines_size, - buffer_plans_size); + buffer_plans_origin); GLuint vao, vertex_buffer, color_buffer;