From 214eebc3787ea79564e8a245f19f77d1a72ca8b2 Mon Sep 17 00:00:00 2001 From: Jean Sirmai Date: Sun, 5 Nov 2023 17:34:25 +0100 Subject: [PATCH] =?UTF-8?q?WIP:=20une=20erreur=20sur=20la=20position=20x?= =?UTF-8?q?=20=3F=20Commentaires=20=C3=A0=20voir?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/graphics/graphics.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/graphics/graphics.c b/src/graphics/graphics.c index cd9b25a..746f294 100644 --- a/src/graphics/graphics.c +++ b/src/graphics/graphics.c @@ -36,6 +36,7 @@ #define FRAG_SHADER_FILE "src/shaders/shader.frag" static struct arrow_t *arrows_ptr; +static GLuint *address_ptr; GLfloat *buffer_vertex_origin = NULL; GLfloat *buffer_colors_origin = NULL; @@ -697,6 +698,8 @@ static inline int set_arrow (struct arrow_t *arrows_ptr, int arrows_nb, int spac if (console) printf("in set_arrow (begin) arrows_nb = %d requested site: %d > ", arrows_nb, site); /* if (console) for (int i = 0; i < arrows_nb; i++) {printf(" [%d] = %d ", i, arrows_ptr[i].site); if (site == arrows_ptr[i].site) break;} */ + if (0) printf("In set_arrow() address_ptr \n"); + for (int i = 0; i < arrows_nb; i++) if ((site == arrows_ptr[i].site) && (arrow_x == arrows_ptr[i].x) @@ -758,7 +761,7 @@ void main_test_graphics (void) srand(time(NULL)); int rand(void); void srand(unsigned int seed); - int randomize = 0, console = 0, arrows_nb = 0, space_X = 1, space_Y = 1, space_Z = 1; + int randomize = 80, console = 0, arrows_nb = 0, space_X = 1, space_Y = 1, space_Z = 1; if (randomize) { space_X = 1 + rand() % randomize; space_Y = 1 + rand() % randomize; @@ -767,6 +770,9 @@ void main_test_graphics (void) int density_max = space_X * space_Y * space_Z, specified_arrows_nb = density_max; /* int max = fmax(space_X, space_Y); max = fmax(max, space_Z); */ + int sites_nb = 6; + address_ptr = g_malloc(space_X * space_Y * space_Z * sites_nb); + /*------------------------------------------------------------------------*/ @@ -819,15 +825,15 @@ void main_test_graphics (void) /* else for (int i = 0; i < 6; i++) */ /* arrows_nb = set_arrow (arrows_ptr, arrows_nb, 1, 1, 1, 0, i, 0, 0, 0, 0); */ - /* int angle = 9; */ - /* if (space_X > angle && space_Y > angle && space_Z > angle) for (int i = 0; i < angle; i++) */ - /* for (int u = 0; u < angle; u++) for (int v = 0; v < angle; v++) for (int w = 0; w < angle; w++) */ - /* if (u + v + w < angle * 3) */ - /* arrows_nb = set_arrow (arrows_ptr, arrows_nb, 1, 1, 1, 0, i, u, v, w, 0); */ + int angle = 9; + if (space_X > angle && space_Y > angle && space_Z > angle) for (int i = 0; i < angle; i++) + for (int u = 0; u < angle; u++) for (int v = 0; v < angle; v++) for (int w = 0; w < angle; w++) + if (u + v + w < angle * 3) + arrows_nb = set_arrow (arrows_ptr, arrows_nb, 1, 1, 1, 0, i, u, v, w, 0); - /* if (space_X > angle && space_Y > angle && space_Z > angle) */ - /* printf("+ effacement des flèches dans l'angle-origine\ */ - /* <=> contrôle graphique de la fonction erase_arrow()\n"); */ + if (space_X > angle && space_Y > angle && space_Z > angle) + printf("+ effacement des flèches dans l'angle-origine\ + <=> contrôle graphique de la fonction erase_arrow()\n"); if (1) print_user_choices(arrows_ptr, max_arrows_nb, arrows_nb, space_X, space_Y, space_Z, 0, 0);