WIP: Ça s'allège. Il y a plus de choses qui marchent que l'inverse !
This commit is contained in:
parent
fbbefa687a
commit
53784a02bf
|
@ -42,11 +42,6 @@ bool compute_space_and_arrows(int model_space_size_x,
|
||||||
GLfloat *vertex_origin,
|
GLfloat *vertex_origin,
|
||||||
GLfloat *color_origin,
|
GLfloat *color_origin,
|
||||||
GLubyte *line_origin,
|
GLubyte *line_origin,
|
||||||
GLubyte *plan_origin,
|
GLubyte *plan_origin);
|
||||||
|
|
||||||
int buffer_vertex_size,
|
|
||||||
int buffer_colors_size,
|
|
||||||
int buffer_lines_size,
|
|
||||||
int buffer_plans_size);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -191,12 +191,7 @@ static int compute_arrow_2D(int space_size_x,
|
||||||
GLfloat *vertex_origin,
|
GLfloat *vertex_origin,
|
||||||
GLfloat *color_origin,
|
GLfloat *color_origin,
|
||||||
GLubyte *line_origin,
|
GLubyte *line_origin,
|
||||||
GLubyte *plan_origin,
|
GLubyte *plan_origin)
|
||||||
|
|
||||||
int buffer_vertex_size,
|
|
||||||
int buffer_colors_size,
|
|
||||||
int buffer_lines_size,
|
|
||||||
int buffer_plans_size)
|
|
||||||
{
|
{
|
||||||
printf("compute_arrow_2D load = %d site = %d x = %d\n", weight, site, x);
|
printf("compute_arrow_2D load = %d site = %d x = %d\n", weight, site, x);
|
||||||
float zero = 0.0f;
|
float zero = 0.0f;
|
||||||
|
@ -442,12 +437,7 @@ static bool compute_arrow_3D(int space_size_x,
|
||||||
GLfloat *vertex_origin,
|
GLfloat *vertex_origin,
|
||||||
GLfloat *color_origin,
|
GLfloat *color_origin,
|
||||||
GLubyte *line_origin,
|
GLubyte *line_origin,
|
||||||
GLubyte *plan_origin,
|
GLubyte *plan_origin)
|
||||||
|
|
||||||
int buffer_vertex_size,
|
|
||||||
int buffer_colors_size,
|
|
||||||
int buffer_lines_size,
|
|
||||||
int buffer_plans_size)
|
|
||||||
|
|
||||||
{
|
{
|
||||||
float zero = 0.0f;
|
float zero = 0.0f;
|
||||||
|
@ -455,9 +445,6 @@ static bool compute_arrow_3D(int space_size_x,
|
||||||
float tip = center + (2 * site - 1) * (1.0f / space_size_x);
|
float tip = center + (2 * site - 1) * (1.0f / space_size_x);
|
||||||
float base = center + (2 * site - 1) * (0.1f / space_size_x);
|
float base = center + (2 * site - 1) * (0.1f / space_size_x);
|
||||||
|
|
||||||
if (A3) printf("arrow_3D (vertices %d to %d) ",\
|
|
||||||
(buffer_vertex_size + space_size_x * 12 - 15), (buffer_vertex_size + space_size_x * 12));
|
|
||||||
|
|
||||||
*(vertex_origin + space_size_x * 12 + 0) = center + (2 * site - 1) * (1.0f / space_size_x - 0.01f);
|
*(vertex_origin + space_size_x * 12 + 0) = center + (2 * site - 1) * (1.0f / space_size_x - 0.01f);
|
||||||
*(vertex_origin + space_size_x * 12 + 1) = zero;
|
*(vertex_origin + space_size_x * 12 + 1) = zero;
|
||||||
*(vertex_origin + space_size_x * 12 + 2) = zero;
|
*(vertex_origin + space_size_x * 12 + 2) = zero;
|
||||||
|
@ -549,12 +536,7 @@ static void show_user_choices(int model_space_size_x,
|
||||||
int pref_3D_xor_2D_arrows,
|
int pref_3D_xor_2D_arrows,
|
||||||
int pref_mark_unit_space,
|
int pref_mark_unit_space,
|
||||||
int pref_style_lines_planes,
|
int pref_style_lines_planes,
|
||||||
int pref_style_mix_colors,
|
int pref_style_mix_colors)
|
||||||
|
|
||||||
int buffer_vertex_size,
|
|
||||||
int buffer_colors_size,
|
|
||||||
int buffer_lines_size,
|
|
||||||
int buffer_plans_size)
|
|
||||||
{
|
{
|
||||||
printf("model + user constraints : x,y,z = (%d, %d, %d) ", model_space_size_x, model_space_size_y, model_space_size_z);
|
printf("model + user constraints : x,y,z = (%d, %d, %d) ", model_space_size_x, model_space_size_y, model_space_size_z);
|
||||||
if (pref_3D_xor_2D_space == 0) printf("3D space ");
|
if (pref_3D_xor_2D_space == 0) printf("3D space ");
|
||||||
|
@ -570,11 +552,12 @@ static void show_user_choices(int model_space_size_x,
|
||||||
if (pref_style_lines_planes > 0)printf("style_lines_planes = %d ", pref_style_lines_planes);
|
if (pref_style_lines_planes > 0)printf("style_lines_planes = %d ", pref_style_lines_planes);
|
||||||
if (! pref_style_mix_colors) printf("style_mix_colors = 0 ");
|
if (! pref_style_mix_colors) printf("style_mix_colors = 0 ");
|
||||||
if (pref_style_mix_colors > 0) printf("style_mix_colors = %d ", pref_style_mix_colors);
|
if (pref_style_mix_colors > 0) printf("style_mix_colors = %d ", pref_style_mix_colors);
|
||||||
printf("\n----------------- alloc : %4d/3 = %3d vertices, %4d/3 = %3d colors,\
|
printf("\n[ n] load site x ---- < arrows array >\
|
||||||
%4d/2 = %3d lines, %4d/3 = %3d plans\n[ n] load site x ---- < arrows array >\
|
----------------------------------------------------------------------\n");
|
||||||
----------------------------------------------------------------------\n",
|
// arrows = { 1, 1, 0, 1, 2, 1, 1, 1, 10, 1, 2, 11, 1, 1, 20, 1, 2, 21 }
|
||||||
buffer_vertex_size, buffer_vertex_size / 3, buffer_colors_size, buffer_colors_size / 3,
|
if (SA) for (int i = 0; i < model_arrows_nb; i++)
|
||||||
buffer_lines_size, buffer_lines_size / 2, buffer_plans_size, buffer_plans_size / 3);
|
printf("[%2d] = %2d, %2d, %2d \n",\
|
||||||
|
i, *(arrows + i * 3), *(arrows + i * 3 + 1), *(arrows + i * 3 + 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool compute_space_and_arrows(int model_space_size_x,
|
bool compute_space_and_arrows(int model_space_size_x,
|
||||||
|
@ -593,12 +576,7 @@ bool compute_space_and_arrows(int model_space_size_x,
|
||||||
GLfloat *vertex_origin,
|
GLfloat *vertex_origin,
|
||||||
GLfloat *color_origin,
|
GLfloat *color_origin,
|
||||||
GLubyte *line_origin,
|
GLubyte *line_origin,
|
||||||
GLubyte *plan_origin,
|
GLubyte *plan_origin)
|
||||||
|
|
||||||
int buffer_vertex_size,
|
|
||||||
int buffer_colors_size,
|
|
||||||
int buffer_lines_size,
|
|
||||||
int buffer_plans_size)
|
|
||||||
|
|
||||||
{
|
{
|
||||||
if (SA) show_user_choices(model_space_size_x,
|
if (SA) show_user_choices(model_space_size_x,
|
||||||
|
@ -612,90 +590,74 @@ bool compute_space_and_arrows(int model_space_size_x,
|
||||||
pref_3D_xor_2D_arrows,
|
pref_3D_xor_2D_arrows,
|
||||||
pref_mark_unit_space,
|
pref_mark_unit_space,
|
||||||
pref_style_lines_planes,
|
pref_style_lines_planes,
|
||||||
pref_style_mix_colors,
|
pref_style_mix_colors);
|
||||||
|
|
||||||
buffer_vertex_size,
|
if (pref_3D_xor_2D_space) compute_space_2D (
|
||||||
buffer_colors_size,
|
model_space_size_x,
|
||||||
buffer_lines_size,
|
model_space_size_y,
|
||||||
buffer_plans_size);
|
model_space_size_z,
|
||||||
|
|
||||||
if (pref_3D_xor_2D_space) compute_space_2D (model_space_size_x,
|
pref_mark_unit_space,
|
||||||
model_space_size_y,
|
pref_style_lines_planes,
|
||||||
model_space_size_z,
|
pref_style_mix_colors,
|
||||||
|
|
||||||
pref_mark_unit_space,
|
vertex_origin,
|
||||||
pref_style_lines_planes,
|
color_origin,
|
||||||
pref_style_mix_colors,
|
line_origin,
|
||||||
|
plan_origin);
|
||||||
|
|
||||||
vertex_origin,
|
else compute_space_3D (
|
||||||
color_origin,
|
model_space_size_x,
|
||||||
line_origin,
|
model_space_size_y,
|
||||||
plan_origin);
|
model_space_size_z,
|
||||||
|
|
||||||
else compute_space_3D (model_space_size_x,
|
pref_mark_unit_space,
|
||||||
model_space_size_y,
|
pref_style_lines_planes,
|
||||||
model_space_size_z,
|
pref_style_mix_colors,
|
||||||
|
|
||||||
pref_mark_unit_space,
|
vertex_origin,
|
||||||
pref_style_lines_planes,
|
color_origin,
|
||||||
pref_style_mix_colors,
|
line_origin,
|
||||||
|
plan_origin);
|
||||||
|
|
||||||
vertex_origin,
|
for (int i = 0; i < model_arrows_nb; i++)
|
||||||
color_origin,
|
if (pref_3D_xor_2D_arrows) compute_arrow_2D(
|
||||||
line_origin,
|
model_space_size_x,
|
||||||
plan_origin);
|
model_space_size_y,
|
||||||
|
model_space_size_z,
|
||||||
|
|
||||||
|
*(arrows + i * 3 + 0), // weight
|
||||||
|
*(arrows + i * 3 + 1), // site
|
||||||
|
*(arrows + i * 3 + 2), // x
|
||||||
|
0, // y
|
||||||
|
0, // z
|
||||||
|
|
||||||
// arrows = { 1, 1, 0, 1, 2, 1, 1, 1, 10, 1, 2, 11, 1, 1, 20, 1, 2, 21 }
|
pref_style_lines_planes,
|
||||||
if (SA) for (int i = 0; i < model_arrows_nb; i++)
|
pref_style_mix_colors,
|
||||||
printf("[%2d] = %2d, %2d, %2d \n",\
|
|
||||||
i, *(arrows + i * 3), *(arrows + i * 3 + 1), *(arrows + i * 3 + 2));
|
|
||||||
|
|
||||||
for (int i = 0; i < model_arrows_nb; i++) if (pref_3D_xor_2D_arrows) compute_arrow_2D(model_space_size_x,
|
vertex_origin,
|
||||||
model_space_size_y,
|
color_origin,
|
||||||
model_space_size_z,
|
line_origin,
|
||||||
|
plan_origin);
|
||||||
|
|
||||||
*(arrows + i * 3 + 0), // weight
|
else compute_arrow_3D(
|
||||||
*(arrows + i * 3 + 1), // site
|
model_space_size_x,
|
||||||
*(arrows + i * 3 + 2), // x
|
model_space_size_y,
|
||||||
0, // y
|
model_space_size_z,
|
||||||
0, // z
|
|
||||||
|
|
||||||
pref_style_lines_planes,
|
*(arrows + i * 3 + 0), // weight
|
||||||
pref_style_mix_colors,
|
*(arrows + i * 3 + 1), // site
|
||||||
|
*(arrows + i * 3 + 2), // x
|
||||||
|
0, // y
|
||||||
|
0, // z
|
||||||
|
|
||||||
vertex_origin,
|
pref_style_lines_planes,
|
||||||
color_origin,
|
pref_style_mix_colors,
|
||||||
line_origin,
|
|
||||||
plan_origin,
|
|
||||||
|
|
||||||
buffer_vertex_size,
|
vertex_origin,
|
||||||
buffer_colors_size,
|
color_origin,
|
||||||
buffer_lines_size,
|
line_origin,
|
||||||
buffer_plans_size);
|
plan_origin);
|
||||||
|
|
||||||
else compute_arrow_3D(model_space_size_x,
|
|
||||||
model_space_size_y,
|
|
||||||
model_space_size_z,
|
|
||||||
|
|
||||||
*(arrows + i * 3 + 0), // weight
|
|
||||||
*(arrows + i * 3 + 1), // site
|
|
||||||
*(arrows + i * 3 + 2), // x
|
|
||||||
0, // y
|
|
||||||
0, // z
|
|
||||||
|
|
||||||
pref_style_lines_planes,
|
|
||||||
pref_style_mix_colors,
|
|
||||||
|
|
||||||
vertex_origin,
|
|
||||||
color_origin,
|
|
||||||
line_origin,
|
|
||||||
plan_origin,
|
|
||||||
|
|
||||||
buffer_vertex_size,
|
|
||||||
buffer_colors_size,
|
|
||||||
buffer_lines_size,
|
|
||||||
buffer_plans_size);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -527,11 +527,11 @@ GLubyte arrows[] = { 1, 1, 0, 1, 0, 1, 1, 1, 4, 1, 0, 5, 1, 1, 8, 1, 0, 9
|
||||||
static void get_model_data_and_user_preferences(){
|
static void get_model_data_and_user_preferences(){
|
||||||
|
|
||||||
model_space_size_x = 11; // 2 < model_space_size_x < 32
|
model_space_size_x = 11; // 2 < model_space_size_x < 32
|
||||||
model_arrows_nb = 6; // assert : l'emplacement des flèches est contraint
|
model_arrows_nb = 1; // 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
|
||||||
pref_3D_xor_2D_space = 0; // 0 = 3D 1 = 2D
|
pref_3D_xor_2D_space = 1; // 0 = 3D 1 = 2D
|
||||||
pref_3D_xor_2D_arrows = 0; // 0 = 3D 1 = 2D
|
pref_3D_xor_2D_arrows = 0; // 0 = 3D 1 = 2D
|
||||||
pref_mark_unit_space = 3; // 0 = no marks, 1 = 1st, 2 = last, 3 = both
|
pref_mark_unit_space = 2; // 0 = no marks, 1 = 1st, 2 = last, 3 = both
|
||||||
pref_style_lines_planes = 0; // 0 = arrows as lines, 1 = as planes, 2 = mix
|
pref_style_lines_planes = 0; // 0 = arrows as lines, 1 = as planes, 2 = mix
|
||||||
pref_style_mix_colors = 0; // TODO
|
pref_style_mix_colors = 0; // TODO
|
||||||
}
|
}
|
||||||
|
@ -557,7 +557,7 @@ static void get_model_data_and_user_preferences(){
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#define S 1
|
||||||
static void compute_buffers_sizes(int model_space_size_x,
|
static void compute_buffers_sizes(int model_space_size_x,
|
||||||
int model_space_size_y,
|
int model_space_size_y,
|
||||||
int model_space_size_z,
|
int model_space_size_z,
|
||||||
|
@ -593,8 +593,10 @@ static void compute_buffers_sizes(int model_space_size_x,
|
||||||
|
|
||||||
/* buffer_plans_size est fonction de : model_space_size_x, model_arrows_nb et de pref_style_lines_planes */
|
/* buffer_plans_size est fonction de : model_space_size_x, model_arrows_nb et de pref_style_lines_planes */
|
||||||
|
|
||||||
if (0) printf("graphics.buffers_sizes : %u vertices, %u colors, %u lines, %u plans. (space_size_x = %d)\n",
|
if (S) printf("allocated buffers sizes :%4d/3 = %3d vertices, %4d/3 = %3d colors,\
|
||||||
buffer_vertex_size, buffer_colors_size, buffer_lines_size, buffer_plans_size, model_space_size_x);
|
%4d/2 = %3d lines, %4d/3 = %3d plans. (space_size_x = %d)\n",
|
||||||
|
buffer_vertex_size, buffer_vertex_size / 3, buffer_colors_size, buffer_colors_size / 3,
|
||||||
|
buffer_lines_size, buffer_lines_size / 2, buffer_plans_size, buffer_plans_size / 3, model_space_size_x);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -647,12 +649,7 @@ void graphics_init_buffers(const void *gl_area)
|
||||||
buffer_vertex_origin,
|
buffer_vertex_origin,
|
||||||
buffer_colors_origin,
|
buffer_colors_origin,
|
||||||
buffer_lines_origin,
|
buffer_lines_origin,
|
||||||
buffer_plans_origin,
|
buffer_plans_origin);
|
||||||
|
|
||||||
buffer_vertex_size,
|
|
||||||
buffer_colors_size,
|
|
||||||
buffer_lines_size,
|
|
||||||
buffer_plans_size);
|
|
||||||
|
|
||||||
GLuint vao, vertex_buffer, color_buffer;
|
GLuint vao, vertex_buffer, color_buffer;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue