REF: Dans un espace cubique de taille quelconque, cubes et centres dessinés

This commit is contained in:
Jean Sirmai 2023-08-14 12:04:45 +02:00
parent 8fc9f6c0e3
commit 9df9383b72
Signed by: jean
GPG Key ID: FB3115C340E057E3
6 changed files with 118 additions and 184 deletions

View File

@ -26,9 +26,9 @@
#include <stdbool.h> #include <stdbool.h>
#include <GL/glu.h> #include <GL/glu.h>
bool compute_space(long model_space_size_x, bool compute_space(int cube_side,
long model_space_size_y, // long model_space_size_y,
long model_space_size_z, // long model_space_size_z,
GLuint *arrows, GLuint *arrows,
int model_arrows_nb, int model_arrows_nb,
@ -45,9 +45,6 @@ bool compute_space(long model_space_size_x,
GLuint *plan_origin); GLuint *plan_origin);
bool draw_some_arrows (GLuint *lines_origin, bool draw_some_arrows (GLuint *lines_origin,
long s, long stx, long sty, int s, int stx, int sty,
GLuint *arrows, int arrows_nb); GLuint *arrows, int arrows_nb);
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);

BIN
side = 11.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
side = 21.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

BIN
side = 5.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@ -18,7 +18,7 @@
* GNU Affero General Public License for more details. * GNU Affero General Public License for more details.
* *
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * aint with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
//#pragma once //#pragma once
@ -41,14 +41,14 @@
#include "../../include/graphics.h" #include "../../include/graphics.h"
#include "../../include/buffers.h" #include "../../include/buffers.h"
static long vertex_index = 0; static int vertex_index = 0;
static long colors_index = 0; static int colors_index = 0;
static long lines_index = 0; static int lines_index = 0;
static long plans_index = 0; static int plans_index = 0;
static bool grids_intersections (long x, long y, long z, static bool grids_intersections (int x, int y, int z,
GLfloat *vertex_origin, GLfloat *colors_origin) GLfloat *vertex_origin, GLfloat *colors_origin)
{ {
@ -87,7 +87,7 @@ static bool grids_intersections (long x, long y, long z,
} }
static bool central_stars (long x, long y, long z, static bool central_stars (int x, int y, int z,
GLfloat *vertex_origin, GLfloat *colors_origin) GLfloat *vertex_origin, GLfloat *colors_origin)
{ {
@ -158,13 +158,13 @@ static bool central_stars (long x, long y, long z,
vertex_index += 3; vertex_index += 3;
*(colors_origin + colors_index + 0) = 1.0f; *(colors_origin + colors_index + 0) = 1.0f;
*(colors_origin + colors_index + 1) = 1.3f; *(colors_origin + colors_index + 1) = 0.3f;
*(colors_origin + colors_index + 2) = 0.3f; *(colors_origin + colors_index + 2) = 0.3f;
colors_index += 3; colors_index += 3;
*(colors_origin + colors_index + 0) = 1.0f; *(colors_origin + colors_index + 0) = 1.0f;
*(colors_origin + colors_index + 1) = 1.3f; *(colors_origin + colors_index + 1) = 0.3f;
*(colors_origin + colors_index + 2) = 0.3f; *(colors_origin + colors_index + 2) = 0.3f;
colors_index += 3; colors_index += 3;
@ -184,14 +184,14 @@ static bool central_stars (long x, long y, long z,
vertex_index += 3; vertex_index += 3;
*(colors_origin + colors_index + 0) = 0.3f; *(colors_origin + colors_index + 0) = 1.0f;
*(colors_origin + colors_index + 1) = 1.3f; *(colors_origin + colors_index + 1) = 0.3f;
*(colors_origin + colors_index + 2) = 0.3f; *(colors_origin + colors_index + 2) = 0.3f;
colors_index += 3; colors_index += 3;
*(colors_origin + colors_index + 0) = 0.3f; *(colors_origin + colors_index + 0) = 1.0f;
*(colors_origin + colors_index + 1) = 1.3f; *(colors_origin + colors_index + 1) = 0.3f;
*(colors_origin + colors_index + 2) = 0.3f; *(colors_origin + colors_index + 2) = 0.3f;
colors_index += 3; colors_index += 3;
@ -203,7 +203,7 @@ static bool central_stars (long x, long y, long z,
} }
static bool centers (long x, long y, long z, static bool centers (int x, int y, int z,
GLfloat *vertex_origin, GLfloat *colors_origin) GLfloat *vertex_origin, GLfloat *colors_origin)
{ {
float max = fmax(x, y); float max = fmax(x, y);
@ -264,8 +264,8 @@ static void draw_line (GLuint *lines_origin, int a, int b)
} }
static void draw_ridges_3D (long x, long y, long z, static void draw_ridges_3D (int x, int y, int z,
long step_x, long step_y, long step_z, int step_x, int step_y, int step_z,
GLuint *lines_origin) GLuint *lines_origin)
{ {
draw_line (lines_origin, step_z * 0 + step_y * 0 + step_x * 0, step_z * 0 + step_y * 0 + step_x * x); draw_line (lines_origin, step_z * 0 + step_y * 0 + step_x * 0, step_z * 0 + step_y * 0 + step_x * x);
@ -283,8 +283,8 @@ static void draw_ridges_3D (long x, long y, long z,
} }
static bool draw_grids_3D (long x, long y, long z, static bool draw_grids_3D (int x, int y, int z,
long step_x, long step_y, long step_z, int step_x, int step_y, int step_z,
GLuint *lines_origin, GLuint *lines_origin,
int pref_show_grid) int pref_show_grid)
{ {
@ -325,8 +325,8 @@ static bool draw_grids_3D (long x, long y, long z,
static void diagonal_test(long x, long y, long z, static void diagonal_test(int x, int y, int z,
long step_x, long step_y, long step_z, int step_x, int step_y, int step_z,
GLuint *lines_origin) GLuint *lines_origin)
{ {
draw_line (lines_origin, 0, step_z * z + step_y * y + step_x * x); draw_line (lines_origin, 0, step_z * z + step_y * y + step_x * x);
@ -336,15 +336,23 @@ static void diagonal_test(long x, long y, long z,
static void draw_a_central_star(GLuint *lines_origin, long n) static void draw_a_central_star(GLuint *lines_origin, int n)
{ {
draw_line (lines_origin, n + 0, n + 1); draw_line (lines_origin, n + 0, n + 1);
draw_line (lines_origin, n + 2, n + 3); draw_line (lines_origin, n + 2, n + 3);
draw_line (lines_origin, n + 4, n + 5); draw_line (lines_origin, n + 4, n + 5);
} }
static void draw_a_central_star_in_a_cube(GLuint *lines_origin, long n, int side_size) static void draw_a_central_star_in_a_cubic_space(GLuint *lines_origin, int n, int side_size)
{ {
/* DANS UN CUBE DE COTE 3 LE CENTRE EST À 3 x 3 x 3 = 27 / 2 = 13,5 >> 13 * 6
* DANS UN CUBE DE COTE 5 LE CENTRE EST À 5 x 5 x 5 = 125 / 2 = 62,5 >> 62 * 6
* DANS UN CUBE DE COTE 7 LE CENTRE EST À 7 x 7 x 7 = 342 / 2 = 171,5 >> 171 * 6
* ETC.
* JE CHOISIS DES CUBES AYANT DES COTÉS IMPAIRS POUR QU'IL Y AIT UNE CASE CENTRALE
*/
int s = side_size * side_size * side_size / 2;
draw_a_central_star(lines_origin, n + s * 6);
} }
// I'm standing on Earth (any planet or star or spinning spheroid, in fact) // I'm standing on Earth (any planet or star or spinning spheroid, in fact)
@ -357,48 +365,34 @@ static void draw_a_central_star_in_a_cube(GLuint *lines_origin, long n, int side
#define SOUTH 4 // + z jaune #define SOUTH 4 // + z jaune
#define NORTH 5 // - z bleu #define NORTH 5 // - z bleu
bool draw_some_arrows (GLuint *lines_origin, long s, long stx, long sty, bool draw_some_arrows (GLuint *lines_origin, int s, int stx, int sty,
GLuint *arrows, int arrows_nb) {return 1;} GLuint *arrows, int arrows_nb) {return 1;}
bool compute_space(long space_x, long space_y, long space_z, bool compute_space(int cube_side,
GLuint *arrows, int model_arrows_nb, GLuint *arrows, int model_arrows_nb,
int pref_show_grid, int pref_test_diagonal, int pref_show_grid, int pref_test_diagonal,
GLfloat *vertex_origin, GLfloat *colors_origin, GLfloat *vertex_origin, GLfloat *colors_origin,
GLuint *lines_origin, GLuint *plans_origin) GLuint *lines_origin, GLuint *plans_origin)
{ {
grids_intersections (space_x, space_y, space_z, vertex_origin, colors_origin); grids_intersections (cube_side, cube_side, cube_side, vertex_origin, colors_origin);
central_stars (space_x, space_y, space_z, vertex_origin, colors_origin); central_stars (cube_side, cube_side, cube_side, vertex_origin, colors_origin);
centers (space_x, space_y, space_z, vertex_origin, colors_origin); centers (cube_side, cube_side, cube_side, vertex_origin, colors_origin);
long step_z = 1, step_y = space_z + 1, step_x = (space_z + 1) * (space_y + 1); int step_z = 1, step_y = cube_side + 1, step_x = (cube_side + 1) * (cube_side + 1);
draw_grids_3D (space_x, space_y, space_z, step_x, step_y, step_z, lines_origin, pref_show_grid); if (pref_show_grid > 0) draw_ridges_3D (cube_side, cube_side, cube_side, step_x, step_y, step_z, lines_origin);
if (pref_show_grid > 0) draw_ridges_3D (space_x, space_y, space_z, step_x, step_y, step_z, lines_origin); draw_grids_3D (cube_side, cube_side, cube_side, step_x, step_y, step_z, lines_origin, pref_show_grid);
long s = step_z * space_z + step_y * space_y + step_x * space_x + 1; int s = step_z * cube_side + step_y * cube_side + step_x * cube_side + 1;
int side_size = space_x; /* IT IS A CUBE ! space_x = space_y = space_z */ int side_size = cube_side; /* IT IS A CUBE ! space_x = space_y = space_z */
draw_a_central_star_in_a_cube (lines_origin, s, side_size); draw_a_central_star_in_a_cubic_space (lines_origin, s, side_size);
if (0) for (int i = 0; i < side_size * side_size * side_size; i ++)
draw_a_central_star (lines_origin, s + i * 6);
draw_a_central_star (lines_origin, s + 13 * 6); // draw_line (lines_origin, 3500, 2422);// further experiments...
/* DANS UN CUBE DE COTE 3 LE CENTRE EST À 3 x 3 x 3 = 27 / 2 = 14 >> 13 * 6 if (pref_test_diagonal) diagonal_test (cube_side, cube_side, cube_side, step_x, step_y, step_z, lines_origin);
* DANS UN CUBE DE COTE 5 LE CENTRE EST À 5 x 5 x 5 = 125 / 2 = 62 >> 62 * 6
* DANS UN CUBE DE COTE 7 LE CENTRE EST À 7 x 7 x 7 = 342 / 2 = 171 >> 171 * 6
* JE CHOISIS DES CUBES AYANT DES COTÉS IMPAIRS POUR QU'IL Y AIT UNE CASE CENTRALE
*/
// draw_line (lines_origin, 2800, 3500);
// draw_line (lines_origin, 3500, 2422);//
// draw_line (lines_origin, 3500, 2606);
if (pref_test_diagonal) diagonal_test (space_x, space_y, space_z, step_x, step_y, step_z, lines_origin);
return 0; return 0;
} }
@ -411,59 +405,9 @@ bool compute_space(long space_x, long space_y, long space_z,
// S C O R I E S ---------------------------------------------------
/* static void draw_an_arrow_East_or_West (GLuint *lines_origin, int s, int weight, int site) */
// S C O R I E S --------------------------------------------------------
// draw_a_central_star (lines_origin, s + 1 + 3 * (29 * 2 * 6)); // OK NORTH 58
// draw_a_central_star (lines_origin, s + 1 + 3 * (19 * 3 * 6)); // CENTRE 57
// draw_a_central_star (lines_origin, s + 1 + 3 * ( 7 * 8 * 6)); // OK SOUTH 56
// draw_a_central_star (lines_origin, s + 1 + 3 * (106 * 6 )); // Ok EAST 19 x 3 + 7 x 7 (57 + 49)
// draw_a_central_star (lines_origin, s + 1 + 3 * (8 * 6)); // OK WEST 19 x 3 - 7 x 7 (57 - 49)
// draw_a_central_star (lines_origin, s + 1 + 3 * (15 * 6)); // W Z
// draw_a_central_star (lines_origin, s + 1 + 3 * (1 * 6)); // W A
// draw_a_central_star (lines_origin, s + 1 + 3 * (49 * 6)); // S A
// draw_a_central_star (lines_origin, s + 1 + 3 * (7 * 6)); // W S
// draw_a_central_star (lines_origin, s + 1 + 3 * (9 * 6)); // W N
// draw_a_central_star (lines_origin, s + 1 + 3 * (105 * 6)); // E S
// draw_a_central_star (lines_origin, s + 1 + 3 * (19 * 6 * 6 - 12)); // E A S
// draw_a_central_star (lines_origin, s + 1 + 3 * (49 * 2 * 6)); // E A S
// draw_a_central_star (lines_origin, s + 1 + 3 * (19 * 6 * 6)); // E Z S << Last One
// draw_a_central_star (lines_origin, s + 1 + 3 * (19 * 6 * 6 - 6)); // E A
// draw_a_central_star (lines_origin, s + 1 + 3 * (19 * 6 * 4)); //
// draw_a_central_star (lines_origin, s + 1 + 171 * 6);
// 4 x 6 = W 10 x 6 = A 14 x 6 = N
// 1 x 6 = WA 3 x 6 = WS 9 x 6 = AS 15 x 6 = ZS 21 x 6 = ES
// 0 x 6 = WAS 2 x 6 = WAN 6 x 6 = WZS 8 x 6 = WZN 12 x 6 = EZS
// 27 x 6 > out
// if (0) draw_some_arrows_demo (lines_origin, s, space_x, space_y, space_z, arrows, model_arrows_nb);
// if (0) draw_some_arrows (lines_origin, s, space_z * space_y, space_z, arrows, model_arrows_nb);
// X - X = EAST - WEST = rouge - cyan
// Y - Y = ZENITH - NADIR = vert - magenta
// Z - Z = SOUTH - NORTH = jaune - bleu
/* static void draw_an_arrow_East_or_West (GLuint *lines_origin, long s, int weight, int site) */
/* { */ /* { */
/* draw_line (lines_origin, s + 2, s + 6 + site % 2); */ /* draw_line (lines_origin, s + 2, s + 6 + site % 2); */
/* draw_line (lines_origin, s + 3, s + 6 + site % 2); */ /* draw_line (lines_origin, s + 3, s + 6 + site % 2); */
@ -472,7 +416,7 @@ bool compute_space(long space_x, long space_y, long space_z,
/* draw_line (lines_origin, s + 5, s + 6 + site % 2); */ /* draw_line (lines_origin, s + 5, s + 6 + site % 2); */
/* } */ /* } */
/* static void draw_an_arrow_Zenith_or_Nadir (GLuint *lines_origin, long s, int weight, int site) */ /* static void draw_an_arrow_Zenith_or_Nadir (GLuint *lines_origin, int s, int weight, int site) */
/* { */ /* { */
/* draw_line (lines_origin, s + 0, s + 8 + site % 2); */ /* draw_line (lines_origin, s + 0, s + 8 + site % 2); */
/* draw_line (lines_origin, s + 1, s + 8 + site % 2); */ /* draw_line (lines_origin, s + 1, s + 8 + site % 2); */
@ -481,7 +425,7 @@ bool compute_space(long space_x, long space_y, long space_z,
/* draw_line (lines_origin, s + 5, s + 8 + site % 2); */ /* draw_line (lines_origin, s + 5, s + 8 + site % 2); */
/* } */ /* } */
/* static void draw_an_arrow_North_or_South (GLuint *lines_origin, long s, int weight, int site) */ /* static void draw_an_arrow_North_or_South (GLuint *lines_origin, int s, int weight, int site) */
/* { */ /* { */
/* draw_line (lines_origin, s + 0, s + 10 + site % 2); */ /* draw_line (lines_origin, s + 0, s + 10 + site % 2); */
/* draw_line (lines_origin, s + 1, s + 10 + site % 2); */ /* draw_line (lines_origin, s + 1, s + 10 + site % 2); */

View File

@ -20,7 +20,7 @@
* GNU Affero General Public License for more details. * GNU Affero General Public License for more details.
* *
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * aint with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <assert.h> #include <assert.h>
@ -47,12 +47,10 @@
/* ----------------- V A R I A B L E S G L O B A L E S ------------------ */ /* ----------------- V A R I A B L E S G L O B A L E S ------------------ */
// int model_dim; < INUTILE : dim est fonction de model_space_size_x, y ,z) */ // int model_dim; < INUTILE : dim est fonction de cube_side, y ,z) */
long model_space_size_x = 0; int cube_side = 0;
long model_space_size_y = 0; int arrows_nb = 0;
long model_space_size_z = 0; int central_stars_nb = 0;
long arrows_nb = 0;
long central_stars_nb = 0;
GLfloat *buffer_vertex_origin = NULL; GLfloat *buffer_vertex_origin = NULL;
GLfloat *buffer_colors_origin = NULL; GLfloat *buffer_colors_origin = NULL;
@ -67,10 +65,10 @@ GLuint *buffer_plans_origin = NULL;
int pref_show_grid = 0; // 0, 1, 2, 3, 5, 6, 10, 15, 30, etc int pref_show_grid = 0; // 0, 1, 2, 3, 5, 6, 10, 15, 30, etc
int pref_test_diagonal = 0; // diagonal test int pref_test_diagonal = 0; // diagonal test
long buffer_vertex_size = 0; int buffer_vertex_size = 0;
long buffer_colors_size = 0; int buffer_colors_size = 0;
long buffer_lines_size = 0; // previously in graphics.h struct gl_area_entry.GLuint line_indices_nb; int buffer_lines_size = 0; // previously in graphics.h struct gl_area_entry.GLuint line_indices_nb;
long buffer_plans_size = 0; // previously in graphics.h struct gl_area_entry.GLuint plan_indices_nb; int buffer_plans_size = 0; // previously in graphics.h struct gl_area_entry.GLuint plan_indices_nb;
/* ----------------- O P E N G L D E B U G M E S S A G E S ------------ */ /* ----------------- O P E N G L D E B U G M E S S A G E S ------------ */
@ -555,23 +553,26 @@ GLuint arrows[] = {
static void get_model_data_and_user_preferences(){ static void get_model_data_and_user_preferences(){
/* DANS UN CUBE DE COTE 3 LE CENTRE EST À 3 x 3 x 3 = 27 / 2 = 14 >> 13 * 6
* DANS UN CUBE DE COTE 5 LE CENTRE EST À 5 x 5 x 5 = 125 / 2 = 62 >> 62 * 6
* DANS UN CUBE DE COTE 7 LE CENTRE EST À 7 x 7 x 7 = 342 / 2 = 171 >> 171 * 6
* JE CHOISIS DES CUBES AYANT DES COTÉS IMPAIRS POUR QU'IL Y AIT UNE CASE CENTRALE
*/
model_space_size_x = 3; // 0 < model_space_size_x cube_side = 5; // 0 < cube_side
model_space_size_y = 3; // 0 < model_space_size_y
model_space_size_z = 3; // 0 < model_space_size_z
long arrows_array_size = 0; int arrows_array_size = 0;
while (*(arrows + arrows_array_size) != un_nombre_ad_hoc_que_je_mets_a_la_fin_du_tableau_pour_en_mesurer_la_taille) while (*(arrows + arrows_array_size) != un_nombre_ad_hoc_que_je_mets_a_la_fin_du_tableau_pour_en_mesurer_la_taille)
arrows_array_size ++; arrows_array_size ++;
printf("get_model_data_and_user_preferences (566) arrows_array_size = %ld (arrows_nb = %ld)\n", arrows_array_size, arrows_array_size / 5); printf("get_model_data_and_user_preferences (566) arrows_array_size = %d (arrows_nb = %d)\n", arrows_array_size, arrows_array_size / 5);
arrows_nb = arrows_array_size / 5; arrows_nb = arrows_array_size / 5;
// assert : l'emplacement des flèches est contraint par space_size_x, y, z et le nombre de sites // assert : l'emplacement des flèches est contraint par space_size_x, y, z et le nombre de sites
central_stars_nb = 1; central_stars_nb = cube_side * cube_side * cube_side;
pref_show_grid = 1; // 0, 1, 2, 3, 5, 6, 10, 15, 30, etc pref_show_grid = 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
pref_test_diagonal = 1; pref_test_diagonal = 0;
} }
@ -579,23 +580,21 @@ static void get_model_data_and_user_preferences(){
static void compute_buffers_sizes(int model_space_size_x, static void compute_buffers_sizes(int cube_side,
int model_space_size_y,
int model_space_size_z,
int pref_test_diagonal) int pref_test_diagonal)
{ {
// XXX ONLY space and no arrows // XXX ONLY space and no arrows
long grids_intersections = (model_space_size_x + 1) int grids_intersections = (cube_side + 1)
* (model_space_size_y + 1) * (cube_side + 1)
* (model_space_size_z + 1); * (cube_side + 1);
long central_stars = (model_space_size_x) int central_stars = (cube_side)
* (model_space_size_y) * (cube_side)
* (model_space_size_z) * (cube_side)
* 6; // 6 is to draw the small central star * 6; // 6 is to draw the small central star
long centers = (model_space_size_x) int centers = (cube_side)
* (model_space_size_y) * (cube_side)
* (model_space_size_z) * (cube_side)
* 2; // and 2 is to draw two centers for each cube * 2; // and 2 is to draw two centers for each cube
// one will be for the arrows sources (blue ?) // one will be for the arrows sources (blue ?)
// and the other, for their targets (red ?) // and the other, for their targets (red ?)
@ -607,10 +606,10 @@ static void compute_buffers_sizes(int model_space_size_x,
buffer_colors_size = buffer_vertex_size; buffer_colors_size = buffer_vertex_size;
buffer_plans_size = 0; buffer_plans_size = 0;
long grids_lines = int grids_lines =
(pref_show_grid % 2 == 0) * (model_space_size_x + 1) * (model_space_size_y + 1) (pref_show_grid % 2 == 0) * (cube_side + 1) * (cube_side + 1)
+ (pref_show_grid % 3 == 0) * (model_space_size_x + 1) * (model_space_size_z + 1) + (pref_show_grid % 3 == 0) * (cube_side + 1) * (cube_side + 1)
+ (pref_show_grid % 5 == 0) * (model_space_size_y + 1) * (model_space_size_z + 1); + (pref_show_grid % 5 == 0) * (cube_side + 1) * (cube_side + 1);
if (pref_show_grid != 1) buffer_lines_size = grids_lines * 2; if (pref_show_grid != 1) buffer_lines_size = grids_lines * 2;
if (pref_show_grid > 0) buffer_lines_size += 12 * 2; // space ridges if (pref_show_grid > 0) buffer_lines_size += 12 * 2; // space ridges
@ -622,8 +621,8 @@ static void compute_buffers_sizes(int model_space_size_x,
// buffer_lines_size -= 2; // == TEST LINES BUFFER SIZE // buffer_lines_size -= 2; // == TEST LINES BUFFER SIZE
if (0) printf("allocated buffers sizes :%4ld/3 = %3ld vertices, %4ld/3 = %3ld colors,\ if (0) printf("allocated buffers sizes :%4d/3 = %3d vertices, %4d/3 = %3d colors,\
%4ld/2 = %3ld lines, %4ld/3 = %3ld plans.\n", %4d/2 = %3d lines, %4d/3 = %3d plans.\n",
buffer_vertex_size, buffer_vertex_size / 3, buffer_vertex_size, buffer_vertex_size / 3,
buffer_colors_size, buffer_colors_size / 3, buffer_colors_size, buffer_colors_size / 3,
buffer_lines_size, buffer_lines_size / 2, buffer_lines_size, buffer_lines_size / 2,
@ -661,19 +660,14 @@ void graphics_init_buffers(const void *gl_area)
get_model_data_and_user_preferences(); get_model_data_and_user_preferences();
/* une struct en retour pour ne plus utiliser de variables globales ? */ /* une struct en retour pour ne plus utiliser de variables globales ? */
compute_buffers_sizes (model_space_size_x, compute_buffers_sizes (cube_side, pref_test_diagonal);
model_space_size_y,
model_space_size_z,
pref_test_diagonal);
buffer_vertex_origin = g_malloc0(buffer_vertex_size * sizeof(GLfloat) * 2); buffer_vertex_origin = g_malloc0(buffer_vertex_size * sizeof(GLfloat) * 2);
buffer_colors_origin = g_malloc0(buffer_colors_size * sizeof(GLfloat) * 2); buffer_colors_origin = g_malloc0(buffer_colors_size * sizeof(GLfloat) * 2);
buffer_lines_origin = g_malloc0(buffer_lines_size * 2 * sizeof(GLuint) * 2); buffer_lines_origin = g_malloc0(buffer_lines_size * 2 * sizeof(GLuint) * 2);
buffer_plans_origin = g_malloc0(buffer_plans_size * 3 * sizeof(GLuint) * 2); buffer_plans_origin = g_malloc0(buffer_plans_size * 3 * sizeof(GLuint) * 2);
compute_space (model_space_size_x, compute_space (cube_side,
model_space_size_y,
model_space_size_z,
arrows, arrows,
arrows_nb, arrows_nb,
@ -686,14 +680,14 @@ void graphics_init_buffers(const void *gl_area)
buffer_lines_origin, buffer_lines_origin,
buffer_plans_origin); buffer_plans_origin);
long step_z = 1, int step_z = 1,
step_y = model_space_size_z + 1, step_y = cube_side + 1,
step_x = (model_space_size_z + 1) * (model_space_size_y + 1); step_x = (cube_side + 1) * (cube_side + 1);
long s = step_z * model_space_size_z + step_y * model_space_size_y int s = step_z * cube_side + step_y * cube_side
+ step_x * model_space_size_x; + step_x * cube_side;
draw_some_arrows (buffer_lines_origin, s, draw_some_arrows (buffer_lines_origin, s,
model_space_size_z * model_space_size_y, model_space_size_z, cube_side * cube_side, cube_side,
arrows, arrows_nb); arrows, arrows_nb);
GLuint vao, vertex_buffer, color_buffer; GLuint vao, vertex_buffer, color_buffer;
@ -855,10 +849,10 @@ void graphics_draw(const void *gl_area)
/* #define DETAIL 0 */ /* #define DETAIL 0 */
/* static bool rewrite_arrow (GLuint *arrows, long address, long weight, */ /* static bool rewrite_arrow (GLuint *arrows, int address, int weight, */
/* long site, long x, long y, long z) */ /* int site, int x, int y, int z) */
/* { */ /* { */
/* if (DETAIL) printf("write the arrow weight to %ld at (%ld, %ld, %ld, %ld)\n",\ */ /* if (DETAIL) printf("write the arrow weight to %d at (%d, %d, %d, %d)\n",\ */
/* weight, site, x, y, z); */ /* weight, site, x, y, z); */
/* *(arrows + address + 0) = weight; */ /* *(arrows + address + 0) = weight; */
@ -866,9 +860,9 @@ void graphics_draw(const void *gl_area)
/* return 1; */ /* replaces the load of the existing arrow by the load 'weight' */ /* return 1; */ /* replaces the load of the existing arrow by the load 'weight' */
/* } */ /* } */
/* static bool create_arrow (GLuint *arrows, long weight, long site, long x, long y, long z) */ /* static bool create_arrow (GLuint *arrows, int weight, int site, int x, int y, int z) */
/* { */ /* { */
/* if (1) printf("create a new arrow with weight = %ld at (%ld, %ld, %ld, %ld)\n",\ */ /* if (1) printf("create a new arrow with weight = %d at (%d, %d, %d, %d)\n",\ */
/* weight, site, x, y, z); */ /* weight, site, x, y, z); */
/* arrows_nb ++; */ /* arrows_nb ++; */
@ -887,10 +881,10 @@ void graphics_draw(const void *gl_area)
/* return 1; */ /* return 1; */
/* } */ /* } */
/* static bool erase_arrow (GLuint *arrows, long address, */ /* static bool erase_arrow (GLuint *arrows, int address, */
/* long site, long x, long y, long z) */ /* int site, int x, int y, int z) */
/* { */ /* { */
/* if (DETAIL) printf("erase arrow at address %ld with values (%ld, %ld, %ld, %ld)",\ */ /* if (DETAIL) printf("erase arrow at address %d with values (%d, %d, %d, %d)",\ */
/* address / 5, site, x, y, z); */ /* address / 5, site, x, y, z); */
/* if (DETAIL) printf(" last arrow is %d, %d, %d, %d, %d\n", */ /* if (DETAIL) printf(" last arrow is %d, %d, %d, %d, %d\n", */
/* *(arrows + (arrows_nb - 1) * 5 + 0), */ /* *(arrows + (arrows_nb - 1) * 5 + 0), */
@ -912,12 +906,12 @@ void graphics_draw(const void *gl_area)
/* return 1; */ /* return 1; */
/* } */ /* } */
/* static long check_for_arrow (GLuint *arrows, long site, long x, long y, long z) */ /* static int check_for_arrow (GLuint *arrows, int site, int x, int y, int z) */
/* { */ /* { */
/* if (arrows_nb <= 1) return -1; */ /* if (arrows_nb <= 1) return -1; */
/* printf("check_for_arrow (723) arrows_nb = %ld\n", arrows_nb); */ /* printf("check_for_arrow (723) arrows_nb = %d\n", arrows_nb); */
/* long address = -1, f_weight = -1, f_site = -1, f_x = -1, f_y = -1, f_z = -1; */ /* 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++) */ /* for (int i = 0; i < arrows_nb; i++) */
/* { */ /* { */
/* f_weight = *(arrows + i * 5 + 0); */ /* f_weight = *(arrows + i * 5 + 0); */
@ -928,33 +922,32 @@ void graphics_draw(const void *gl_area)
/* if (f_site == site && f_x == x && f_y == y && f_z == z) { */ /* if (f_site == site && f_x == x && f_y == y && f_z == z) { */
/* address = i * 5; */ /* address = i * 5; */
/* if (DETAIL) printf("arrows_nb = %ld checked arrow (%ld,%ld,%ld,%ld) found at address %ld (line %ld)",\ */ /* 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); */ /* arrows_nb, site, x, y, z, address, address / 5); */
/* if (DETAIL && f_weight > 1) printf(" weight = %ld", f_weight); */ /* if (DETAIL && f_weight > 1) printf(" weight = %d", f_weight); */
/* if (DETAIL) printf("\n"); */ /* if (DETAIL) printf("\n"); */
/* } */ /* } */
/* } */ /* } */
/* return address; returns the address of the arrow if there is one /* return address; returns the address of the arrow if there is one or (-1) if there is none */
/* or (-1) if there is none */
/* } */ /* } */
/* static void show_arrows_array (GLuint *arrows, long address, long weight, long site, long x, long y, long z) */ /* static void show_arrows_array (GLuint *arrows, int address, int weight, int site, int x, int y, int z) */
/* { */ /* { */
/* printf("\n[ n] load | site x y z ----- < arrows_nb = %ld > ------", arrows_nb); */ /* printf("\n[ n] load | site x y z ----- < arrows_nb = %d > ------", arrows_nb); */
/* if (arrows_nb == 0) printf("--------------------------- no arrows\n"); */ /* if (arrows_nb == 0) printf("--------------------------- no arrows\n"); */
/* else if (address == -1) printf("--------------------------- create new arrow\n"); */ /* else if (address == -1) printf("--------------------------- create new arrow\n"); */
/* else printf("--------------------------- erase arrow at address = %ld / 5\n", address); */ /* else printf("--------------------------- erase arrow at address = %d / 5\n", address); */
/* for (int i = 0; i < arrows_nb; i++) */ /* for (int i = 0; i < arrows_nb; i++) */
/* { */ /* { */
/* printf("[%2d] = %2d | %2d, %2d, %2d, %2d ",\ */ /* printf("[%2d] = %2d | %2d, %2d, %2d, %2d ",\ */
/* i, *(arrows + i * 5 + 0), *(arrows + i * 5 + 1), *(arrows + i * 5 + 2),\ */ /* i, *(arrows + i * 5 + 0), *(arrows + i * 5 + 1), *(arrows + i * 5 + 2),\ */
/* *(arrows + i * 5 + 3), *(arrows + i * 5 + 4)); */ /* *(arrows + i * 5 + 3), *(arrows + i * 5 + 4)); */
/* if (weight == 0 && i == address / 5) printf(" <<<| < - > (%d, %d, %d, %d) @ [%ld]",\ */ /* if (weight == 0 && i == address / 5) printf(" <<<| < - > (%d, %d, %d, %d) @ [%d]",\ */
/* *(arrows + i * 5 + 1), *(arrows + i * 5 + 2),\ */ /* *(arrows + i * 5 + 1), *(arrows + i * 5 + 2),\ */
/* *(arrows + i * 5 + 3), *(arrows + i * 5 + 4), address / 5); */ /* *(arrows + i * 5 + 3), *(arrows + i * 5 + 4), address / 5); */
/* if (weight > 0 && i == arrows_nb - 1) printf(" <<< < + > (%d, %d, %d, %d) @ [%ld]",\ */ /* if (weight > 0 && i == arrows_nb - 1) printf(" <<< < + > (%d, %d, %d, %d) @ [%d]",\ */
/* *(arrows + i * 5 + 1), *(arrows + i * 5 + 2),\ */ /* *(arrows + i * 5 + 1), *(arrows + i * 5 + 2),\ */
/* *(arrows + i * 5 + 3), *(arrows + i * 5 + 4), address / 5); */ /* *(arrows + i * 5 + 3), *(arrows + i * 5 + 4), address / 5); */
/* if (weight == 0 && i > address / 5 && i < arrows_nb - 1) printf(" |"); */ /* if (weight == 0 && i > address / 5 && i < arrows_nb - 1) printf(" |"); */
@ -964,9 +957,9 @@ void graphics_draw(const void *gl_area)
/* } */ /* } */
/* static bool set_arrow (GLuint *arrows, long weight, long site, long x, long y, long z) */ /* static bool set_arrow (GLuint *arrows, int weight, int site, int x, int y, int z) */
/* { */ /* { */
/* long address = (check_for_arrow (arrows, site, x, y, z)); */ /* int address = (check_for_arrow (arrows, site, x, y, z)); */
/* show_arrows_array(arrows, address, weight, site, x, y, z); */ /* show_arrows_array(arrows, address, weight, site, x, y, z); */
/* if (address == -1 && weight == 0) return 0; */ /* if (address == -1 && weight == 0) return 0; */