diff --git a/src/graphics/arrows.c b/src/graphics/arrows.c index 9fde53b..bf5fe84 100644 --- a/src/graphics/arrows.c +++ b/src/graphics/arrows.c @@ -72,11 +72,11 @@ int write_one_arrow_vertex (int space_X_int, int space_Y_int, int space_Z_int, break; case SOUTH: graphics_write_vertex (vx, vy, vz - (site % 2 - 1) * (1 / max) + (site % 2 - 1) * arrow_tip_padding, print); - graphics_write_color(0.05f, 0.4f, 1.0f); + graphics_write_color(1.0f, 1.0f, 0.0f); break; case NORTH: graphics_write_vertex (vx, vy, vz - (site % 2) * (1 / max) + (site % 2) * arrow_tip_padding, print); - graphics_write_color(1.0f, 1.0f, 0.0f); + graphics_write_color(0.05f, 0.4f, 1.0f); break; default: break; } diff --git a/src/graphics/displays.c b/src/graphics/displays.c index f814201..e5732a3 100644 --- a/src/graphics/displays.c +++ b/src/graphics/displays.c @@ -350,7 +350,7 @@ static void print_one_arrow_in_buffers (struct arrow_t *arrows, GLfloat *buffer_lines_origin, long buffer_lines_0_arrow, int i, int arrows_nb, int address) { - printf(" [%4d] = %2d | %2d, %2d, %2d, %2d, (%2d) %6.2f %6.2f %6.2f %6.2f %6.2f %6.2f %4d %4d\n",\ + printf(" [%4d] = %2d | %2d, %2d, %2d, %2d, (%2d) %6.2f %6.2f %6.2f %6.2f %6.2f %6.2f %4f %4f\n",\ i, arrows[i].load, arrows[i].site, arrows[i].x, arrows[i].y, arrows[i].z, address, diff --git a/src/graphics/graphics.c b/src/graphics/graphics.c index 86c26dc..c06f371 100644 --- a/src/graphics/graphics.c +++ b/src/graphics/graphics.c @@ -42,13 +42,13 @@ GLuint *buffer_lines_origin = NULL; GLuint *buffer_plans_origin = NULL; volatile long buffer_vertex_size = 0; -volatile long buffer_lines_size = 0; volatile long buffer_colors_size = 0; +volatile long buffer_lines_size = 0; volatile long buffer_plans_size = 0; volatile long buffer_vertex_0_arrow = 0; -volatile long buffer_lines_0_arrow = 0; volatile long buffer_colors_0_arrow = 0; +volatile long buffer_lines_0_arrow = 0; volatile long buffer_plans_0_arrow = 0; #define TEST 0 @@ -649,23 +649,6 @@ static inline int erase_arrow (int arrows_nb, int arrow_address_in_list, assert (arrows_nb); arrows_nb --; - void *new_arrows_vertex_ptr = g_realloc(buffer_vertex_origin, buffer_vertex_size * sizeof(GLfloat)); - if (new_arrows_vertex_ptr) buffer_vertex_origin = new_arrows_vertex_ptr; - else perror("In graphics.erase_arrow(), can't re_allocate for arrows vertex buffer.\n"); - - void *new_arrows_colors_ptr = g_realloc(buffer_colors_origin, buffer_colors_size * sizeof(GLfloat)); - if (new_arrows_colors_ptr) buffer_colors_origin = new_arrows_colors_ptr; - else perror("In graphics.erase_arrow(), can't re_allocate for arrows colors buffer.\n"); - - buffer_vertex_size -= 6; // <<< l'inverse de ce qui est fait dans : graphics_write_vertex() - buffer_colors_size -= 6; // <<< l'inverse de ce qui est fait dans : graphics_write_colors() - buffer_lines_size -= 2; // <<< l'inverse de ce qui est fait dans : graphics_write_line() - - /* Il ne faut pas réécrire ce qui suit: ces lignes dessinent maintenant à partir d'autres vertex */ - /* void *new_arrows_lines_ptr = g_realloc(buffer_lines_origin, buffer_lines_size * sizeof(GLfloat)); */ - /* if (new_arrows_lines_ptr) buffer_lines_origin = new_arrows_lines_ptr; */ - /* else perror("In graphics.erase_arrow(), can't re_allocate for arrows lines buffer.\n"); */ - if (arrow_address_in_list < arrows_nb) { int mem = arrows_ptr[arrow_address_in_list].site; @@ -685,10 +668,27 @@ static inline int erase_arrow (int arrows_nb, int arrow_address_in_list, for (long i = 0 + arrow_address_in_list * 6; i < 6 + arrow_address_in_list * 6; i++) buffer_vertex_origin [buffer_vertex_0_arrow + i] = buffer_vertex_origin [buffer_vertex_size - 6 + i]; - for (long i = 0; i < 6; i++) + for (long i = 0 + arrow_address_in_list * 6; i < 6 + arrow_address_in_list * 6; i++) buffer_colors_origin [buffer_colors_0_arrow + i] = buffer_colors_origin [buffer_colors_size - 6 + i]; } + buffer_vertex_size -= 6; // <<< l'inverse de ce qui est fait dans : graphics_write_vertex() + buffer_colors_size -= 6; // <<< l'inverse de ce qui est fait dans : graphics_write_colors() + buffer_lines_size -= 2; // <<< l'inverse de ce qui est fait dans : graphics_write_line() + + void *new_arrows_vertex_ptr = g_realloc(buffer_vertex_origin, buffer_vertex_size * sizeof(GLfloat)); + if (new_arrows_vertex_ptr) buffer_vertex_origin = new_arrows_vertex_ptr; + else perror("In graphics.erase_arrow(), can't re_allocate for arrows vertex buffer.\n"); + + void *new_arrows_colors_ptr = g_realloc(buffer_colors_origin, buffer_colors_size * sizeof(GLfloat)); + if (new_arrows_colors_ptr) buffer_colors_origin = new_arrows_colors_ptr; + else perror("In graphics.erase_arrow(), can't re_allocate for arrows colors buffer.\n"); + + /* Il ne faut pas réécrire ce qui suit: ces lignes dessinent maintenant à partir d'autres vertex */ + /* void *new_arrows_lines_ptr = g_realloc(buffer_lines_origin, buffer_lines_size * sizeof(GLfloat)); */ + /* if (new_arrows_lines_ptr) buffer_lines_origin = new_arrows_lines_ptr; */ + /* else perror("In graphics.erase_arrow(), can't re_allocate for arrows lines buffer.\n"); */ + if (1) print_arrows_array (arrows_ptr, arrows_nb, 0); return arrows_nb; @@ -749,6 +749,7 @@ void main_test_graphics (void) write_grids_on_space_faces_lines (buffer_lines_size, space_X, space_Y, space_Z); buffer_vertex_0_arrow = buffer_vertex_size; + buffer_colors_0_arrow = buffer_colors_size; buffer_lines_0_arrow = buffer_lines_size; /* A R R O W S */ @@ -776,7 +777,7 @@ void main_test_graphics (void) rand() % space_Z, // z console); else for (int i = 0; i < 1; i++) - arrows_nb = set_arrow (arrows_ptr, arrows_nb, 1, 1, 1, 0, i, 0, 0, 0, 0); + arrows_nb = set_arrow (arrows_ptr, arrows_nb, 1, 1, 1, 0, i, 0, 0, 0, 1); if (randomize) print_user_choices(arrows_ptr, max_arrows_nb, arrows_nb, space_X, space_Y, space_Z, 1, 0);