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 + 4, n + 5);
|
||||
}
|
||||
|
||||
|
|
|
@ -33,19 +33,18 @@
|
|||
#define FRAG_SHADER_FILE "src/shaders/shader.frag"
|
||||
|
||||
static GLuint arrows[] = {
|
||||
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,
|
||||
1, 0, 3, 2, 1,
|
||||
1, 1, 3, 2, 1,
|
||||
1, 2, 3, 2, 1,
|
||||
1, 3, 3, 2, 1,
|
||||
1, 4, 3, 2, 1,
|
||||
1, 5, 3, 2, 1,
|
||||
// load, site, x, y, z
|
||||
};
|
||||
|
||||
static int model_space_size_x = 0;
|
||||
static int model_space_size_y = 0;
|
||||
static int model_space_size_z = 0;
|
||||
static int model_arrows_nb = 0;
|
||||
static int central_stars_nb = 0;
|
||||
|
||||
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_plans_origin = NULL;
|
||||
|
||||
static int pref_show_grid = 0;
|
||||
static int pref_show_grids = 0;
|
||||
|
||||
static volatile int buffer_vertex_size = 0;
|
||||
static int buffer_colors_size = 0;
|
||||
|
@ -132,54 +131,49 @@ 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,
|
||||
|
||||
static void show_user_choices(long space_size_x,
|
||||
long space_size_y,
|
||||
long space_size_z,
|
||||
GLuint *arrows,
|
||||
int model_arrows_nb,
|
||||
|
||||
int pref_show_grid)
|
||||
int prefer)
|
||||
{
|
||||
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",\
|
||||
int arrows_nb = sizeof(arrows) / (5 * 4);
|
||||
printf("model + user constraints : space size x,y,z = %ld,%ld,%ld ", space_size_x, space_size_y, space_size_z);
|
||||
if (arrows_nb > 0) printf("[%d] arrows ", arrows_nb);
|
||||
if (prefer == 1) printf("prefer = %d <> show no grid ", prefer);
|
||||
if (prefer == 0) printf("prefer = %d <> show all grids ", prefer);
|
||||
if (prefer == 2) printf("prefer = %d <> show grid xy ", prefer);
|
||||
if (prefer == 3) printf("prefer = %d <> show grid xz ", prefer);
|
||||
if (prefer == 5) printf("prefer = %d <> show grid yz ", prefer);
|
||||
if (prefer == 6) printf("prefer = %d <> show grids xy & xz ", prefer);
|
||||
if (prefer == 10) printf("prefer = %d <> show grids xy & yz ", prefer);
|
||||
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);
|
||||
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");
|
||||
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",\
|
||||
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
|
||||
model_space_size_x = 7; // 0 < model_space_size_x
|
||||
model_space_size_y = 5; // 0 < model_space_size_y
|
||||
model_space_size_z = 7; // 0 < model_space_size_z
|
||||
|
||||
model_arrows_nb = sizeof(arrows) / (5 * 4);
|
||||
model_space_size_z = 3; // 0 < model_space_size_z
|
||||
// assert : l'emplacement des flèches est contraint
|
||||
// par model_space_size_x, y, z et le nombre de sites
|
||||
|
||||
central_stars_nb = 0; // à calculer TODO
|
||||
// ! 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
|
||||
|
||||
show_user_choices(model_space_size_x, model_space_size_y, model_space_size_z,
|
||||
arrows, model_arrows_nb,
|
||||
pref_show_grid);
|
||||
arrows, pref_show_grids);
|
||||
|
||||
|
||||
}
|
||||
|
@ -622,65 +616,50 @@ bool graphics_shutdown(const void *gl_area)
|
|||
|
||||
void main_test_graphics (void)
|
||||
{
|
||||
long stx = model_space_size_z * model_space_size_y,
|
||||
sty = model_space_size_z,
|
||||
long 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 site = 0, x = 0, y = 0, z = 0;
|
||||
|
||||
printf("offset_before_grid = %d\n", buffer_vertex_size / 3);
|
||||
|
||||
/* 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)
|
||||
grid_write_x (model_space_size_x, model_space_size_y, model_space_size_z);
|
||||
if (pref_show_grid % 3 == 0)
|
||||
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_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_grid > 0)
|
||||
grid_write_ridges (model_space_size_x, model_space_size_y, model_space_size_z);
|
||||
if (pref_show_grids > 0) grid_write_ridges (x, y, z);
|
||||
|
||||
int offset_after_grid = buffer_vertex_size / 3, cube_coord = 0;
|
||||
|
||||
int offset_after_grid = buffer_vertex_size / 3;
|
||||
printf("offset_after_ grid = %d\n", offset_after_grid);
|
||||
|
||||
/* 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];
|
||||
x = arrows[i * 5 + 2];
|
||||
y = arrows[i * 5 + 3];
|
||||
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);
|
||||
|
||||
arrows_write_basis (offset_after_grid + 12 * (stx * x + sty * y + stz * z)); // XXX 1 + 12 ?
|
||||
cube_coord = 12 * (stx * x + sty * y + stz * z);
|
||||
arrows_write_basis (offset_after_grid + cube_coord);
|
||||
|
||||
switch(site){
|
||||
case EAST:
|
||||
write_arrow_lines_east(offset_after_grid + 12 * (stx * x + sty * y + stz * z), 1, site);
|
||||
break;
|
||||
case WEST:
|
||||
write_arrow_lines_west(offset_after_grid + 12 * (stx * x + sty * y + stz * z), 1, site);
|
||||
break;
|
||||
case ZENITH:
|
||||
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;
|
||||
case EAST: write_arrow_lines_east (offset_after_grid + cube_coord, 1, site); break;
|
||||
case WEST: write_arrow_lines_west (offset_after_grid + cube_coord, 1, site); break;
|
||||
case ZENITH: write_arrow_lines_zenith(offset_after_grid + cube_coord, 1, site); break;
|
||||
case NADIR: write_arrow_lines_nadir (offset_after_grid + cube_coord, 1, site); break;
|
||||
case SOUTH: write_arrow_lines_south (offset_after_grid + cube_coord, 1, site); break;
|
||||
case NORTH: write_arrow_lines_north (offset_after_grid + cube_coord, 1, site); break;
|
||||
default: 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