From 5b9fae0db5c3c9cc9c10cee9be05d82bf71d4551 Mon Sep 17 00:00:00 2001 From: Jean Sirmai Date: Sun, 10 Sep 2023 16:34:13 +0200 Subject: [PATCH] WIP: avant rebase --- src/graphics/graphics.c | 126 ++++++++++++++-------------------------- src/graphics/grid.c | 47 ++++++--------- src/shaders/shader.vert | 4 +- 3 files changed, 65 insertions(+), 112 deletions(-) diff --git a/src/graphics/graphics.c b/src/graphics/graphics.c index 5077374..64e0653 100644 --- a/src/graphics/graphics.c +++ b/src/graphics/graphics.c @@ -33,46 +33,12 @@ #define FRAG_SHADER_FILE "src/shaders/shader.frag" static GLuint arrows[] = { - 1, 0, 1, 2, 4, - 1, 1, 1, 2, 4, - 1, 2, 1, 2, 4, - 1, 3, 1, 2, 4, - 1, 4, 1, 2, 4, - 1, 5, 1, 2, 4, - - 1, 1, 0, 0, 0, - 1, 3, 0, 0, 0, - 1, 5, 0, 0, 0, - - 1, 0, 2, 0, 0, - 1, 3, 2, 0, 0, - 1, 5, 2, 0, 0, - - 1, 1, 0, 4, 0, - 1, 2, 0, 4, 0, - 1, 5, 0, 4, 0, - - 1, 1, 0, 0, 6, - 1, 3, 0, 0, 6, - 1, 4, 0, 0, 6, - - 1, 0, 2, 4, 0, - 1, 2, 2, 4, 0, - 1, 5, 2, 4, 0, - - 1, 0, 2, 0, 6, - 1, 3, 2, 0, 6, - 1, 4, 2, 0, 6, - - 1, 1, 0, 4, 6, - 1, 2, 0, 4, 6, - 1, 4, 0, 4, 6, - - - 1, 0, 2, 4, 6, - 1, 2, 2, 4, 6, - 1, 4, 2, 4, 6, - + 1, 0, 1, 2, 3, + 1, 1, 1, 2, 3, + 1, 2, 1, 2, 3, + 1, 3, 1, 2, 3, + 1, 4, 1, 2, 3, + 1, 5, 1, 2, 3, // load, site, x, y, z }; @@ -162,6 +128,38 @@ static void graphics_debug_callback(GLenum source, GLenum type, GLuint id, /* -------------------------------------------------------------------------- */ +/* + * DEBUG + * + */ +static void show_user_choices(long model_space_size_x, + long model_space_size_y, + long model_space_size_z, + + GLuint *arrows, + int model_arrows_nb, + + int pref_show_grid) +{ + printf("model + user constraints : space size x,y,z = %ld,%ld,%ld ", model_space_size_x, model_space_size_y, model_space_size_z); + if (model_arrows_nb > 0) printf("[%d] arrows ", model_arrows_nb); + if (pref_show_grid == 1) printf("pref_show_grid = %d <> show no grid ", pref_show_grid); + if (pref_show_grid == 0) printf("pref_show_grid = %d <> show all grids ", pref_show_grid); + if (pref_show_grid == 2) printf("pref_show_grid = %d <> show grid xy ", pref_show_grid); + if (pref_show_grid == 3) printf("pref_show_grid = %d <> show grid xz ", pref_show_grid); + if (pref_show_grid == 5) printf("pref_show_grid = %d <> show grid yz ", pref_show_grid); + if (pref_show_grid == 6) printf("pref_show_grid = %d <> show grids xy & xz ", pref_show_grid); + if (pref_show_grid == 10) printf("pref_show_grid = %d <> show grids xy & yz ", pref_show_grid); + if (pref_show_grid == 15) printf("pref_show_grid = %d <> show grids xz & yz ", pref_show_grid); + if (model_arrows_nb == 0) printf("\tbuffer_vertex_size = %d\t lines = %d\n",\ + buffer_vertex_size, buffer_lines_size); + if (model_arrows_nb > 0) printf("\n--- < arrows array >\ + ---\n[ n] load site x y z \n-----------------------------\n"); + for (int i = 0; i < model_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 @@ -176,8 +174,14 @@ static void get_model_data_and_user_preferences() // ! WARNING ! Pour l'instant égal au nombre de flèches ! (central stars réécrites) central_stars_nb = model_arrows_nb; - pref_show_grid = 0; // 0, 1, 2, 3, 5, 6, 10, 15, 30, etc + pref_show_grid = 1; // 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, model_arrows_nb, + pref_show_grid); + + } /* -------------------------------------------------------------------------- */ @@ -488,38 +492,6 @@ void graphics_draw(const void *gl_area) } /* -------------------------------------------------------------------------- */ -/* - * DEBUG - * - */ -static void show_user_choices(long model_space_size_x, - long model_space_size_y, - long model_space_size_z, - - GLuint *arrows, - int model_arrows_nb, - - int pref_show_grid) -{ - printf("model + user constraints : space size x,y,z = %ld,%ld,%ld ", model_space_size_x, model_space_size_y, model_space_size_z); - if (model_arrows_nb > 0) printf("[%d] arrows ", model_arrows_nb); - if (pref_show_grid == 1) printf("pref_show_grid = %d <> show no grid ", pref_show_grid); - if (pref_show_grid == 0) printf("pref_show_grid = %d <> show all grids ", pref_show_grid); - if (pref_show_grid == 2) printf("pref_show_grid = %d <> show grid xy ", pref_show_grid); - if (pref_show_grid == 3) printf("pref_show_grid = %d <> show grid xz ", pref_show_grid); - if (pref_show_grid == 5) printf("pref_show_grid = %d <> show grid yz ", pref_show_grid); - if (pref_show_grid == 6) printf("pref_show_grid = %d <> show grids xy & xz ", pref_show_grid); - if (pref_show_grid == 10) printf("pref_show_grid = %d <> show grids xy & yz ", pref_show_grid); - if (pref_show_grid == 15) printf("pref_show_grid = %d <> show grids xz & yz ", pref_show_grid); - if (model_arrows_nb == 0) printf("\tbuffer_vertex_size = %d\t lines = %d\n",\ - buffer_vertex_size, buffer_lines_size); - if (model_arrows_nb > 0) printf("\n[ n] load site x y z ---- < arrows array >\ - ------------------------------------------------------------\n"); - for (int i = 0; i < model_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)); -} - /* * Find gl_area_entry from a gl_area ptr * @@ -656,10 +628,6 @@ void main_test_graphics (void) long site = 0, x = 0, y = 0, z = 0; - show_user_choices(model_space_size_x, model_space_size_y, model_space_size_z, - arrows, model_arrows_nb, - pref_show_grid); - printf("offset_before_grid = %d\n", buffer_vertex_size / 3); /* GRID */ @@ -717,10 +685,6 @@ void main_test_graphics (void) } } - show_user_choices(model_space_size_x, model_space_size_y, model_space_size_z, - arrows, model_arrows_nb, - pref_show_grid); - printf("main_test_graphics [ok]\n"); } diff --git a/src/graphics/grid.c b/src/graphics/grid.c index 4c632bd..de27a10 100644 --- a/src/graphics/grid.c +++ b/src/graphics/grid.c @@ -62,37 +62,24 @@ void grid_write_ridges (long x, long y, long z) { - long step_x = (z + 1) * (y + 1), - step_y = z + 1, - step_z = 1; + long step_x = (z + 1) * (y + 1), + step_y = z + 1, + step_z = 1; + long r_000 = step_z * 0 + step_y * 0 + step_x * 0, + r_100 = step_z * 0 + step_y * 0 + step_x * x, + r_010 = step_z * 0 + step_y * y + step_x * 0, + r_001 = step_z * z + step_y * 0 + step_x * 0, + r_011 = step_z * z + step_y * y + step_x * 0, + r_101 = step_z * z + step_y * 0 + step_x * x, + r_110 = step_z * 0 + step_y * y + step_x * x, + r_111 = step_z * z + step_y * y + step_x * x; - graphics_write_line (step_z * 0 + step_y * 0 + step_x * 0, - step_z * 0 + step_y * 0 + step_x * x); - graphics_write_line (step_z * 0 + step_y * 0 + step_x * 0, - step_z * 0 + step_y * y + step_x * 0); - graphics_write_line (step_z * 0 + step_y * 0 + step_x * 0, - step_z * z + step_y * 0 + step_x * 0); - - graphics_write_line (step_z * z + step_y * y + step_x * x, - step_z * 0 + step_y * y + step_x * x); - graphics_write_line (step_z * z + step_y * y + step_x * x, - step_z * z + step_y * y + step_x * 0); - graphics_write_line (step_z * z + step_y * y + step_x * x, - step_z * z + step_y * 0 + step_x * x); - - graphics_write_line (step_z * 0 + step_y * 0 + step_x * x, - step_z * 0 + step_y * y + step_x * x); - graphics_write_line (step_z * 0 + step_y * 0 + step_x * x, - step_z * z + step_y * 0 + step_x * x); - graphics_write_line (step_z * z + step_y * 0 + step_x * 0, - step_z * z + step_y * y + step_x * 0); - - graphics_write_line (step_z * 0 + step_y * y + step_x * 0, - step_z * 0 + step_y * y + step_x * x); - graphics_write_line (step_z * 0 + step_y * y + step_x * 0, - step_z * z + step_y * y + step_x * 0); - graphics_write_line (step_z * z + step_y * 0 + step_x * 0, - step_z * z + step_y * 0 + step_x * x); + graphics_write_line (r_000, r_100); graphics_write_line (r_111, r_011); + graphics_write_line (r_000, r_010); graphics_write_line (r_111, r_101); + graphics_write_line (r_000, r_001); graphics_write_line (r_111, r_110); + graphics_write_line (r_100, r_110); graphics_write_line (r_011, r_001); + graphics_write_line (r_100, r_101); graphics_write_line (r_011, r_010); + graphics_write_line (r_010, r_110); graphics_write_line (r_101, r_001); } /* diff --git a/src/shaders/shader.vert b/src/shaders/shader.vert index 23d289e..1cb0bf7 100644 --- a/src/shaders/shader.vert +++ b/src/shaders/shader.vert @@ -15,4 +15,6 @@ void main(void) gl_Position = projection_matrix * view_matrix * model_matrix * vec4(in_position, zoom); color = vec4 (chrominance * in_color.rgb, luminance); -} \ No newline at end of file +} + +// https://learnopengl.com/Getting-started/Shaders \ No newline at end of file