WIP: mise en forme du code (propositions de) - suite
This commit is contained in:
parent
4ca13189c6
commit
d734bed39b
|
@ -216,3 +216,4 @@ void arrows_write_basis(long n)
|
||||||
graphics_write_line (n + 2, n + 3);
|
graphics_write_line (n + 2, n + 3);
|
||||||
graphics_write_line (n + 4, n + 5);
|
graphics_write_line (n + 4, n + 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,19 +33,18 @@
|
||||||
#define FRAG_SHADER_FILE "src/shaders/shader.frag"
|
#define FRAG_SHADER_FILE "src/shaders/shader.frag"
|
||||||
|
|
||||||
static GLuint arrows[] = {
|
static GLuint arrows[] = {
|
||||||
1, 0, 1, 2, 3,
|
1, 0, 3, 2, 1,
|
||||||
1, 1, 1, 2, 3,
|
1, 1, 3, 2, 1,
|
||||||
1, 2, 1, 2, 3,
|
1, 2, 3, 2, 1,
|
||||||
1, 3, 1, 2, 3,
|
1, 3, 3, 2, 1,
|
||||||
1, 4, 1, 2, 3,
|
1, 4, 3, 2, 1,
|
||||||
1, 5, 1, 2, 3,
|
1, 5, 3, 2, 1,
|
||||||
// load, site, x, y, z
|
// load, site, x, y, z
|
||||||
};
|
};
|
||||||
|
|
||||||
static int model_space_size_x = 0;
|
static int model_space_size_x = 0;
|
||||||
static int model_space_size_y = 0;
|
static int model_space_size_y = 0;
|
||||||
static int model_space_size_z = 0;
|
static int model_space_size_z = 0;
|
||||||
static int model_arrows_nb = 0;
|
|
||||||
static int central_stars_nb = 0;
|
static int central_stars_nb = 0;
|
||||||
|
|
||||||
static GLfloat *buffer_vertex_origin = NULL;
|
static GLfloat *buffer_vertex_origin = NULL;
|
||||||
|
@ -53,7 +52,7 @@ static GLfloat *buffer_colors_origin = NULL;
|
||||||
static GLuint *buffer_lines_origin = NULL;
|
static GLuint *buffer_lines_origin = NULL;
|
||||||
static GLuint *buffer_plans_origin = NULL;
|
static GLuint *buffer_plans_origin = NULL;
|
||||||
|
|
||||||
static int pref_show_grid = 0;
|
static int pref_show_grids = 0;
|
||||||
|
|
||||||
static volatile int buffer_vertex_size = 0;
|
static volatile int buffer_vertex_size = 0;
|
||||||
static int buffer_colors_size = 0;
|
static int buffer_colors_size = 0;
|
||||||
|
@ -132,54 +131,49 @@ static void graphics_debug_callback(GLenum source, GLenum type, GLuint id,
|
||||||
* DEBUG
|
* DEBUG
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static void show_user_choices(long model_space_size_x,
|
static void show_user_choices(long space_size_x,
|
||||||
long model_space_size_y,
|
long space_size_y,
|
||||||
long model_space_size_z,
|
long space_size_z,
|
||||||
|
|
||||||
GLuint *arrows,
|
GLuint *arrows,
|
||||||
int model_arrows_nb,
|
int prefer)
|
||||||
|
|
||||||
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);
|
int arrows_nb = sizeof(arrows) / (5 * 4);
|
||||||
if (model_arrows_nb > 0) printf("[%d] arrows ", model_arrows_nb);
|
printf("model + user constraints : space size x,y,z = %ld,%ld,%ld ", space_size_x, space_size_y, space_size_z);
|
||||||
if (pref_show_grid == 1) printf("pref_show_grid = %d <> show no grid ", pref_show_grid);
|
if (arrows_nb > 0) printf("[%d] arrows ", arrows_nb);
|
||||||
if (pref_show_grid == 0) printf("pref_show_grid = %d <> show all grids ", pref_show_grid);
|
if (prefer == 1) printf("prefer = %d <> show no grid ", prefer);
|
||||||
if (pref_show_grid == 2) printf("pref_show_grid = %d <> show grid xy ", pref_show_grid);
|
if (prefer == 0) printf("prefer = %d <> show all grids ", prefer);
|
||||||
if (pref_show_grid == 3) printf("pref_show_grid = %d <> show grid xz ", pref_show_grid);
|
if (prefer == 2) printf("prefer = %d <> show grid xy ", prefer);
|
||||||
if (pref_show_grid == 5) printf("pref_show_grid = %d <> show grid yz ", pref_show_grid);
|
if (prefer == 3) printf("prefer = %d <> show grid xz ", prefer);
|
||||||
if (pref_show_grid == 6) printf("pref_show_grid = %d <> show grids xy & xz ", pref_show_grid);
|
if (prefer == 5) printf("prefer = %d <> show grid yz ", prefer);
|
||||||
if (pref_show_grid == 10) printf("pref_show_grid = %d <> show grids xy & yz ", pref_show_grid);
|
if (prefer == 6) printf("prefer = %d <> show grids xy & xz ", prefer);
|
||||||
if (pref_show_grid == 15) printf("pref_show_grid = %d <> show grids xz & yz ", pref_show_grid);
|
if (prefer == 10) printf("prefer = %d <> show grids xy & yz ", prefer);
|
||||||
if (model_arrows_nb == 0) printf("\tbuffer_vertex_size = %d\t lines = %d\n",\
|
if (prefer == 15) printf("prefer = %d <> show grids xz & yz ", prefer);
|
||||||
|
if (arrows_nb == 0) printf("\tbuffer_vertex_size = %d\t lines = %d\n",\
|
||||||
buffer_vertex_size, buffer_lines_size);
|
buffer_vertex_size, buffer_lines_size);
|
||||||
if (model_arrows_nb > 0) printf("\n--- < arrows array >\
|
if (arrows_nb > 0) printf("\n--- < arrows array >\
|
||||||
---\n[ n] load site x y z \n-----------------------------\n");
|
---\n[ n] load site x y z \n-----------------------------\n");
|
||||||
for (int i = 0; i < model_arrows_nb; i++)
|
for (int i = 0; i < arrows_nb; i++)
|
||||||
printf("[%2d] = %2d, %2d, %2d, %2d, %2d \n",\
|
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));
|
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()
|
static void get_model_data_and_user_preferences()
|
||||||
{
|
{
|
||||||
model_space_size_x = 3; // 0 < model_space_size_x
|
model_space_size_x = 7; // 0 < model_space_size_x
|
||||||
model_space_size_y = 5; // 0 < model_space_size_y
|
model_space_size_y = 5; // 0 < model_space_size_y
|
||||||
model_space_size_z = 7; // 0 < model_space_size_z
|
model_space_size_z = 3; // 0 < model_space_size_z
|
||||||
|
|
||||||
model_arrows_nb = sizeof(arrows) / (5 * 4);
|
|
||||||
// assert : l'emplacement des flèches est contraint
|
// assert : l'emplacement des flèches est contraint
|
||||||
// par model_space_size_x, y, z et le nombre de sites
|
// par model_space_size_x, y, z et le nombre de sites
|
||||||
|
|
||||||
central_stars_nb = 0; // à calculer TODO
|
central_stars_nb = 0; // à calculer TODO
|
||||||
// ! WARNING ! Pour l'instant égal au nombre de flèches ! (central stars réécrites)
|
// ! WARNING ! Pour l'instant égal au nombre de flèches ! (central stars réécrites)
|
||||||
central_stars_nb = model_arrows_nb;
|
central_stars_nb = sizeof(arrows) / (5 * 4);
|
||||||
|
|
||||||
pref_show_grid = 0; // 0, 1, 2, 3, 5, 6, 10, 15, 30, etc
|
pref_show_grids = 0; // 0, 1, 2, 3, 5, 6, 10, 15, 30, etc
|
||||||
// xyz, 0, x, y, z, xy, xz, yz, xyz
|
// xyz, 0, x, y, z, xy, xz, yz, xyz
|
||||||
|
|
||||||
show_user_choices(model_space_size_x, model_space_size_y, model_space_size_z,
|
show_user_choices(model_space_size_x, model_space_size_y, model_space_size_z,
|
||||||
arrows, model_arrows_nb,
|
arrows, pref_show_grids);
|
||||||
pref_show_grid);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -622,65 +616,50 @@ bool graphics_shutdown(const void *gl_area)
|
||||||
|
|
||||||
void main_test_graphics (void)
|
void main_test_graphics (void)
|
||||||
{
|
{
|
||||||
long stx = model_space_size_z * model_space_size_y,
|
long site = 0,
|
||||||
sty = model_space_size_z,
|
x = model_space_size_x,
|
||||||
|
y = model_space_size_y,
|
||||||
|
z = model_space_size_z;
|
||||||
|
long stx = z * y,
|
||||||
|
sty = z,
|
||||||
stz = 1;
|
stz = 1;
|
||||||
long site = 0, x = 0, y = 0, z = 0;
|
|
||||||
|
|
||||||
printf("offset_before_grid = %d\n", buffer_vertex_size / 3);
|
printf("offset_before_grid = %d\n", buffer_vertex_size / 3);
|
||||||
|
|
||||||
/* GRID */
|
/* GRID */
|
||||||
|
|
||||||
grid_write_intersections (model_space_size_x, model_space_size_y, model_space_size_z);
|
grid_write_intersections (x, y, z);
|
||||||
|
|
||||||
if (pref_show_grid % 2 == 0)
|
if (pref_show_grids % 2 == 0) grid_write_x (x, y, z);
|
||||||
grid_write_x (model_space_size_x, model_space_size_y, model_space_size_z);
|
if (pref_show_grids % 3 == 0) grid_write_y (x, y, z);
|
||||||
if (pref_show_grid % 3 == 0)
|
if (pref_show_grids % 5 == 0) grid_write_z (x, y, z);
|
||||||
grid_write_y (model_space_size_x, model_space_size_y, model_space_size_z);
|
|
||||||
if (pref_show_grid % 5 == 0)
|
|
||||||
grid_write_z (model_space_size_x, model_space_size_y, model_space_size_z);
|
|
||||||
|
|
||||||
if (pref_show_grid > 0)
|
if (pref_show_grids > 0) grid_write_ridges (x, y, z);
|
||||||
grid_write_ridges (model_space_size_x, model_space_size_y, model_space_size_z);
|
|
||||||
|
|
||||||
int offset_after_grid = buffer_vertex_size / 3;
|
int offset_after_grid = buffer_vertex_size / 3, cube_coord = 0;
|
||||||
printf("offset_after_grid = %d\n", offset_after_grid);
|
|
||||||
|
printf("offset_after_ grid = %d\n", offset_after_grid);
|
||||||
|
|
||||||
/* ARROWS */
|
/* ARROWS */
|
||||||
arrows_write_terminations (model_space_size_x, model_space_size_y, model_space_size_z);
|
arrows_write_terminations (x, y, z);
|
||||||
|
|
||||||
for (int i = 0; i < model_arrows_nb; i++) {
|
for (int i = 0; i < sizeof(arrows) / (5 * 4); i++) {
|
||||||
site = arrows[i * 5 + 1];
|
site = arrows[i * 5 + 1];
|
||||||
x = arrows[i * 5 + 2];
|
x = arrows[i * 5 + 2];
|
||||||
y = arrows[i * 5 + 3];
|
y = arrows[i * 5 + 3];
|
||||||
z = arrows[i * 5 + 4];
|
z = arrows[i * 5 + 4];
|
||||||
|
|
||||||
// printf("[%ld]\tsite = %d\tx = %ld\ty = %ld\tz = %ld\tstep x = %ld\tstep y = %ld\n", site, i, x, y, z, stx, sty);
|
cube_coord = 12 * (stx * x + sty * y + stz * z);
|
||||||
|
arrows_write_basis (offset_after_grid + cube_coord);
|
||||||
arrows_write_basis (offset_after_grid + 12 * (stx * x + sty * y + stz * z)); // XXX 1 + 12 ?
|
|
||||||
|
|
||||||
switch(site){
|
switch(site){
|
||||||
case EAST:
|
case EAST: write_arrow_lines_east (offset_after_grid + cube_coord, 1, site); break;
|
||||||
write_arrow_lines_east(offset_after_grid + 12 * (stx * x + sty * y + stz * z), 1, site);
|
case WEST: write_arrow_lines_west (offset_after_grid + cube_coord, 1, site); break;
|
||||||
break;
|
case ZENITH: write_arrow_lines_zenith(offset_after_grid + cube_coord, 1, site); break;
|
||||||
case WEST:
|
case NADIR: write_arrow_lines_nadir (offset_after_grid + cube_coord, 1, site); break;
|
||||||
write_arrow_lines_west(offset_after_grid + 12 * (stx * x + sty * y + stz * z), 1, site);
|
case SOUTH: write_arrow_lines_south (offset_after_grid + cube_coord, 1, site); break;
|
||||||
break;
|
case NORTH: write_arrow_lines_north (offset_after_grid + cube_coord, 1, site); break;
|
||||||
case ZENITH:
|
default: break;
|
||||||
write_arrow_lines_zenith(offset_after_grid + 12 * (stx * x + sty * y + stz * z), 1, site);
|
|
||||||
break;
|
|
||||||
case NADIR:
|
|
||||||
write_arrow_lines_nadir(offset_after_grid + 12 * (stx * x + sty * y + stz * z), 1, site);
|
|
||||||
break;
|
|
||||||
case SOUTH:
|
|
||||||
write_arrow_lines_south(offset_after_grid + 12 * (stx * x + sty * y + stz * z), 1, site);
|
|
||||||
break;
|
|
||||||
case NORTH:
|
|
||||||
write_arrow_lines_north(offset_after_grid + 12 * (stx * x + sty * y + stz * z), 1, site);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
// XXX ?
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -688,3 +667,4 @@ void main_test_graphics (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -154,3 +154,4 @@ void grid_write_z (long x, long y, long z)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue