Compare commits
No commits in common. "9a1023b0b2f3032a337958520b2ee9b9083a2777" and "1a7a535f4590c63059b9f10f5649a940d18f4db8" have entirely different histories.
9a1023b0b2
...
1a7a535f45
|
@ -35,9 +35,7 @@
|
|||
#define VERTEX_SHADER_FILE "src/shaders/shader.vert"
|
||||
#define FRAG_SHADER_FILE "src/shaders/shader.frag"
|
||||
|
||||
static struct arrow_t *sworrah; /* "arrows" était devenu un peu trop populaire :
|
||||
* (je n'arrivais plus à facilement le distinguer de arrows_nb, par ex.)
|
||||
* et le 'h' final donne une petite touche sauvage... */
|
||||
static struct arrow_t *sworra;
|
||||
static GLfloat *buffer_vertex_origin = NULL;
|
||||
static GLfloat *buffer_colors_origin = NULL;
|
||||
static GLuint *buffer_lines_origin = NULL;
|
||||
|
@ -134,8 +132,7 @@ void graphics_write_vertex (GLfloat x, GLfloat y, GLfloat z)
|
|||
buffer_vertex_origin[buffer_vertex_size + 1] = y;
|
||||
buffer_vertex_origin[buffer_vertex_size + 2] = z;
|
||||
|
||||
if (1) printf("In graphics_write_vertex() buffer_vertex_size = %d > %d (%6.3f,%6.3f,%6.3f)\n",\
|
||||
buffer_vertex_size, buffer_vertex_size + 3, x, y, z);
|
||||
if (0) printf("buffer_vertex_size = %d (%6.3f,%6.3f,%6.3f)\n", buffer_vertex_size, x, y, z);
|
||||
|
||||
buffer_vertex_size += 3;
|
||||
}
|
||||
|
@ -552,9 +549,9 @@ bool graphics_shutdown(const void *gl_area)
|
|||
*/
|
||||
static int rewrite_arrow (int arrows_nb, int address, int load, int site, int x, int y, int z)
|
||||
{
|
||||
sworrah[address].load = load;
|
||||
sworra[address].load = load;
|
||||
|
||||
print_arrows_array (sworrah, arrows_nb, 2);
|
||||
print_arrows_array (sworra, arrows_nb, 2);
|
||||
|
||||
return arrows_nb;
|
||||
}
|
||||
|
@ -565,22 +562,22 @@ static int rewrite_arrow (int arrows_nb, int address, int load, int site, int x,
|
|||
*/
|
||||
static inline int create_arrow (int arrows_nb, int load, int site, int x, int y, int z)
|
||||
{
|
||||
void *newptr = g_realloc(sworrah, (arrows_nb + 1) * sizeof(struct arrow_t));
|
||||
void *newptr = g_realloc(sworra, (arrows_nb + 1) * sizeof(struct arrow_t));
|
||||
|
||||
if (newptr)
|
||||
sworrah = newptr;
|
||||
sworra = newptr;
|
||||
else
|
||||
perror("In create arrow, can't allocate new arrow buffer !\n");
|
||||
|
||||
sworrah[arrows_nb].load = load;
|
||||
sworrah[arrows_nb].site = site;
|
||||
sworrah[arrows_nb].x = x;
|
||||
sworrah[arrows_nb].y = y;
|
||||
sworrah[arrows_nb].z = z;
|
||||
sworra[arrows_nb].load = load;
|
||||
sworra[arrows_nb].site = site;
|
||||
sworra[arrows_nb].x = x;
|
||||
sworra[arrows_nb].y = y;
|
||||
sworra[arrows_nb].z = z;
|
||||
|
||||
arrows_nb ++;
|
||||
|
||||
print_arrows_array (sworrah, arrows_nb, 1);
|
||||
print_arrows_array (sworra, arrows_nb, 1);
|
||||
|
||||
return arrows_nb;
|
||||
}
|
||||
|
@ -594,26 +591,26 @@ static inline int erase_arrow (int arrows_nb, int address, int site, int x, int
|
|||
|
||||
if (arrows_nb > 0)
|
||||
{
|
||||
sworrah[address].load = sworrah[arrows_nb].load;
|
||||
sworrah[address].site = sworrah[arrows_nb].site;
|
||||
sworrah[address].x = sworrah[arrows_nb].x;
|
||||
sworrah[address].y = sworrah[arrows_nb].y;
|
||||
sworrah[address].z = sworrah[arrows_nb].z;
|
||||
sworra[address].load = sworra[arrows_nb].load;
|
||||
sworra[address].site = sworra[arrows_nb].site;
|
||||
sworra[address].x = sworra[arrows_nb].x;
|
||||
sworra[address].y = sworra[arrows_nb].y;
|
||||
sworra[address].z = sworra[arrows_nb].z;
|
||||
}
|
||||
|
||||
/* void *newptr = g_realloc(sworrah, arrows_nb * sizeof(struct arrow_t)); */
|
||||
/* void *newptr = g_realloc(sworra, arrows_nb * sizeof(struct arrow_t)); */
|
||||
|
||||
/* if (newptr) */
|
||||
/* sworrah = newptr; */
|
||||
/* sworra = newptr; */
|
||||
/* else */
|
||||
/* perror("In erase arrow, can't allocate new arrow buffer !\n"); */
|
||||
|
||||
print_arrows_array (sworrah, arrows_nb,0);
|
||||
print_arrows_array (sworra, arrows_nb,0);
|
||||
|
||||
return arrows_nb;
|
||||
}
|
||||
|
||||
static inline void show_user_action(struct arrow_t *sworrah, int arrows_nb, int address, int requested_weight,
|
||||
static inline void show_user_action(struct arrow_t *sworra, int arrows_nb, int address, int requested_weight,
|
||||
int current_weight, int site, int x, int y, int z);
|
||||
/*
|
||||
* Calls one of the functions create_arrow(), erase_arrow() or rewrite_arrow()
|
||||
|
@ -623,27 +620,27 @@ static inline void show_user_action(struct arrow_t *sworrah, int arrows_nb, int
|
|||
* - Current_weight of an arrow located at the requested address == requested_weight
|
||||
* - No arrow was found at the requested addres AND current_weight == requested_weight
|
||||
*/
|
||||
static inline int set_arrow (struct arrow_t *sworrah, int arrows_nb, int requested_weight, int site, int x, int y, int z) // , int buffer_vertex_size
|
||||
static inline int set_arrow (struct arrow_t *sworra, int arrows_nb, int requested_weight, int site, int x, int y, int z)
|
||||
{
|
||||
int address = -1, current_weight = -1;
|
||||
|
||||
#pragma omp parallel schedule(static, 12)
|
||||
{
|
||||
for (int i = 0; i < arrows_nb; i++) {
|
||||
if ((site == sworrah[i].site)
|
||||
&& (x == sworrah[i].x)
|
||||
&& (y == sworrah[i].y)
|
||||
&& (z == sworrah[i].z))
|
||||
if ((site == sworra[i].site)
|
||||
&& (x == sworra[i].x)
|
||||
&& (y == sworra[i].y)
|
||||
&& (z == sworra[i].z))
|
||||
{
|
||||
address = i * 5;
|
||||
current_weight = sworrah[i].load;
|
||||
current_weight = sworra[i].load;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
//printf("\n[%d]set_arrow() invoked with requested weight = %2d + ", arrows_nb, requested_weight);
|
||||
|
||||
if (TEST) show_user_action(sworrah, arrows_nb, address, requested_weight, current_weight, site, x, y, z);
|
||||
if (TEST) show_user_action(sworra, arrows_nb, address, requested_weight, current_weight, site, x, y, z);
|
||||
|
||||
if (address == -1 && requested_weight > 0)
|
||||
return create_arrow (arrows_nb, requested_weight, site, x, y, z);
|
||||
|
@ -654,9 +651,9 @@ static inline int set_arrow (struct arrow_t *sworrah, int arrows_nb, int request
|
|||
if (address >= 0 && current_weight != requested_weight)
|
||||
return rewrite_arrow (arrows_nb, address/5, requested_weight, site, x, y, z);
|
||||
|
||||
if (! TEST && address >= 0 && current_weight == requested_weight) print_arrows_array(sworrah, arrows_nb, 3);
|
||||
if (! TEST && address >= 0 && current_weight == requested_weight) print_arrows_array(sworra, arrows_nb, 3);
|
||||
|
||||
if (! TEST && address == -1 && requested_weight == 0) print_arrows_array(sworrah, arrows_nb, 4);
|
||||
if (! TEST && address == -1 && requested_weight == 0) print_arrows_array(sworra, arrows_nb, 4);
|
||||
|
||||
return arrows_nb;
|
||||
}
|
||||
|
@ -681,8 +678,8 @@ void __attribute__((optimize("no-unroll-loops"))) main_test_graphics (void)
|
|||
void srand(unsigned int seed); // printf ("Valeur max : %d\n", RAND_MAX); min + rand() % (max+1 - min);
|
||||
|
||||
int arbitrary = 3;
|
||||
int space_X = 3,// + rand() % arbitrary,
|
||||
space_Y = 2,// + rand() % arbitrary,
|
||||
int space_X = 1,// + rand() % arbitrary,
|
||||
space_Y = 1,// + rand() % arbitrary,
|
||||
space_Z = 1;// + rand() % arbitrary;
|
||||
int density_max = space_X * space_Y * space_Z;
|
||||
int max = fmax(space_X, space_Y); max = fmax(max, space_Z);
|
||||
|
@ -699,14 +696,14 @@ void __attribute__((optimize("no-unroll-loops"))) main_test_graphics (void)
|
|||
#pragma omp parallel
|
||||
{
|
||||
/* while (arrows_nb < specif_arrows_nb){ */
|
||||
arrows_nb = set_arrow (sworrah, arrows_nb,
|
||||
arrows_nb = set_arrow (sworra, arrows_nb,
|
||||
1,//rand() % arbitrary + 1, // load / weight
|
||||
0,//rand() % 6, // site,
|
||||
0,//rand() % space_X, // x
|
||||
0,//rand() % space_Y, // y
|
||||
0);//rand() % space_Z); // z
|
||||
|
||||
arrows_nb = set_arrow (sworrah, arrows_nb,
|
||||
arrows_nb = set_arrow (sworra, arrows_nb,
|
||||
1,//rand() % arbitrary + 1, // load / weight
|
||||
1,//rand() % 6, // site,
|
||||
0,//rand() % space_X, // x
|
||||
|
@ -719,6 +716,30 @@ void __attribute__((optimize("no-unroll-loops"))) main_test_graphics (void)
|
|||
/* } */
|
||||
printf("I N I T I A L D A T A A R E N O W S P E C I F I E D\n");
|
||||
}
|
||||
// clock_t start, end;
|
||||
|
||||
/* Recording the starting clock tick.*/
|
||||
// start = clock();
|
||||
|
||||
/* arbitrary = 26; */
|
||||
/* space_X = arbitrary; space_Y = arbitrary; space_Z = arbitrary; */
|
||||
/* density_max = space_X * space_Y * space_Z;
|
||||
* C E T T E Q U A D R U P L E B O U C L E
|
||||
* S A T U R E L ' E S P A C E S Y S T É M A T I Q U E M E N T */
|
||||
/* for (int i =0; i < space_X; i++) */
|
||||
/* for (int j =0; j < space_Y; j++) */
|
||||
/* for (int k =0; k < space_Z; k++) */
|
||||
/* for (int u =0; u < 6; u++) */
|
||||
/* arrows_nb = set_arrow (sworra, arrows_nb, */
|
||||
/* 1, // load / weight */
|
||||
/* u,//i % 6, // site, */
|
||||
/* i,//i % space_X, // x */
|
||||
/* j,//i % space_Y, // y */
|
||||
/* k//i % space_Z); */
|
||||
/* ); */
|
||||
// end = clock(); printf("Elapsed time %ld\n", end - start);
|
||||
|
||||
/* print_user_choices(sworra, arrows_nb, space_X, space_Y, space_Z, print_arrows_data, 0); */
|
||||
|
||||
/*--------------------------------------------------------------------------------*/
|
||||
|
||||
|
@ -730,111 +751,105 @@ void __attribute__((optimize("no-unroll-loops"))) main_test_graphics (void)
|
|||
|
||||
/* V E R T E X F I R S T */
|
||||
|
||||
int offset_vertex = 0, offset_colors = 0, offset_lines = 0;
|
||||
|
||||
/* S P A C E */
|
||||
|
||||
buffer_vertex_size += write_space_ridges_vertex (buffer_vertex_size, space_X, space_Y, space_Z);
|
||||
buffer_colors_size = buffer_vertex_size;
|
||||
// float max = fmax(x, y); max = fmax(max, z);
|
||||
offset_vertex += write_space_ridges_vertex (offset_vertex, space_X, space_Y, space_Z);
|
||||
offset_colors = offset_vertex;
|
||||
|
||||
if (1) printf("buffer_vertex_size after writing_space_ridges_vertex : %d (x 3 = %d)\n\n", buffer_vertex_size, buffer_vertex_size * 3);
|
||||
if (0) printf("offset_vertex after writing_space_ridges_vertex : %d (x 3 = %d)\n\n", offset_vertex, offset_vertex * 3);
|
||||
|
||||
buffer_vertex_size += write_grids_on_space_faces_vertex (space_X, space_Y, space_Z);
|
||||
buffer_colors_size = buffer_vertex_size;
|
||||
offset_vertex += write_grids_on_space_faces_vertex (space_X, space_Y, space_Z);
|
||||
offset_colors = offset_vertex;
|
||||
|
||||
if (1) printf("buffer_vertex_size after writing_space_faces_vertex = %4d - 8 = %3d (x 3 = %4d)\n", buffer_vertex_size, buffer_vertex_size - 8, (buffer_vertex_size - 8) * 3);
|
||||
if (1) printf("(space_X - 1) * 4 + (space_Y - 1) * 4 + (space_Z - 1) * 4 = %3d (x 3 = %4d)\n\n",\
|
||||
if (0) printf("offset_vertex after writing_space_faces_vertex = %4d - 8 = %3d (x 3 = %4d)\n", offset_vertex, offset_vertex - 8, (offset_vertex - 8) * 3);
|
||||
if (0) printf("(space_X - 1) * 4 + (space_Y - 1) * 4 + (space_Z - 1) * 4 = %3d (x 3 = %4d)\n\n",\
|
||||
(space_X - 1) * 4 + (space_Y - 1) * 4 + (space_Z - 1) * 4, ((space_X - 1) * 4 + (space_Y - 1) * 4 + (space_Z - 1) * 4) * 3);
|
||||
|
||||
|
||||
/* A R R O W S */
|
||||
|
||||
for (int i = 0; i < arrows_nb; i++) {
|
||||
load = sworrah[i].load;
|
||||
site = sworrah[i].site;
|
||||
x = sworrah[i].x;
|
||||
y = sworrah[i].y;
|
||||
z = sworrah[i].z;
|
||||
load = sworra[i].load;
|
||||
site = sworra[i].site;
|
||||
x = sworra[i].x;
|
||||
y = sworra[i].y;
|
||||
z = sworra[i].z;
|
||||
|
||||
buffer_vertex_size += write_one_arrow_vertex(buffer_vertex_size,
|
||||
offset_vertex += write_one_arrow_vertex(offset_vertex,
|
||||
space_X, space_Y, space_Z,
|
||||
load, site, x, y, z);
|
||||
buffer_colors_size = buffer_vertex_size;
|
||||
offset_colors = offset_vertex;
|
||||
}
|
||||
|
||||
if (1) printf("buffer_vertex_size after writing_arrows_vertex : %d (x 3 = %d) (arrows_nb = %d)\n", buffer_vertex_size, buffer_vertex_size * 3, arrows_nb);
|
||||
if (0) printf("offset_vertex after writing_arrows_vertex : %d (x 3 = %d) (arrows_nb = %d)\n", offset_vertex, offset_vertex * 3, arrows_nb);
|
||||
|
||||
|
||||
/*---------------------------------------------------------------*/
|
||||
|
||||
/* L I N E S S E C O N D */
|
||||
|
||||
// buffer_vertex_size = 0; buffer_colors_size = 0; buffer_lines_size = 0;
|
||||
offset_vertex = 0; offset_colors = 0; offset_lines = 0;
|
||||
|
||||
/* S P A C E */
|
||||
|
||||
buffer_vertex_size += write_space_ridges_lines ();
|
||||
offset_vertex += write_space_ridges_lines ();
|
||||
|
||||
buffer_vertex_size += write_grids_on_space_faces_lines (buffer_vertex_size, space_X, space_Y, space_Z);
|
||||
offset_vertex += write_grids_on_space_faces_lines (offset_vertex, space_X, space_Y, space_Z);
|
||||
|
||||
/* A R R O W S */
|
||||
|
||||
for (int i = 0; i < arrows_nb; i++) {
|
||||
load = sworrah[i].load;
|
||||
site = sworrah[i].site;
|
||||
x = sworrah[i].x;
|
||||
y = sworrah[i].y;
|
||||
z = sworrah[i].z;
|
||||
load = sworra[i].load;
|
||||
site = sworra[i].site;
|
||||
x = sworra[i].x;
|
||||
y = sworra[i].y;
|
||||
z = sworra[i].z;
|
||||
|
||||
buffer_vertex_size += write_one_arrow_line (buffer_vertex_size);
|
||||
offset_vertex += write_one_arrow_line (offset_vertex);
|
||||
}
|
||||
|
||||
/* n E W D A T A W I L L N O W B E S P E C I F I E D */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* N E W D A T A W I L L N O W B E S P E C I F I E D */
|
||||
|
||||
/* A N D T H E N D R A W N E D */
|
||||
/* B E F O R E B E I N G D R A W N E D */
|
||||
|
||||
/*--------------------------------------------------------------------------------*/
|
||||
|
||||
arrows_nb = set_arrow (sworrah, arrows_nb,
|
||||
arrows_nb = set_arrow (sworra, arrows_nb,
|
||||
0,//rand() % arbitrary + 1, // load / weight
|
||||
0,//rand() % 6, // site,
|
||||
0,//rand() % space_X, // x
|
||||
0,//rand() % space_Y, // y
|
||||
0);//rand() % space_Z); // z
|
||||
|
||||
/* print_user_choices(sworrah, arrows_nb, space_X, space_Y, space_Z, print_arrows_data, 0); */
|
||||
/* print_user_choices(sworra, arrows_nb, space_X, space_Y, space_Z, print_arrows_data, 0); */
|
||||
|
||||
arrows_nb = set_arrow (sworrah, arrows_nb,
|
||||
arrows_nb = set_arrow (sworra, arrows_nb,
|
||||
0,//rand() % arbitrary + 1, // load / weight
|
||||
1,//rand() % 6, // site,
|
||||
0,//rand() % space_X, // x
|
||||
0,//rand() % space_Y, // y
|
||||
0);//rand() % space_Z); // z
|
||||
|
||||
arrows_nb = set_arrow (sworrah, arrows_nb,
|
||||
arrows_nb = set_arrow (sworra, arrows_nb,
|
||||
1,//rand() % arbitrary + 1, // load / weight
|
||||
2,//rand() % 6, // site,
|
||||
0,//rand() % space_X, // x
|
||||
0,//rand() % space_Y, // y
|
||||
0);//rand() % space_Z); // z
|
||||
|
||||
arrows_nb = set_arrow (sworrah, arrows_nb,
|
||||
arrows_nb = set_arrow (sworra, arrows_nb,
|
||||
1,//rand() % arbitrary + 1, // load / weight
|
||||
3,//rand() % 6, // site,
|
||||
0,//rand() % space_X, // x
|
||||
0,//rand() % space_Y, // y
|
||||
0);//rand() % space_Z); // z
|
||||
|
||||
printf("On devrait avoir deux flèches Y+Y- (Zénith-Nadir) dessinées (au lieu des deux flèches X+X- Est-Ouest)...\n");
|
||||
/* print_user_choices(sworra, arrows_nb, space_X, space_Y, space_Z, print_arrows_data, 0); */
|
||||
|
||||
/* print_user_choices(sworrah, arrows_nb, space_X, space_Y, space_Z, print_arrows_data, 0); */
|
||||
|
||||
// buffer_vertex_size -= 2;
|
||||
// offset_vertex -= 2;
|
||||
// buffer_vertex_size += 3;
|
||||
|
||||
|
||||
|
@ -848,7 +863,7 @@ printf("On devrait avoir deux flèches Y+Y- (Zénith-Nadir) dessinées (au lieu
|
|||
/* random_choice = rand() % 6; */
|
||||
/* if (random_choice == 0) deleted++; */
|
||||
|
||||
/* modified = set_arrow (sworrah, arrows_nb + modified, */
|
||||
/* modified = set_arrow (sworra, arrows_nb + modified, */
|
||||
/* random_choice, // load / weight */
|
||||
/* rand() % 6, // site, */
|
||||
/* rand() % space_X, // x */
|
||||
|
@ -860,34 +875,34 @@ printf("On devrait avoir deux flèches Y+Y- (Zénith-Nadir) dessinées (au lieu
|
|||
/* #pragma omp parallel */
|
||||
/* { */
|
||||
/* for (int i = 0; i < arrows_nb + modified; i++) { */
|
||||
/* load = sworrah[i].load; */
|
||||
/* site = sworrah[i].site; */
|
||||
/* x = sworrah[i].x; */
|
||||
/* y = sworrah[i].y; */
|
||||
/* z = sworrah[i].z; */
|
||||
/* load = sworra[i].load; */
|
||||
/* site = sworra[i].site; */
|
||||
/* x = sworra[i].x; */
|
||||
/* y = sworra[i].y; */
|
||||
/* z = sworra[i].z; */
|
||||
|
||||
/* buffer_vertex_size += write_one_arrow_vertex(buffer_vertex_size, */
|
||||
/* offset_vertex += write_one_arrow_vertex(offset_vertex, */
|
||||
/* space_X, space_Y, space_Z, */
|
||||
/* load, site, x, y, z); */
|
||||
/* buffer_colors_size = buffer_vertex_size; */
|
||||
/* offset_colors = offset_vertex; */
|
||||
/* } */
|
||||
|
||||
/* for (int i = 0; i < arrows_nb + modified; i++) { */
|
||||
/* load = sworrah[i].load; */
|
||||
/* site = sworrah[i].site; */
|
||||
/* x = sworrah[i].x; */
|
||||
/* y = sworrah[i].y; */
|
||||
/* z = sworrah[i].z; */
|
||||
/* load = sworra[i].load; */
|
||||
/* site = sworra[i].site; */
|
||||
/* x = sworra[i].x; */
|
||||
/* y = sworra[i].y; */
|
||||
/* z = sworra[i].z; */
|
||||
|
||||
/* buffer_vertex_size += write_one_arrow_line (buffer_vertex_size); */
|
||||
/* offset_vertex += write_one_arrow_line (offset_vertex); */
|
||||
/* } */
|
||||
/* } */
|
||||
|
||||
/* print_evolution (sworrah, arrows_nb, arbitrary, deleted, print_arrows_data); */
|
||||
/* print_evolution (sworra, arrows_nb, arbitrary, deleted, print_arrows_data); */
|
||||
|
||||
|
||||
// ? free (space) TODO
|
||||
free(sworrah);
|
||||
sworrah = NULL;
|
||||
free(sworra);
|
||||
sworra = NULL;
|
||||
arrows_nb = 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue