WIP: Bon. L'affichage est faux mais le graphisme est parfait pour toutes les fonctions.

This commit is contained in:
Jean Sirmai 2023-08-11 23:00:34 +02:00
parent abc118d8e1
commit 1240dfed43
Signed by: jean
GPG Key ID: FB3115C340E057E3
2 changed files with 32 additions and 5 deletions

View File

@ -482,7 +482,7 @@ bool draw_some_arrows (GLuint *lines_origin, long s, long stx, long sty,
void show_user_choices(long model_size_x, long model_size_y, long model_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_size_x, model_size_y, model_size_z);
printf("\nmodel + user constraints : space size x,y,z = %ld,%ld,%ld ", model_size_x, model_size_y, model_size_z);
if (model_arrows_nb > 0) printf("[%d] arrows ", model_arrows_nb);
// if (pref_mark_unit_space == 0) printf("no unit_space marks ");
// if (pref_mark_unit_space == 1) printf("first unit space marked ");
@ -507,7 +507,7 @@ void show_user_choices(long model_size_x, long model_size_y, long model_size_z,
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));
printf("NB If you play : 'draw_some_arrows(...)' and add some more arrows (in graphics.c below line 571),\
if (0) printf("NB If you play : 'draw_some_arrows(...)' and add some more arrows (in graphics.c below line 571),\
you must also increase the number of arrows (line 555) \n\
The 'central_stars_nb' is automatically set equal to the number_of_arrows (line 559).\n");
}

View File

@ -548,7 +548,7 @@ static void get_model_data_and_user_preferences(){
model_space_size_x = 4; // 0 < model_space_size_x
model_space_size_y = 3; // 0 < model_space_size_y
model_space_size_z = 2; // 0 < model_space_size_z
model_space_size_z = 3; // 0 < model_space_size_z
// XXX ONLY space drawed, no arrows yet
@ -642,9 +642,9 @@ static void compute_buffers_sizes(int model_space_size_x,
// buffer_lines_size += 16 + 20; // draw a small cube with diagonals
buffer_lines_size -= 2;
// buffer_lines_size -= 2;
if (1) printf("allocated buffers sizes :%4d/3 = %3d vertices, %4d/3 = %3d colors,\
if (0) printf("allocated buffers sizes :%4d/3 = %3d vertices, %4d/3 = %3d colors,\
%4d/2 = %3d lines, %4d/3 = %3d plans.\n",
buffer_vertex_size, buffer_vertex_size / 3,
buffer_colors_size, buffer_colors_size / 3,
@ -659,6 +659,11 @@ static bool rewrite_arrow (GLuint *arrows, long address, long weight,
{
printf("write the arrow weight to %ld at (%ld, %ld, %ld, %ld)\n",\
weight, site, x, y, z);
*(arrows + address + 0) = weight;
show_user_choices(model_space_size_x, model_space_size_y, model_space_size_z,
arrows, arrows_nb, pref_show_grid);
return 1; /* replaces the load of the existing arrow by the load 'weight' */
}
@ -666,6 +671,20 @@ static bool create_arrow (GLuint *arrows, long weight, long site, long x, long y
{
printf("create a new arrow with weight = %ld at (%ld, %ld, %ld, %ld)\n",\
weight, site, x, y, z);
arrows_nb ++;
buffer_lines_origin = g_realloc(buffer_lines_origin, buffer_lines_size * 2 * sizeof(GLuint) * 2);
*(arrows + buffer_lines_size + 0) = weight;
*(arrows + buffer_lines_size + 1) = site;
*(arrows + buffer_lines_size + 2) = x;
*(arrows + buffer_lines_size + 3) = y;
*(arrows + buffer_lines_size + 4) = z;
buffer_lines_size += 14;
show_user_choices(model_space_size_x, model_space_size_y, model_space_size_z,
arrows, arrows_nb, pref_show_grid);
return 1;
}
@ -708,6 +727,7 @@ static long check_for_arrow (GLuint *arrows, long site, long x, long y, long z)
f_z = *(arrows + i * 5 + 4);
if (f_site == site && f_x == x && f_y == y && f_z == z) {
if (f_weight > 1) printf("weight = %ld ", f_weight);
address = i * 5;
printf("found at %ld (%ld / 5 = %ld)\n", address, address, address / 5);
}
@ -810,6 +830,13 @@ void graphics_init_buffers(const void *gl_area)
set_arrow(arrows, 0, 2, 2, 1, 1);
set_arrow(arrows, 0, 3, 2, 2, 1);
set_arrow(arrows, 1, 0, 0, 0, 2);
set_arrow(arrows, 1, 1, 1, 0, 2);
set_arrow(arrows, 1, 2, 0, 0, 2);
set_arrow(arrows, 1, 3, 0, 1, 2);
// set_arrow(arrows, 2, 1, 1, 0, 2);
draw_some_arrows (buffer_lines_origin, s,
model_space_size_z * model_space_size_y, model_space_size_z,
arrows, arrows_nb);