WIP: affichage amélioré erreurs set_arrow() persistantes
This commit is contained in:
parent
039e247bff
commit
ef83ea0a6b
|
@ -91,7 +91,7 @@ void arrows_write_terminations (long x, long y, long z)
|
|||
graphics_write_color(0.0f, 1.0f, 0.0f);
|
||||
graphics_write_color(1.0f, 0.0f, 1.0f);
|
||||
|
||||
// Z - Z axis arrows tips near the faces centers NORTH - SOUTH
|
||||
// Z - Z (NORTH - SOUTH) axis - arrows tips
|
||||
graphics_write_vertex (vx, vy, vz + (1 / max) - arrow_tip_padding);
|
||||
graphics_write_vertex (vx, vy, vz - (1 / max) + arrow_tip_padding);
|
||||
graphics_write_color(0.0f, 0.0f, 1.0f);
|
||||
|
@ -100,67 +100,67 @@ void arrows_write_terminations (long x, long y, long z)
|
|||
}
|
||||
|
||||
/*
|
||||
* Writes lines for arrow oriented to the east or west into lines buffer
|
||||
* Writes lines for arrow oriented towards east or west into lines buffer
|
||||
*
|
||||
* @param s,
|
||||
* @param offset,
|
||||
* weight,
|
||||
* site
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
void write_arrow_lines_east_west (long s, int weight, int site)
|
||||
void write_arrow_lines_east_west (long offset, int weight, int site)
|
||||
{
|
||||
graphics_write_line (s + 2, s + 6 + site % 2);
|
||||
graphics_write_line (s + 3, s + 6 + site % 2);
|
||||
graphics_write_line (s + 4, s + 6 + site % 2);
|
||||
graphics_write_line (s + 5, s + 6 + site % 2);
|
||||
graphics_write_line (offset + 2, offset + 6 + site % 2);
|
||||
graphics_write_line (offset + 3, offset + 6 + site % 2);
|
||||
graphics_write_line (offset + 4, offset + 6 + site % 2);
|
||||
graphics_write_line (offset + 5, offset + 6 + site % 2);
|
||||
}
|
||||
|
||||
/*
|
||||
* Writes lines for arrow oriented to the zenith or nadir into lines buffer
|
||||
* Writes lines for arrow oriented towards zenith or nadir into lines buffer
|
||||
*
|
||||
* @param s,
|
||||
* @param offset,
|
||||
* weight,
|
||||
* site
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
void write_arrow_lines_zenith_nadir (long s, int weight, int site)
|
||||
void write_arrow_lines_zenith_nadir (long offset, int weight, int site)
|
||||
{
|
||||
graphics_write_line (s + 0, s + 8 + site % 2);
|
||||
graphics_write_line (s + 1, s + 8 + site % 2);
|
||||
graphics_write_line (s + 4, s + 8 + site % 2);
|
||||
graphics_write_line (s + 5, s + 8 + site % 2);
|
||||
graphics_write_line (offset + 0, offset + 8 + site % 2);
|
||||
graphics_write_line (offset + 1, offset + 8 + site % 2);
|
||||
graphics_write_line (offset + 4, offset + 8 + site % 2);
|
||||
graphics_write_line (offset + 5, offset + 8 + site % 2);
|
||||
}
|
||||
|
||||
/*
|
||||
* Writes lines for arrow oriented to the south or north into lines buffer
|
||||
* Writes lines for arrow oriented towards south or north into lines buffer
|
||||
*
|
||||
* @param s,
|
||||
* @param offset,
|
||||
* weight,
|
||||
* site
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
void write_arrow_lines_south_north (long s, int weight, int site)
|
||||
void write_arrow_lines_south_north (long offset, int weight, int site)
|
||||
{
|
||||
graphics_write_line (s + 0, s + 10 + site % 2);
|
||||
graphics_write_line (s + 1, s + 10 + site % 2);
|
||||
graphics_write_line (s + 2, s + 10 + site % 2);
|
||||
graphics_write_line (s + 3, s + 10 + site % 2);
|
||||
graphics_write_line (offset + 0, offset + 10 + site % 2);
|
||||
graphics_write_line (offset + 1, offset + 10 + site % 2);
|
||||
graphics_write_line (offset + 2, offset + 10 + site % 2);
|
||||
graphics_write_line (offset + 3, offset + 10 + site % 2);
|
||||
}
|
||||
|
||||
/*
|
||||
* Writes lines for arrow basis into lines buffer
|
||||
*
|
||||
* @param n
|
||||
* @param offset
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
void arrows_write_basis(long n)
|
||||
void arrows_write_basis(long offset)
|
||||
{
|
||||
graphics_write_line (n + 0, n + 1);
|
||||
graphics_write_line (n + 2, n + 3);
|
||||
graphics_write_line (n + 4, n + 5);
|
||||
graphics_write_line (offset + 0, offset + 1);
|
||||
graphics_write_line (offset + 2, offset + 3);
|
||||
graphics_write_line (offset + 4, offset + 5);
|
||||
}
|
||||
|
||||
|
|
|
@ -32,26 +32,31 @@
|
|||
#define VERTEX_SHADER_FILE "src/shaders/shader.vert"
|
||||
#define FRAG_SHADER_FILE "src/shaders/shader.frag"
|
||||
|
||||
static int model_space_size_x = 0;
|
||||
static int model_space_size_y = 0;
|
||||
static int model_space_size_z = 0;
|
||||
|
||||
static GLfloat *buffer_vertex_origin = NULL;
|
||||
static GLfloat *buffer_colors_origin = NULL;
|
||||
static GLuint *buffer_lines_origin = NULL;
|
||||
static GLuint *buffer_plans_origin = NULL;
|
||||
|
||||
static int pref_show_grids = 0;
|
||||
|
||||
static volatile int buffer_vertex_size = 0;
|
||||
static int buffer_colors_size = 0;
|
||||
static int buffer_lines_size = 0;
|
||||
static int buffer_plans_size = 0;
|
||||
|
||||
|
||||
// model_data_and_user_preferences :
|
||||
|
||||
static int pref_show_grids = 0; // 0, 1, 2, 3, 5, 6, 10, 15, 30, etc
|
||||
// xyz, 0, x, y, z, xy, xz, yz, xyz
|
||||
|
||||
static int xxx = 0;
|
||||
static int yyy = 0;
|
||||
static int zzz = 0;
|
||||
|
||||
// assert : l'emplacement des flèches est contraint
|
||||
// par model_space_size_x, y, z et le nombre de sites
|
||||
static GLuint arrows[] = {
|
||||
1, 0, 0, 0, 0,
|
||||
1, 1, 0, 0, 0,
|
||||
1, 1, 1, 0, 0,
|
||||
/* 1, 1, 0, 0, 0, */
|
||||
/* 1, 2, 0, 0, 0, */
|
||||
|
@ -73,12 +78,11 @@ static void show_user_choices(int space_size_x,
|
|||
{
|
||||
int arrows_nb = get_arrows_nb();
|
||||
printf("model + user constraints : space size x,y,z = %d,%d,%d ", space_size_x, space_size_y, space_size_z);
|
||||
if (arrows_nb > 0) printf("[%d] arrows ", arrows_nb);
|
||||
if (prefer == 0) printf("prefer = %d <> show all grids ", prefer);
|
||||
if (prefer == 1) printf("prefer = %d <> show no grid ", prefer);
|
||||
if (prefer > 1) printf("pref_show_grids = %d ", prefer);
|
||||
if (prefer == 0) printf("prefer = %d <> show all grids ", prefer);
|
||||
if (prefer == 1) printf("prefer = %d <> show no grid ", prefer);
|
||||
if (prefer > 1) printf("pref_show_grids = %d ", prefer);
|
||||
if (arrows_nb == 0) printf("\tbuffer_vertex_size = %d\t lines = %d\n", buffer_vertex_size, buffer_lines_size);
|
||||
if (arrows_nb > 0) printf("\n [ n] load | site x y z \n -------------------------------\n");
|
||||
if (arrows_nb > 0) printf("\n [%2d] load | site x y z \n -------------------------------\n", arrows_nb);
|
||||
for (int i = 0; i < 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));
|
||||
if (arrows_nb > 0) printf(" -------------------------------\n");}
|
||||
|
@ -87,15 +91,12 @@ static int set_arrow (int weight, int site, int x, int y, int z);
|
|||
|
||||
static void get_model_data_and_user_preferences()
|
||||
{
|
||||
model_space_size_x = 2; // 0 < model_space_size_x
|
||||
model_space_size_y = 1; // 0 < model_space_size_y
|
||||
model_space_size_z = 1; // 0 < model_space_size_z
|
||||
xxx = 2; // 0 < model_space_size_x
|
||||
yyy = 1; // 0 < model_space_size_y
|
||||
zzz = 1; // 0 < model_space_size_z
|
||||
pref_show_grids = 0; // 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,
|
||||
pref_show_grids);
|
||||
|
||||
// set_arrow(arrows, 1, 1, 1, 0, 0);
|
||||
show_user_choices(xxx, yyy, zzz, pref_show_grids);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
@ -138,9 +139,9 @@ static bool create_arrow (int weight, int site, int x, int y, int z)
|
|||
static bool erase_arrow (int address, int site, int x, int y, int z)
|
||||
{
|
||||
int arrows_nb = get_arrows_nb();
|
||||
if (DETAIL) printf("erase arrow at address %d with values (%d, %d, %d, %d)",\
|
||||
if (1) printf("erase arrow at address %d with values (%d, %d, %d, %d)",\
|
||||
address / 5, site, x, y, z);
|
||||
if (DETAIL) printf(" last arrow is %d, %d, %d, %d, %d\n",
|
||||
if (1) printf(" last arrow is %d, %d, %d, %d, %d\n",
|
||||
*(arrows + (arrows_nb - 1) * 5 + 0),
|
||||
*(arrows + (arrows_nb - 1) * 5 + 1),
|
||||
*(arrows + (arrows_nb - 1) * 5 + 2),
|
||||
|
@ -160,52 +161,33 @@ static bool erase_arrow (int address, int site, int x, int y, int z)
|
|||
return 1;
|
||||
}
|
||||
|
||||
static int check_for_arrow (int site, int x, int y, int z)
|
||||
static void show_arrows_array (int arrows_nb, int address, int current_weigh, int weight, int site, int x, int y, int z)
|
||||
{
|
||||
int arrows_nb = get_arrows_nb();
|
||||
if (arrows_nb == 0) return -1;
|
||||
printf("command set_arrow (weight (%d), address (%d,%d,%d,%d)) <> ", weight, site, x, y, z);
|
||||
|
||||
int address = -1, f_weight = -1, f_site = -1, f_x = -1, f_y = -1, f_z = -1;
|
||||
for (int i = 0; i < arrows_nb; i++)
|
||||
{
|
||||
f_weight = *(arrows + i * 5 + 0);
|
||||
f_site = *(arrows + i * 5 + 1);
|
||||
f_x = *(arrows + i * 5 + 2);
|
||||
f_y = *(arrows + i * 5 + 3);
|
||||
f_z = *(arrows + i * 5 + 4);
|
||||
|
||||
if (f_site == site && f_x == x && f_y == y && f_z == z) {
|
||||
address = i * 5;
|
||||
if (DETAIL) printf("arrows_nb = %d checked arrow (%d,%d,%d,%d) found at address %d (line %d)",\
|
||||
arrows_nb, site, x, y, z, address, address / 5);
|
||||
if (DETAIL && f_weight > 1) printf(" weight = %d", f_weight);
|
||||
if (DETAIL) printf("\n");
|
||||
}
|
||||
if (arrows_nb == 0 && weight == 0) printf("no arrow in space + no arrows to be created > end function set_arrow()\n");
|
||||
if (address == -1 && weight == 0) printf("arrow not found + no arrows to be created > end function set_arrow()\n");
|
||||
if (address == -1 && weight > 0) printf("arrow not found > new arrow will be created at line [%d]\n", arrows_nb);
|
||||
if (address >= 0 && weight == 0) printf("arrow found at line [%d] > will be erased\n", address / 5);
|
||||
if (address >= 0 && weight > 0) {
|
||||
if (current_weigh != weight) printf("arrow found at line [%d] > will be modified\n", address / 5);
|
||||
if (current_weigh == weight) printf("arrow found at line [%d] > will not be modified\n", address / 5);
|
||||
}
|
||||
return address; /* returns the address of the arrow if there is one
|
||||
* or (-1) if there is none */
|
||||
}
|
||||
|
||||
|
||||
static void show_arrows_array (int address, int weight, int site, int x, int y, int z)
|
||||
{
|
||||
int arrows_nb = get_arrows_nb();
|
||||
printf("\n [ n] load | site x y z ----- < arrows_nb = %d > ------", arrows_nb);
|
||||
if (arrows_nb == 0) printf("--------------------------- no arrows\n");
|
||||
else if (address == -1) printf("--------------------------- create new arrow\n");
|
||||
else printf("--------------------------- erase arrow at address = %d / 5\n", address);
|
||||
|
||||
printf(" [rank] load | site x y z\n");
|
||||
for (int i = 0; i < arrows_nb; i++)
|
||||
{
|
||||
printf(" [%2d] = %2d | %2d, %2d, %2d, %2d ",\
|
||||
printf(" [%4d] = %2d | %2d, %2d, %2d, %2d ",\
|
||||
i, *(arrows + i * 5 + 0), *(arrows + i * 5 + 1), *(arrows + i * 5 + 2),\
|
||||
*(arrows + i * 5 + 3), *(arrows + i * 5 + 4));
|
||||
if (weight == 0 && i == address / 5) printf(" <<<| < - > (%d, %d, %d, %d) @ [%d]",\
|
||||
*(arrows + i * 5 + 1), *(arrows + i * 5 + 2),\
|
||||
*(arrows + i * 5 + 3), *(arrows + i * 5 + 4), address / 5);
|
||||
if (weight > 0 && i == arrows_nb - 1) printf(" <<< < + > (%d, %d, %d, %d) @ [%d]",\
|
||||
if (weight > 0 && current_weigh != weight && i == arrows_nb - 1)
|
||||
printf(" <<< < + > (%d, %d, %d, %d) @ [%d]",\
|
||||
*(arrows + i * 5 + 1), *(arrows + i * 5 + 2),\
|
||||
*(arrows + i * 5 + 3), *(arrows + i * 5 + 4), address / 5);
|
||||
if (weight > 0 && current_weigh == weight && i == address / 5) printf(" <");
|
||||
if (weight == 0 && i > address / 5 && i < arrows_nb - 1) printf(" |");
|
||||
if (weight == 0 && i == arrows_nb - 1 && i != address / 5) printf(" >>>|");
|
||||
printf("\n");
|
||||
|
@ -215,15 +197,30 @@ static void show_arrows_array (int address, int weight, int site, int x, int y,
|
|||
|
||||
static int set_arrow (int weight, int site, int x, int y, int z)
|
||||
{
|
||||
int address = (check_for_arrow (site, x, y, z));
|
||||
show_arrows_array(address, weight, site, x, y, z);
|
||||
// assert pas de flèche(s) doublons
|
||||
|
||||
int address = -1, current_weight = -1,
|
||||
arrows_nb = get_arrows_nb();
|
||||
|
||||
if (arrows_nb > 0)
|
||||
for (int i = 0; i < arrows_nb; i++) {
|
||||
if ((site == *(arrows + i * 5 + 1))
|
||||
&& (x == *(arrows + i * 5 + 2))
|
||||
&& (y == *(arrows + i * 5 + 3))
|
||||
&& (z == *(arrows + i * 5 + 4)))
|
||||
{
|
||||
address = i * 5;
|
||||
current_weight = *(arrows + i * 5 + 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
show_arrows_array(arrows_nb, address, current_weight, weight, site, x, y, z);
|
||||
|
||||
if (address == -1 && weight == 0) return 0;
|
||||
if (address == -1 && weight > 0) return create_arrow (weight, site, x, y, z);
|
||||
if (address >= 0 && weight == 0) return erase_arrow (address, site, x, y, z);
|
||||
if (address >= 0 && weight > 0) return rewrite_arrow (address, weight, site, x, y, z);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -762,35 +759,25 @@ bool graphics_shutdown(const void *gl_area)
|
|||
|
||||
void main_test_graphics (void)
|
||||
{
|
||||
long weight = 0, site = 0,
|
||||
x = model_space_size_x,
|
||||
y = model_space_size_y,
|
||||
z = model_space_size_z;
|
||||
long stx = z * y,
|
||||
sty = z,
|
||||
stz = 1;
|
||||
long arrow_offset = 0;
|
||||
long weight = 0, site = 0, stx = zzz * yyy, sty = zzz, stz = 1, arrow_offset = 0;
|
||||
|
||||
if (0) printf("buffer_vertex_offset_before_grid = %d\n", buffer_vertex_size / 3);
|
||||
|
||||
/* GRID */
|
||||
grid_write_intersections (x, y, z);
|
||||
grid_write_intersections (xxx, yyy, zzz);
|
||||
|
||||
if (pref_show_grids % 2 == 0) grid_write_x (x, y, z);
|
||||
if (pref_show_grids % 3 == 0) grid_write_y (x, y, z);
|
||||
if (pref_show_grids % 5 == 0) grid_write_z (x, y, z);
|
||||
if (pref_show_grids % 2 == 0) grid_write_x (xxx, yyy, zzz);
|
||||
if (pref_show_grids % 3 == 0) grid_write_y (xxx, yyy, zzz);
|
||||
if (pref_show_grids % 5 == 0) grid_write_z (xxx, yyy, zzz);
|
||||
|
||||
if (pref_show_grids > 0) grid_write_ridges (x, y, z);
|
||||
if (pref_show_grids > 0) grid_write_ridges (xxx, yyy, zzz);
|
||||
|
||||
int offset_after_grids = buffer_vertex_size / 3;
|
||||
|
||||
if (1) printf("buffer_vertex_offset_after grids = %d (x+1)*(y+1)*(z+1) = %ld\n",\
|
||||
offset_after_grids, (x+1)*(y+1)*(z+1));
|
||||
|
||||
/* ARROWS */
|
||||
arrows_write_terminations (x, y, z);
|
||||
arrows_write_terminations (xxx, yyy, zzz);
|
||||
|
||||
int arrows_nb = get_arrows_nb();
|
||||
int arrows_nb = get_arrows_nb(), offset_up_to_this_cube_coords = 0, x,y,z;
|
||||
|
||||
for (int i = 0; i < arrows_nb; i++) {
|
||||
weight = arrows[i * 5 + 0];
|
||||
|
@ -799,23 +786,25 @@ void main_test_graphics (void)
|
|||
y = arrows[i * 5 + 3];
|
||||
z = arrows[i * 5 + 4];
|
||||
|
||||
set_arrow (weight, site, x, y, z);
|
||||
|
||||
/* // cube coordinates = 12 * (stx * x + sty * y + stz * z); */
|
||||
arrow_offset = offset_after_grids + 12 * (stx * x + sty * y + stz * z);
|
||||
offset_up_to_this_cube_coords = 12 * (stx * x + sty * y + stz * z);
|
||||
arrow_offset = offset_after_grids + offset_up_to_this_cube_coords;
|
||||
arrows_write_basis (arrow_offset);
|
||||
|
||||
switch(site){
|
||||
case EAST: case WEST: write_arrow_lines_east_west (arrow_offset, 1, site); break;
|
||||
case ZENITH: case NADIR: write_arrow_lines_zenith_nadir (arrow_offset, 1, site); break;
|
||||
case SOUTH: case NORTH: write_arrow_lines_south_north (arrow_offset, 1, site); break;
|
||||
case EAST: case WEST: write_arrow_lines_east_west (arrow_offset, weight, site); break;
|
||||
case ZENITH: case NADIR: write_arrow_lines_zenith_nadir (arrow_offset, weight, site); break;
|
||||
case SOUTH: case NORTH: write_arrow_lines_south_north (arrow_offset, weight, site); break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
set_arrow (1, 1, 1, 0, 0);
|
||||
|
||||
int offset_after_arrows = buffer_vertex_size / 3, difference = offset_after_arrows - offset_after_grids;
|
||||
// TODO Qu'est-ce que j'affiche, là ?! < À vérifier
|
||||
if (1) printf("buffer_vertex_offset_after arrows = %d (%d - %d = %d, %d / 12 = %d cubes)\n",\
|
||||
|
||||
if (1) printf("\nbuffer_vertex_offset_after grids = %d (x+1)*(y+1)*(z+1) = %d (x,y,z = %d,%d,%d)\n",\
|
||||
offset_after_grids, (xxx + 1)*(yyy + 1)*(zzz + 1), xxx, yyy, zzz);
|
||||
if (1) printf("buffer_vertex_offset_after arrows = %d (%d - %d = %d, %d / 12 <> %d cubes)\n",\
|
||||
offset_after_arrows, offset_after_arrows, offset_after_grids,\
|
||||
difference, difference, difference / 12);
|
||||
if (0) printf("main_test_graphics [ok]\n");
|
||||
|
|
Loading…
Reference in New Issue