OK : create_arrow() creating in arrows_ptr and drawing
This commit is contained in:
parent
faa7ecdc86
commit
db1c2a091c
|
@ -108,7 +108,7 @@ void graphics_init_buffers(const void *gl_area);
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
void graphics_write_line (GLuint a, GLuint b);
|
||||
void graphics_write_line (GLuint a, GLuint b, int print);
|
||||
|
||||
/*
|
||||
* Writes values to describe a vertex at (x,y,z) into the vertex buffer
|
||||
|
@ -117,7 +117,7 @@ void graphics_write_line (GLuint a, GLuint b);
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
void graphics_write_vertex (GLfloat x, GLfloat y, GLfloat z);
|
||||
void graphics_write_vertex (GLfloat x, GLfloat y, GLfloat z, int print);
|
||||
|
||||
/*
|
||||
* Writes values to describe a color (r,g,b) into the color buffer
|
||||
|
|
|
@ -46,7 +46,9 @@ int write_one_arrow_vertex (int space_X_int, int space_Y_int, int space_Z_int,
|
|||
vy = (2 * j / space_Y_int - 1) * space_Y_int / max + (1 / max),
|
||||
vz = (2 * k / space_Z_int - 1) * space_Z_int / max + (1 / max);
|
||||
|
||||
graphics_write_vertex(vx, vy, vz);
|
||||
int print = 0;
|
||||
|
||||
graphics_write_vertex(vx, vy, vz, print);
|
||||
graphics_write_color(0.3f, 0.3f, 0.3f);
|
||||
|
||||
// réduit légèrement les longueurs des flèches
|
||||
|
@ -55,27 +57,27 @@ int write_one_arrow_vertex (int space_X_int, int space_Y_int, int space_Z_int,
|
|||
|
||||
switch(site){
|
||||
case EAST:
|
||||
graphics_write_vertex (vx - (site % 2 - 1) * (1 / max) + (site % 2 - 1) * arrow_tip_padding, vy, vz);
|
||||
graphics_write_vertex (vx - (site % 2 - 1) * (1 / max) + (site % 2 - 1) * arrow_tip_padding, vy, vz, print);
|
||||
graphics_write_color (1.0f, 0.0f, 0.0f);
|
||||
break;
|
||||
case WEST:
|
||||
graphics_write_vertex (vx - (site % 2) * (1 / max) + (site % 2) * arrow_tip_padding, vy, vz);
|
||||
graphics_write_vertex (vx - (site % 2) * (1 / max) + (site % 2) * arrow_tip_padding, vy, vz, print);
|
||||
graphics_write_color (0.0f, 1.0f, 1.0f);
|
||||
break;
|
||||
case ZENITH:
|
||||
graphics_write_vertex (vx, vy - (site % 2 - 1) * (1 / max) + (site % 2 - 1) * arrow_tip_padding, vz);
|
||||
graphics_write_vertex (vx, vy - (site % 2 - 1) * (1 / max) + (site % 2 - 1) * arrow_tip_padding, vz, print);
|
||||
graphics_write_color(0.0f, 1.0f, 0.0f);
|
||||
break;
|
||||
case NADIR:
|
||||
graphics_write_vertex (vx, vy - (site % 2) * (1 / max) + (site % 2) * arrow_tip_padding, vz);
|
||||
graphics_write_color(1.0f, 0.0f, 1.0f);
|
||||
graphics_write_vertex (vx, vy - (site % 2) * (1 / max) + (site % 2) * arrow_tip_padding, vz, print);
|
||||
graphics_write_color(0.7f, 0.2f, 0.2f);
|
||||
break;
|
||||
case SOUTH:
|
||||
graphics_write_vertex (vx, vy, vz + (site % 2 - 1) * (1 / max) - (site % 2 - 1) * arrow_tip_padding);
|
||||
graphics_write_color(0.0f, 0.0f, 1.0f);
|
||||
graphics_write_vertex (vx, vy, vz + (site % 2 - 1) * (1 / max) - (site % 2 - 1) * arrow_tip_padding, print);
|
||||
graphics_write_color(0.3f, 0.1f, 0.6f);
|
||||
break;
|
||||
case NORTH:
|
||||
graphics_write_vertex (vx, vy, vz + (site % 2) * (1 / max) - (site % 2) * arrow_tip_padding);
|
||||
graphics_write_vertex (vx, vy, vz + (site % 2) * (1 / max) - (site % 2) * arrow_tip_padding, print);
|
||||
graphics_write_color(1.0f, 1.0f, 0.0f);
|
||||
break;
|
||||
default: break;
|
||||
|
@ -87,7 +89,8 @@ int write_one_arrow_vertex (int space_X_int, int space_Y_int, int space_Z_int,
|
|||
|
||||
int write_one_arrow_line(int offset_vertex)
|
||||
{
|
||||
graphics_write_line (offset_vertex + 0, offset_vertex + 1);
|
||||
int print = 0;
|
||||
graphics_write_line (offset_vertex + 0, offset_vertex + 1, print);
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
|
|
@ -122,7 +122,7 @@ static void graphics_debug_callback(GLenum source, GLenum type, GLuint id,
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
void graphics_write_vertex (GLfloat x, GLfloat y, GLfloat z)
|
||||
void graphics_write_vertex (GLfloat x, GLfloat y, GLfloat z, int print)
|
||||
{
|
||||
buffer_vertex_origin = g_realloc (buffer_vertex_origin,
|
||||
(buffer_vertex_size + 3) * sizeof(GLfloat));
|
||||
|
@ -133,7 +133,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 => [%2d > %2d] (%6.3f,%6.3f,%6.3f)\n",\
|
||||
if (print) printf("In graphics_write_vertex() buffer_vertex_size => [%2d > %2d] (%6.3f,%6.3f,%6.3f)\n",\
|
||||
buffer_vertex_size + 0, buffer_vertex_size + 2, x, y, z);
|
||||
|
||||
buffer_vertex_size += 3;
|
||||
|
@ -167,7 +167,7 @@ void graphics_write_color (GLfloat r, GLfloat g, GLfloat b)
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
void graphics_write_line (GLuint a, GLuint b)
|
||||
void graphics_write_line (GLuint a, GLuint b, int print)
|
||||
{
|
||||
buffer_lines_origin = g_realloc (buffer_lines_origin,
|
||||
(buffer_lines_size + 2) * sizeof(GLuint));
|
||||
|
@ -177,8 +177,8 @@ void graphics_write_line (GLuint a, GLuint b)
|
|||
buffer_lines_origin[buffer_lines_size + 0] = a;
|
||||
buffer_lines_origin[buffer_lines_size + 1] = b;
|
||||
|
||||
if (1) printf("In graphics_write_line() buffer_lines_size => [%2d > %2d]\n",\
|
||||
buffer_lines_size + 0, buffer_lines_size + 1);
|
||||
if (print) printf("In graphics_write_line() buffer_lines_size => [%2d > %2d] (%2u > %2u)\n",\
|
||||
buffer_lines_size + 0, buffer_lines_size + 1, a, b);
|
||||
|
||||
buffer_lines_size += 2;
|
||||
}
|
||||
|
@ -582,16 +582,14 @@ static inline int create_arrow (int arrows_nb,
|
|||
arrows_ptr[arrows_nb].y = y;
|
||||
arrows_ptr[arrows_nb].z = z;
|
||||
|
||||
/* if (1) printf("In create_arrow() buffer_vertex_size => [%2d > %2d] (%6.3f,%6.3f,%6.3f)\n",\ */
|
||||
/* buffer_vertex_size + 0, buffer_vertex_size + 2, x, y, z); */
|
||||
if (0) printf("In create_arrow() buffer_vertex_size => [%2d > %2d]\n",\
|
||||
buffer_vertex_size + 0, buffer_vertex_size + 2);
|
||||
|
||||
write_one_arrow_vertex(space_X, space_Y, space_Z,
|
||||
load, site, x, y, z);
|
||||
buffer_colors_size = buffer_vertex_size;
|
||||
|
||||
/* write_one_arrow_line (buffer_vertex_size); */
|
||||
/* cas (1,1,1) graphics_write_line (9, 10); graphics_write_line (10, 11); */
|
||||
graphics_write_line (13, 14); graphics_write_line (14, 15);
|
||||
write_one_arrow_line (buffer_vertex_size / 3 - 2);
|
||||
|
||||
arrows_nb ++;
|
||||
|
||||
|
@ -699,17 +697,17 @@ void __attribute__((optimize("no-unroll-loops"))) main_test_graphics (void)
|
|||
int rand(void);
|
||||
void srand(unsigned int seed); // printf ("Valeur max : %d\n", RAND_MAX); min + rand() % (max+1 - min);
|
||||
|
||||
int arbitrary = 7;
|
||||
int space_X = 2,//1 + rand() % arbitrary,
|
||||
space_Y = 1,//1 + rand() % arbitrary,
|
||||
space_Z = 1;//1 + rand() % arbitrary;
|
||||
int arbitrary = 5;
|
||||
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);
|
||||
|
||||
int print_arrows_data = 0;
|
||||
|
||||
int load = 0, site = 0, x = 0, y = 0, z = 0;
|
||||
int specif_arrows_nb = 1;//rand() % density_max;
|
||||
int specif_arrows_nb = rand() % density_max / 2;
|
||||
int arrows_nb = 0, cpt = 0, t_initial = 0;
|
||||
|
||||
int print_inter_results = 0;
|
||||
|
@ -772,11 +770,11 @@ void __attribute__((optimize("no-unroll-loops"))) main_test_graphics (void)
|
|||
|
||||
/* S P A C E */
|
||||
|
||||
if (1) printf("buffer_lines_size before writing 12 space_ridges_lines : %2d (* 2 = %2d)\n", buffer_lines_size / 2, buffer_lines_size);
|
||||
if (0) printf("buffer_lines_size before writing 12 space_ridges_lines : %2d (* 2 = %2d)\n", buffer_lines_size / 2, buffer_lines_size);
|
||||
write_space_ridges_lines ();
|
||||
if (1) printf("buffer_lines_size after writing 12 space_ridges_lines : %2d (* 2 = %2d)\n", buffer_lines_size / 2, buffer_lines_size);
|
||||
if (0) printf("buffer_lines_size after writing 12 space_ridges_lines : %2d (* 2 = %2d)\n", buffer_lines_size / 2, buffer_lines_size);
|
||||
|
||||
if (1) printf("buffer_lines_size before writing (n) space_faces_lines : %2d (* 2 = %2d)\n", buffer_lines_size / 2, buffer_lines_size);
|
||||
if (0) printf("buffer_lines_size before writing (n) space_faces_lines : %2d (* 2 = %2d)\n", buffer_lines_size / 2, buffer_lines_size);
|
||||
write_grids_on_space_faces_lines (buffer_lines_size, space_X, space_Y, space_Z);
|
||||
if (1) printf("buffer_lines_size after writing (n) space_faces_lines : %d (* 2 = %d)\n\n", buffer_lines_size / 2, buffer_lines_size);
|
||||
|
||||
|
@ -786,18 +784,18 @@ void __attribute__((optimize("no-unroll-loops"))) main_test_graphics (void)
|
|||
/* { */
|
||||
/* while (arrows_nb < specif_arrows_nb){ */
|
||||
arrows_nb = set_arrow (arrows_ptr, arrows_nb, space_X, space_Y, space_Z,
|
||||
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
|
||||
rand() % arbitrary + 1, // load / weight
|
||||
rand() % 6, // site,
|
||||
rand() % space_X, // x
|
||||
rand() % space_Y, // y
|
||||
rand() % space_Z); // z
|
||||
|
||||
arrows_nb = set_arrow (arrows_ptr, arrows_nb, space_X, space_Y, space_Z,
|
||||
1,//rand() % arbitrary + 1, // load / weight
|
||||
1,//rand() % 6, // site,
|
||||
0,//rand() % space_X, // x
|
||||
0,//rand() % space_Y, // y
|
||||
0);//rand() % space_Z); // z
|
||||
rand() % arbitrary + 1, // load / weight
|
||||
rand() % 6, // site,
|
||||
rand() % space_X, // x
|
||||
rand() % space_Y, // y
|
||||
rand() % space_Z); // z
|
||||
|
||||
/* clock_gettime(CLOCK_REALTIME, &ts); < Je n'arrive pas à afficher les temps en cours d'exécutuion */
|
||||
/* if (arrows_nb % 1000 == 0) {cpt++; printf("%8d", arrows_nb / 1000); if (cpt % 22 == 0) printf(" %f\n%10d | ", specif_arrows_nb / 1000, ts.tv_sec - t_initial);} */
|
||||
|
|
|
@ -29,17 +29,17 @@ int write_space_ridges_vertex (long offset_vertex, long x, long y, long z)
|
|||
{
|
||||
float max = fmax(x, y); max = fmax(max, z);
|
||||
|
||||
graphics_write_vertex (offset_vertex - x / max, offset_vertex - y / max, - z / max);
|
||||
graphics_write_vertex (offset_vertex - x / max, offset_vertex - y / max, - z / max, 0);
|
||||
|
||||
graphics_write_vertex (offset_vertex + x / max, offset_vertex - y / max, - z / max);
|
||||
graphics_write_vertex (offset_vertex - x / max, offset_vertex + y / max, - z / max);
|
||||
graphics_write_vertex (offset_vertex - x / max, offset_vertex - y / max, + z / max);
|
||||
graphics_write_vertex (offset_vertex + x / max, offset_vertex - y / max, - z / max, 0);
|
||||
graphics_write_vertex (offset_vertex - x / max, offset_vertex + y / max, - z / max, 0);
|
||||
graphics_write_vertex (offset_vertex - x / max, offset_vertex - y / max, + z / max, 0);
|
||||
|
||||
graphics_write_vertex (offset_vertex + x / max, offset_vertex + y / max, - z / max);
|
||||
graphics_write_vertex (offset_vertex + x / max, offset_vertex - y / max, + z / max);
|
||||
graphics_write_vertex (offset_vertex - x / max, offset_vertex + y / max, + z / max);
|
||||
graphics_write_vertex (offset_vertex + x / max, offset_vertex + y / max, - z / max, 0);
|
||||
graphics_write_vertex (offset_vertex + x / max, offset_vertex - y / max, + z / max, 0);
|
||||
graphics_write_vertex (offset_vertex - x / max, offset_vertex + y / max, + z / max, 0);
|
||||
|
||||
graphics_write_vertex (offset_vertex + x / max, + y / max, + z / max);
|
||||
graphics_write_vertex (offset_vertex + x / max, + y / max, + z / max, 0);
|
||||
|
||||
graphics_write_color (0.9f, 0.7f, 0.4f);
|
||||
graphics_write_color (0.9f, 0.7f, 0.4f);
|
||||
|
@ -55,13 +55,13 @@ int write_space_ridges_vertex (long offset_vertex, long x, long y, long z)
|
|||
|
||||
int write_space_ridges_lines ()
|
||||
{
|
||||
graphics_write_line ( 0, 1); graphics_write_line ( 7, 4);
|
||||
graphics_write_line ( 0, 2); graphics_write_line ( 7, 5);
|
||||
graphics_write_line ( 0, 3); graphics_write_line ( 7, 6);
|
||||
graphics_write_line ( 0, 1, 0); graphics_write_line ( 7, 4, 0);
|
||||
graphics_write_line ( 0, 2, 0); graphics_write_line ( 7, 5, 0);
|
||||
graphics_write_line ( 0, 3, 0); graphics_write_line ( 7, 6, 0);
|
||||
|
||||
graphics_write_line ( 1, 4); graphics_write_line ( 2, 4);
|
||||
graphics_write_line ( 1, 5); graphics_write_line ( 3, 5);
|
||||
graphics_write_line ( 2, 6); graphics_write_line ( 3, 6);
|
||||
graphics_write_line ( 1, 4, 0); graphics_write_line ( 2, 4, 0);
|
||||
graphics_write_line ( 1, 5, 0); graphics_write_line ( 3, 5, 0);
|
||||
graphics_write_line ( 2, 6, 0); graphics_write_line ( 3, 6, 0);
|
||||
|
||||
return 12;
|
||||
}
|
||||
|
@ -72,10 +72,10 @@ long write_grids_on_space_faces_vertex (long x, long y, long z)
|
|||
|
||||
for (i = 1; i < x; i++) {
|
||||
|
||||
graphics_write_vertex ((2 * i / x - 1) * x / max, - y / max, - z / max);
|
||||
graphics_write_vertex ((2 * i / x - 1) * x / max, - y / max, z / max);
|
||||
graphics_write_vertex ((2 * i / x - 1) * x / max, y / max, z / max);
|
||||
graphics_write_vertex ((2 * i / x - 1) * x / max, y / max, - z / max);
|
||||
graphics_write_vertex ((2 * i / x - 1) * x / max, - y / max, - z / max, 0);
|
||||
graphics_write_vertex ((2 * i / x - 1) * x / max, - y / max, z / max, 0);
|
||||
graphics_write_vertex ((2 * i / x - 1) * x / max, y / max, z / max, 0);
|
||||
graphics_write_vertex ((2 * i / x - 1) * x / max, y / max, - z / max, 0);
|
||||
|
||||
graphics_write_color (0.5f, 0.5f, 0.5f);
|
||||
graphics_write_color (0.5f, 0.5f, 0.5f);
|
||||
|
@ -87,10 +87,10 @@ long write_grids_on_space_faces_vertex (long x, long y, long z)
|
|||
|
||||
for (i = 1; i < y; i++) {
|
||||
|
||||
graphics_write_vertex (- x / max, (2 * i / y - 1) * y / max, - z / max);
|
||||
graphics_write_vertex (- x / max, (2 * i / y - 1) * y / max, z / max);
|
||||
graphics_write_vertex ( x / max, (2 * i / y - 1) * y / max, z / max);
|
||||
graphics_write_vertex ( x / max, (2 * i / y - 1) * y / max, - z / max);
|
||||
graphics_write_vertex (- x / max, (2 * i / y - 1) * y / max, - z / max, 0);
|
||||
graphics_write_vertex (- x / max, (2 * i / y - 1) * y / max, z / max, 0);
|
||||
graphics_write_vertex ( x / max, (2 * i / y - 1) * y / max, z / max, 0);
|
||||
graphics_write_vertex ( x / max, (2 * i / y - 1) * y / max, - z / max, 0);
|
||||
|
||||
graphics_write_color (0.5f, 0.5f, 0.5f);
|
||||
graphics_write_color (0.5f, 0.5f, 0.5f);
|
||||
|
@ -102,10 +102,10 @@ long write_grids_on_space_faces_vertex (long x, long y, long z)
|
|||
|
||||
for (i = 1; i < z; i++) {
|
||||
|
||||
graphics_write_vertex (- x / max, - y / max, (2 * i / z - 1) * z / max);
|
||||
graphics_write_vertex (- x / max, y / max, (2 * i / z - 1) * z / max);
|
||||
graphics_write_vertex ( x / max, y / max, (2 * i / z - 1) * z / max);
|
||||
graphics_write_vertex ( x / max, - y / max, (2 * i / z - 1) * z / max);
|
||||
graphics_write_vertex (- x / max, - y / max, (2 * i / z - 1) * z / max, 0);
|
||||
graphics_write_vertex (- x / max, y / max, (2 * i / z - 1) * z / max, 0);
|
||||
graphics_write_vertex ( x / max, y / max, (2 * i / z - 1) * z / max, 0);
|
||||
graphics_write_vertex ( x / max, - y / max, (2 * i / z - 1) * z / max, 0);
|
||||
|
||||
graphics_write_color (0.5f, 0.5f, 0.5f);
|
||||
graphics_write_color (0.5f, 0.5f, 0.5f);
|
||||
|
@ -123,30 +123,30 @@ long write_grids_on_space_faces_lines (long offset_vertex, long x, long y, long
|
|||
|
||||
for (int i = 0; i < x - 1; i ++) {
|
||||
|
||||
/* graphics_write_line (offset_vertex + i * 4 + 0, offset_vertex + i * 4 + 1); */
|
||||
graphics_write_line (offset_vertex + i * 4 + 1, offset_vertex + i * 4 + 2);
|
||||
graphics_write_line (offset_vertex + i * 4 + 2, offset_vertex + i * 4 + 3);
|
||||
/* graphics_write_line (offset_vertex + i * 4 + 3, offset_vertex + i * 4 + 0); */
|
||||
/* graphics_write_line (offset_vertex + i * 4 + 0, offset_vertex + i * 4 + 1, 0); */
|
||||
graphics_write_line (offset_vertex + i * 4 + 1, offset_vertex + i * 4 + 2, 0);
|
||||
graphics_write_line (offset_vertex + i * 4 + 2, offset_vertex + i * 4 + 3, 0);
|
||||
/* graphics_write_line (offset_vertex + i * 4 + 3, offset_vertex + i * 4 + 0, 0); */
|
||||
}
|
||||
|
||||
offset_vertex += (x - 1) * 4;
|
||||
|
||||
for (int i = 0; i < y - 1; i ++) {
|
||||
|
||||
/* graphics_write_line (offset_vertex + i * 4 + 0, offset_vertex + i * 4 + 1); */
|
||||
/* graphics_write_line (offset_vertex + i * 4 + 1, offset_vertex + i * 4 + 2); */
|
||||
graphics_write_line (offset_vertex + i * 4 + 2, offset_vertex + i * 4 + 3);
|
||||
graphics_write_line (offset_vertex + i * 4 + 3, offset_vertex + i * 4 + 0);
|
||||
/* graphics_write_line (offset_vertex + i * 4 + 0, offset_vertex + i * 4 + 1, 0); */
|
||||
/* graphics_write_line (offset_vertex + i * 4 + 1, offset_vertex + i * 4 + 2, 0); */
|
||||
graphics_write_line (offset_vertex + i * 4 + 2, offset_vertex + i * 4 + 3, 0);
|
||||
graphics_write_line (offset_vertex + i * 4 + 3, offset_vertex + i * 4 + 0, 0);
|
||||
}
|
||||
|
||||
offset_vertex += (y - 1) * 4;
|
||||
|
||||
for (int i = 0; i < z - 1; i ++) {
|
||||
|
||||
graphics_write_line (offset_vertex + i * 4 + 0, offset_vertex + i * 4 + 1);
|
||||
/* graphics_write_line (offset_vertex + i * 4 + 1, offset_vertex + i * 4 + 2); */
|
||||
/* graphics_write_line (offset_vertex + i * 4 + 2, offset_vertex + i * 4 + 3); */
|
||||
graphics_write_line (offset_vertex + i * 4 + 3, offset_vertex + i * 4 + 0);
|
||||
graphics_write_line (offset_vertex + i * 4 + 0, offset_vertex + i * 4 + 1, 0);
|
||||
/* graphics_write_line (offset_vertex + i * 4 + 1, offset_vertex + i * 4 + 2, 0); */
|
||||
/* graphics_write_line (offset_vertex + i * 4 + 2, offset_vertex + i * 4 + 3, 0); */
|
||||
graphics_write_line (offset_vertex + i * 4 + 3, offset_vertex + i * 4 + 0, 0);
|
||||
}
|
||||
|
||||
return (x + y + z - 3) * 4;
|
||||
|
|
Loading…
Reference in New Issue