WIP: cleaning before set_arrow() loop optimization
This commit is contained in:
parent
a79f468f19
commit
26f3d2eb2b
|
@ -38,8 +38,8 @@ typedef struct arrow_t {
|
||||||
GLuint z;
|
GLuint z;
|
||||||
};
|
};
|
||||||
|
|
||||||
int write_one_arrow_vertex (int space_X, int space_Y, int space_Z,
|
int draw_one_arrow_vertex (int space_X, int space_Y, int space_Z,
|
||||||
int weight, int site, int x, int y, int z, int print);
|
int weight, int site, int x, int y, int z, int print);
|
||||||
|
|
||||||
int write_one_arrow_line(int offset_vertex, int print);
|
int draw_one_arrow_line(int offset_vertex, int print);
|
||||||
|
|
||||||
|
|
|
@ -44,8 +44,6 @@ struct gl_area_entry {
|
||||||
GLuint m; // init_shaders, draw
|
GLuint m; // init_shaders, draw
|
||||||
GLuint v; // init_shaders, draw
|
GLuint v; // init_shaders, draw
|
||||||
GLuint p; // init_shaders, draw
|
GLuint p; // init_shaders, draw
|
||||||
// GLuint line_indices_nb; // now : graphics.c > int buffer_lines_ndx
|
|
||||||
// GLuint plan_indices_nb; // now : graphics.c > int buffer_plans_ndx
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -101,6 +99,26 @@ bool graphics_init_shaders(const void *gl_area);
|
||||||
*/
|
*/
|
||||||
void graphics_init_buffers(const void *gl_area);
|
void graphics_init_buffers(const void *gl_area);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Draws a vertex (x, y, z)
|
||||||
|
* if (console) prints (x, y, z) values to console
|
||||||
|
*
|
||||||
|
* @param GLfloat x, GLfloat y, GLfloat z
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
void graphics_draw_vertex (GLfloat x, GLfloat y, GLfloat z, int console);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Draws the color (r, g, b) associated to a vertex
|
||||||
|
* if (console) prints (r, g, b) values to console
|
||||||
|
*
|
||||||
|
* @param GLfloat r, GLfloat g, GLfloat b
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
void graphics_draw_color (GLfloat r, GLfloat g, GLfloat b, int console);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Writes values to describe a line from a to b into the line buffer
|
* Writes values to describe a line from a to b into the line buffer
|
||||||
*
|
*
|
||||||
|
@ -108,25 +126,7 @@ void graphics_init_buffers(const void *gl_area);
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
void graphics_write_line (GLuint a, GLuint b, int print);
|
void graphics_draw_line (GLuint a, GLuint b, int console);
|
||||||
|
|
||||||
/*
|
|
||||||
* Writes values to describe a vertex at (x,y,z) into the vertex buffer
|
|
||||||
*
|
|
||||||
* @param coords GLfloat(x,y,z)
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
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
|
|
||||||
*
|
|
||||||
* @param color GLfloat(r,g,b)
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
void graphics_write_color (GLfloat r, GLfloat g, GLfloat b);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Writes values to describe an (a,b,c) plan (triangle) into the plan buffer
|
* Writes values to describe an (a,b,c) plan (triangle) into the plan buffer
|
||||||
|
@ -135,7 +135,7 @@ void graphics_write_color (GLfloat r, GLfloat g, GLfloat b);
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
void graphics_write_plan (GLuint a, GLuint b, GLuint c);
|
void graphics_draw_plan (GLuint a, GLuint b, GLuint c, int console);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initializes an identity matrix
|
* Initializes an identity matrix
|
||||||
|
|
|
@ -34,8 +34,8 @@
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
int write_space_ridges_vertex (long offset_vertex, long x, long y, long z);
|
int draw_space_ridges_vertex (long offset_vertex, long x, long y, long z, int console);
|
||||||
int write_space_ridges_lines ();
|
int draw_space_ridges_lines (int console);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Writes grid lines on space faces
|
* Writes grid lines on space faces
|
||||||
|
@ -44,6 +44,6 @@ int write_space_ridges_lines ();
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
long write_grids_on_space_faces_vertex (long x, long y, long z);
|
long draw_grids_on_space_faces_vertex (long x, long y, long z, int console);
|
||||||
long write_grids_on_space_faces_lines (long offset_vertex, long x, long y, long z);
|
long draw_grids_on_space_faces_lines (long offset_vertex, long x, long y, long z, int console);
|
||||||
|
|
||||||
|
|
|
@ -33,8 +33,8 @@
|
||||||
* Z - Z = NORTH - SOUTH = bleu - jaune
|
* Z - Z = NORTH - SOUTH = bleu - jaune
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int write_one_arrow_vertex (int space_X_int, int space_Y_int, int space_Z_int,
|
int draw_one_arrow_vertex (int space_X_int, int space_Y_int, int space_Z_int,
|
||||||
int weight, int site, int arrow_x, int arrow_y, int arrow_z, int print)
|
int weight, int site, int arrow_x, int arrow_y, int arrow_z, int console)
|
||||||
{
|
{
|
||||||
|
|
||||||
float max = fmax(space_X_int, space_Y_int);
|
float max = fmax(space_X_int, space_Y_int);
|
||||||
|
@ -46,8 +46,8 @@ 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),
|
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);
|
vz = (2 * k / space_Z_int - 1) * space_Z_int / max + (1 / max);
|
||||||
|
|
||||||
graphics_write_vertex(vx, vy, vz, print);
|
graphics_draw_vertex(vx, vy, vz, console);
|
||||||
graphics_write_color(0.4f, 0.4f, 0.4f);
|
graphics_draw_color(0.4f, 0.4f, 0.4f, console);
|
||||||
|
|
||||||
// réduit légèrement les longueurs des flèches
|
// réduit légèrement les longueurs des flèches
|
||||||
// pour qu'elles s'arrêtent avant les faces des cubes
|
// pour qu'elles s'arrêtent avant les faces des cubes
|
||||||
|
@ -55,28 +55,28 @@ int write_one_arrow_vertex (int space_X_int, int space_Y_int, int space_Z_int,
|
||||||
|
|
||||||
switch(site){
|
switch(site){
|
||||||
case EAST:
|
case EAST:
|
||||||
graphics_write_vertex (vx - (site % 2 - 1) * (1 / max) + (site % 2 - 1) * arrow_tip_padding, vy, vz, print);
|
graphics_draw_vertex (vx - (site % 2 - 1) * (1 / max) + (site % 2 - 1) * arrow_tip_padding, vy, vz, console);
|
||||||
graphics_write_color (1.0f, 0.0f, 0.0f);
|
graphics_draw_color (1.0f, 0.0f, 0.0f, console);
|
||||||
break;
|
break;
|
||||||
case WEST:
|
case WEST:
|
||||||
graphics_write_vertex (vx - (site % 2) * (1 / max) + (site % 2) * arrow_tip_padding, vy, vz, print);
|
graphics_draw_vertex (vx - (site % 2) * (1 / max) + (site % 2) * arrow_tip_padding, vy, vz, console);
|
||||||
graphics_write_color (0.0f, 1.0f, 1.0f);
|
graphics_draw_color (0.0f, 1.0f, 1.0f, console);
|
||||||
break;
|
break;
|
||||||
case ZENITH:
|
case ZENITH:
|
||||||
graphics_write_vertex (vx, vy - (site % 2 - 1) * (1 / max) + (site % 2 - 1) * arrow_tip_padding, vz, print);
|
graphics_draw_vertex (vx, vy - (site % 2 - 1) * (1 / max) + (site % 2 - 1) * arrow_tip_padding, vz, console);
|
||||||
graphics_write_color(0.0f, 0.6f, 0.1f);
|
graphics_draw_color(0.0f, 0.6f, 0.1f, console);
|
||||||
break;
|
break;
|
||||||
case NADIR:
|
case NADIR:
|
||||||
graphics_write_vertex (vx, vy - (site % 2) * (1 / max) + (site % 2) * arrow_tip_padding, vz, print);
|
graphics_draw_vertex (vx, vy - (site % 2) * (1 / max) + (site % 2) * arrow_tip_padding, vz, console);
|
||||||
graphics_write_color(0.6f, 0.1f, 0.7f);
|
graphics_draw_color(0.6f, 0.1f, 0.7f, console);
|
||||||
break;
|
break;
|
||||||
case SOUTH:
|
case SOUTH:
|
||||||
graphics_write_vertex (vx, vy, vz - (site % 2 + 1) * (1 / max) + (site % 2 + 1) * arrow_tip_padding, print);
|
graphics_draw_vertex (vx, vy, vz - (site % 2 + 1) * (1 / max) + (site % 2 + 1) * arrow_tip_padding, console);
|
||||||
graphics_write_color(0.05f, 0.4f, 1.0f);
|
graphics_draw_color(0.05f, 0.4f, 1.0f, console);
|
||||||
break;
|
break;
|
||||||
case NORTH:
|
case NORTH:
|
||||||
graphics_write_vertex (vx, vy, vz - (site % 2 - 2) * (1 / max) + (site % 2 - 2) * arrow_tip_padding, print);
|
graphics_draw_vertex (vx, vy, vz - (site % 2 - 2) * (1 / max) + (site % 2 - 2) * arrow_tip_padding, console);
|
||||||
graphics_write_color(1.0f, 1.0f, 0.0f);
|
graphics_draw_color(1.0f, 1.0f, 0.0f, console);
|
||||||
break;
|
break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
@ -85,8 +85,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, int print)
|
int draw_one_arrow_line(int offset_vertex, int print)
|
||||||
{
|
{
|
||||||
graphics_write_line (offset_vertex + 0, offset_vertex + 1, print);
|
graphics_draw_line (offset_vertex + 0, offset_vertex + 1, print);
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
#define FRAG_SHADER_FILE "src/shaders/shader.frag"
|
#define FRAG_SHADER_FILE "src/shaders/shader.frag"
|
||||||
|
|
||||||
static struct arrow_t *arrows_ptr;
|
static struct arrow_t *arrows_ptr;
|
||||||
|
|
||||||
GLfloat *buffer_vertex_origin = NULL;
|
GLfloat *buffer_vertex_origin = NULL;
|
||||||
GLfloat *buffer_colors_origin = NULL;
|
GLfloat *buffer_colors_origin = NULL;
|
||||||
GLuint *buffer_lines_origin = NULL;
|
GLuint *buffer_lines_origin = NULL;
|
||||||
|
@ -126,7 +127,7 @@ static void graphics_debug_callback(GLenum source, GLenum type, GLuint id,
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
void graphics_write_vertex (GLfloat x, GLfloat y, GLfloat z, int print)
|
void graphics_draw_vertex (GLfloat x, GLfloat y, GLfloat z, int console)
|
||||||
{
|
{
|
||||||
buffer_vertex_origin = g_realloc (buffer_vertex_origin,
|
buffer_vertex_origin = g_realloc (buffer_vertex_origin,
|
||||||
(buffer_vertex_size + 3) * sizeof(GLfloat));
|
(buffer_vertex_size + 3) * sizeof(GLfloat));
|
||||||
|
@ -137,7 +138,7 @@ void graphics_write_vertex (GLfloat x, GLfloat y, GLfloat z, int print)
|
||||||
buffer_vertex_origin[buffer_vertex_size + 1] = y;
|
buffer_vertex_origin[buffer_vertex_size + 1] = y;
|
||||||
buffer_vertex_origin[buffer_vertex_size + 2] = z;
|
buffer_vertex_origin[buffer_vertex_size + 2] = z;
|
||||||
|
|
||||||
if (print) printf("In graphics_write_vertex() buffer_vertex_size => [%2ld] [%2ld > %2ld] (%6.3f,%6.3f,%6.3f)\n",\
|
if (console) printf("In graphics_draw_vertex() buffer_vertex_size => [%2ld] [%2ld > %2ld] (%6.3f,%6.3f,%6.3f)\n",\
|
||||||
buffer_vertex_size / 3, buffer_vertex_size + 0, buffer_vertex_size + 2, x, y, z);
|
buffer_vertex_size / 3, buffer_vertex_size + 0, buffer_vertex_size + 2, x, y, z);
|
||||||
|
|
||||||
buffer_vertex_size += 3;
|
buffer_vertex_size += 3;
|
||||||
|
@ -150,7 +151,7 @@ void graphics_write_vertex (GLfloat x, GLfloat y, GLfloat z, int print)
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
void graphics_write_color (GLfloat r, GLfloat g, GLfloat b)
|
void graphics_draw_color (GLfloat r, GLfloat g, GLfloat b, int console)
|
||||||
{
|
{
|
||||||
buffer_colors_origin = g_realloc (buffer_colors_origin,
|
buffer_colors_origin = g_realloc (buffer_colors_origin,
|
||||||
(buffer_colors_size + 3) * sizeof(GLfloat));
|
(buffer_colors_size + 3) * sizeof(GLfloat));
|
||||||
|
@ -171,7 +172,7 @@ void graphics_write_color (GLfloat r, GLfloat g, GLfloat b)
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
void graphics_write_line (GLuint a, GLuint b, int print)
|
void graphics_draw_line (GLuint a, GLuint b, int console)
|
||||||
{
|
{
|
||||||
buffer_lines_origin = g_realloc (buffer_lines_origin,
|
buffer_lines_origin = g_realloc (buffer_lines_origin,
|
||||||
(buffer_lines_size + 2) * sizeof(GLuint));
|
(buffer_lines_size + 2) * sizeof(GLuint));
|
||||||
|
@ -181,7 +182,7 @@ void graphics_write_line (GLuint a, GLuint b, int print)
|
||||||
buffer_lines_origin[buffer_lines_size + 0] = a;
|
buffer_lines_origin[buffer_lines_size + 0] = a;
|
||||||
buffer_lines_origin[buffer_lines_size + 1] = b;
|
buffer_lines_origin[buffer_lines_size + 1] = b;
|
||||||
|
|
||||||
if (print) printf("In graphics_write_line() buffer_lines_size => [%2ld] [%2ld > %2ld] (%3u > %3u )\n\n",\
|
if (console) printf("In graphics_draw_line() buffer_lines_size => [%2ld] [%2ld > %2ld] (%3u > %3u )\n",\
|
||||||
buffer_lines_size / 2, buffer_lines_size + 0, buffer_lines_size + 1, a, b);
|
buffer_lines_size / 2, buffer_lines_size + 0, buffer_lines_size + 1, a, b);
|
||||||
|
|
||||||
buffer_lines_size += 2;
|
buffer_lines_size += 2;
|
||||||
|
@ -194,7 +195,7 @@ void graphics_write_line (GLuint a, GLuint b, int print)
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
void graphics_write_plan (GLuint a, GLuint b, GLuint c)
|
void graphics_draw_plan (GLuint a, GLuint b, GLuint c, int console)
|
||||||
{
|
{
|
||||||
buffer_plans_origin = g_realloc (buffer_plans_origin,
|
buffer_plans_origin = g_realloc (buffer_plans_origin,
|
||||||
(buffer_plans_size + 3) * sizeof(GLuint));
|
(buffer_plans_size + 3) * sizeof(GLuint));
|
||||||
|
@ -590,8 +591,8 @@ static inline int create_arrow (int arrows_nb,
|
||||||
arrows_ptr[arrows_nb].y = y;
|
arrows_ptr[arrows_nb].y = y;
|
||||||
arrows_ptr[arrows_nb].z = z;
|
arrows_ptr[arrows_nb].z = z;
|
||||||
|
|
||||||
write_one_arrow_vertex(space_X, space_Y, space_Z, load, site, x, y, z, console);
|
draw_one_arrow_vertex(space_X, space_Y, space_Z, load, site, x, y, z, console);
|
||||||
write_one_arrow_line (buffer_vertex_size / 3 - 2, console);
|
draw_one_arrow_line (buffer_vertex_size / 3 - 2, console);
|
||||||
|
|
||||||
arrows_nb ++;
|
arrows_nb ++;
|
||||||
|
|
||||||
|
@ -640,9 +641,9 @@ static inline int erase_arrow (int arrows_nb, int arrow_address_in_list,
|
||||||
buffer_colors_origin [buffer_colors_0_arrow + arrow_address_in_list * 6 + i]
|
buffer_colors_origin [buffer_colors_0_arrow + arrow_address_in_list * 6 + i]
|
||||||
= buffer_colors_origin [buffer_colors_size - 6 + i];
|
= buffer_colors_origin [buffer_colors_size - 6 + i];
|
||||||
|
|
||||||
buffer_vertex_size -= 6; // <<< l'inverse de ce qui est fait dans : graphics_write_vertex()
|
buffer_vertex_size -= 6; // <<< l'inverse de ce qui est fait dans : graphics_draw_vertex()
|
||||||
buffer_colors_size -= 6; // <<< l'inverse de ce qui est fait dans : graphics_write_colors()
|
buffer_colors_size -= 6; // <<< l'inverse de ce qui est fait dans : graphics_draw_colors()
|
||||||
buffer_lines_size -= 2; // <<< l'inverse de ce qui est fait dans : graphics_write_line()
|
buffer_lines_size -= 2; // <<< l'inverse de ce qui est fait dans : graphics_draw_line()
|
||||||
|
|
||||||
void *new_arrows_vertex_ptr = g_realloc(buffer_vertex_origin, buffer_vertex_size * sizeof(GLfloat));
|
void *new_arrows_vertex_ptr = g_realloc(buffer_vertex_origin, buffer_vertex_size * sizeof(GLfloat));
|
||||||
if (new_arrows_vertex_ptr) buffer_vertex_origin = new_arrows_vertex_ptr;
|
if (new_arrows_vertex_ptr) buffer_vertex_origin = new_arrows_vertex_ptr;
|
||||||
|
@ -707,6 +708,7 @@ static inline int set_arrow (struct arrow_t *arrows_ptr, int arrows_nb, int spac
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
assert (address <= arrows_nb);
|
assert (address <= arrows_nb);
|
||||||
|
|
||||||
if (console) {
|
if (console) {
|
||||||
if (address == -1 && requested_weight > 0) printf(" >> create_arrow() at site %d\n", site);
|
if (address == -1 && requested_weight > 0) printf(" >> create_arrow() at site %d\n", site);
|
||||||
if (address >= 0 && requested_weight == 0) printf(" >> erase_arrow() at site %d\n", site);
|
if (address >= 0 && requested_weight == 0) printf(" >> erase_arrow() at site %d\n", site);
|
||||||
|
@ -756,14 +758,14 @@ void main_test_graphics (void)
|
||||||
|
|
||||||
|
|
||||||
srand(time(NULL)); int rand(void); void srand(unsigned int seed);
|
srand(time(NULL)); int rand(void); void srand(unsigned int seed);
|
||||||
int randomize = 60, console = 0, arrows_nb = 0, space_X = 1, space_Y = 1, space_Z = 1;
|
int randomize = 0, console = 0, arrows_nb = 0, space_X = 1, space_Y = 1, space_Z = 1;
|
||||||
if (randomize) {
|
if (randomize) {
|
||||||
space_X = 1 + rand() % randomize;
|
space_X = 1 + rand() % randomize;
|
||||||
space_Y = 1 + rand() % randomize;
|
space_Y = 1 + rand() % randomize;
|
||||||
space_Z = 1 + rand() % randomize;
|
space_Z = 1 + rand() % randomize;
|
||||||
}
|
}
|
||||||
int density_max = space_X * space_Y * space_Z, specified_arrows_nb = density_max;
|
int density_max = space_X * space_Y * space_Z, specified_arrows_nb = density_max;
|
||||||
int max = fmax(space_X, space_Y); max = fmax(max, space_Z);
|
/* int max = fmax(space_X, space_Y); max = fmax(max, space_Z); */
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
|
@ -772,11 +774,10 @@ void main_test_graphics (void)
|
||||||
|
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
draw_space_ridges_vertex (buffer_vertex_size, space_X, space_Y, space_Z, console);
|
||||||
write_space_ridges_vertex (buffer_vertex_size, space_X, space_Y, space_Z);
|
draw_space_ridges_lines (console);
|
||||||
write_space_ridges_lines ();
|
draw_grids_on_space_faces_vertex (space_X, space_Y, space_Z, console);
|
||||||
write_grids_on_space_faces_vertex (space_X, space_Y, space_Z);
|
draw_grids_on_space_faces_lines (buffer_lines_size, space_X, space_Y, space_Z, console);
|
||||||
write_grids_on_space_faces_lines (buffer_lines_size, space_X, space_Y, space_Z);
|
|
||||||
|
|
||||||
buffer_vertex_0_arrow = buffer_vertex_size;
|
buffer_vertex_0_arrow = buffer_vertex_size;
|
||||||
buffer_colors_0_arrow = buffer_colors_size;
|
buffer_colors_0_arrow = buffer_colors_size;
|
||||||
|
@ -790,8 +791,6 @@ void main_test_graphics (void)
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
||||||
printf("specified_arrows_nb: %d\n", specified_arrows_nb);
|
|
||||||
|
|
||||||
if (randomize) for (int i = 0; i < specified_arrows_nb; i++)
|
if (randomize) for (int i = 0; i < specified_arrows_nb; i++)
|
||||||
{
|
{
|
||||||
arrows_nb = set_arrow (arrows_ptr, arrows_nb, space_X, space_Y, space_Z,
|
arrows_nb = set_arrow (arrows_ptr, arrows_nb, space_X, space_Y, space_Z,
|
||||||
|
@ -805,32 +804,32 @@ void main_test_graphics (void)
|
||||||
if (i > 0 && i % 100000 == 0) printf("\n");
|
if (i > 0 && i % 100000 == 0) printf("\n");
|
||||||
}
|
}
|
||||||
else for (int i = 0; i < 6; i++)
|
else for (int i = 0; i < 6; i++)
|
||||||
arrows_nb = set_arrow (arrows_ptr, arrows_nb, 1, 1, 1, 1, i, 0, 0, 0, 0);
|
arrows_nb = set_arrow (arrows_ptr, arrows_nb, 1, 1, 1, 1, i, 0, 0, 0, console);
|
||||||
|
|
||||||
int max_arrows_nb = arrows_nb;
|
int max_arrows_nb = arrows_nb;
|
||||||
printf("\nend initial arrows drawing\n");
|
|
||||||
|
|
||||||
if (randomize) for (int i = 0; i < 6; i++)
|
/* if (randomize) for (int i = 0; i < 6; i++) */
|
||||||
arrows_nb = set_arrow (arrows_ptr, arrows_nb, space_X, space_Y, space_Z,
|
/* arrows_nb = set_arrow (arrows_ptr, arrows_nb, space_X, space_Y, space_Z, */
|
||||||
rand() % 1, // load
|
/* rand() % 1, // load */
|
||||||
rand() % 6, // site
|
/* rand() % 6, // site */
|
||||||
rand() % space_X, // x
|
/* rand() % space_X, // x */
|
||||||
rand() % space_Y, // y
|
/* rand() % space_Y, // y */
|
||||||
rand() % space_Z, // z
|
/* rand() % space_Z, // z */
|
||||||
console);
|
/* console); */
|
||||||
else for (int i = 0; i < 6; i++)
|
/* else for (int i = 0; i < 6; i++) */
|
||||||
arrows_nb = set_arrow (arrows_ptr, arrows_nb, 1, 1, 1, 0, i, 0, 0, 0, 0);
|
/* arrows_nb = set_arrow (arrows_ptr, arrows_nb, 1, 1, 1, 0, i, 0, 0, 0, 0); */
|
||||||
|
|
||||||
int angle = 9;
|
/* int angle = 9; */
|
||||||
if (space_X > angle && space_Y > angle && space_Z > angle) for (int i = 0; i < angle; i++)
|
/* if (space_X > angle && space_Y > angle && space_Z > angle) for (int i = 0; i < angle; i++) */
|
||||||
for (int u = 0; u < angle; u++) for (int v = 0; v < angle; v++) for (int w = 0; w < angle; w++)
|
/* for (int u = 0; u < angle; u++) for (int v = 0; v < angle; v++) for (int w = 0; w < angle; w++) */
|
||||||
if (u + v + w < angle * 3)
|
/* if (u + v + w < angle * 3) */
|
||||||
arrows_nb = set_arrow (arrows_ptr, arrows_nb, 1, 1, 1, 0, i, u, v, w, 0);
|
/* arrows_nb = set_arrow (arrows_ptr, arrows_nb, 1, 1, 1, 0, i, u, v, w, 0); */
|
||||||
|
|
||||||
if (space_X > angle && space_Y > angle && space_Z > angle)
|
/* if (space_X > angle && space_Y > angle && space_Z > angle) */
|
||||||
printf("+ effacement des flèches dans l'angle-origine\
|
/* printf("+ effacement des flèches dans l'angle-origine\ */
|
||||||
<=> contrôle graphique de la fonction erase_arrow()\n");
|
/* <=> contrôle graphique de la fonction erase_arrow()\n"); */
|
||||||
|
|
||||||
if (randomize) print_user_choices(arrows_ptr, max_arrows_nb, arrows_nb, space_X, space_Y, space_Z, 0, 0);
|
if (1) print_user_choices(arrows_ptr, max_arrows_nb, arrows_nb, space_X, space_Y, space_Z, 0, 0);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -25,128 +25,128 @@
|
||||||
#include "../../include/base.h"
|
#include "../../include/base.h"
|
||||||
#include "../../include/graphics.h"
|
#include "../../include/graphics.h"
|
||||||
|
|
||||||
int write_space_ridges_vertex (long offset_vertex, long x, long y, long z)
|
int draw_space_ridges_vertex (long offset_vertex, long x, long y, long z, int console)
|
||||||
{
|
{
|
||||||
float max = fmax(x, y); max = fmax(max, z);
|
GLfloat max = fmax(x, y); max = fmax(max, z);
|
||||||
|
|
||||||
graphics_write_vertex (offset_vertex - x / max, offset_vertex - y / max, - z / max, 0);
|
graphics_draw_vertex (offset_vertex - x / max, offset_vertex - y / max, - z / max, console);
|
||||||
|
|
||||||
graphics_write_vertex (offset_vertex + x / max, offset_vertex - y / max, - z / max, 0);
|
graphics_draw_vertex (offset_vertex + x / max, offset_vertex - y / max, - z / max, console);
|
||||||
graphics_write_vertex (offset_vertex - x / max, offset_vertex + y / max, - z / max, 0);
|
graphics_draw_vertex (offset_vertex - x / max, offset_vertex + y / max, - z / max, console);
|
||||||
graphics_write_vertex (offset_vertex - x / max, offset_vertex - y / max, + z / max, 0);
|
graphics_draw_vertex (offset_vertex - x / max, offset_vertex - y / max, + z / max, console);
|
||||||
|
|
||||||
graphics_write_vertex (offset_vertex + x / max, offset_vertex + y / max, - z / max, 0);
|
graphics_draw_vertex (offset_vertex + x / max, offset_vertex + y / max, - z / max, console);
|
||||||
graphics_write_vertex (offset_vertex + x / max, offset_vertex - y / max, + z / max, 0);
|
graphics_draw_vertex (offset_vertex + x / max, offset_vertex - y / max, + z / max, console);
|
||||||
graphics_write_vertex (offset_vertex - x / max, offset_vertex + y / max, + z / max, 0);
|
graphics_draw_vertex (offset_vertex - x / max, offset_vertex + y / max, + z / max, console);
|
||||||
|
|
||||||
graphics_write_vertex (offset_vertex + x / max, + y / max, + z / max, 0);
|
graphics_draw_vertex (offset_vertex + x / max, + y / max, + z / max, console);
|
||||||
|
|
||||||
graphics_write_color (0.8f, 0.6f, 0.5f);
|
graphics_draw_color (0.8f, 0.6f, 0.5f, console);
|
||||||
graphics_write_color (0.8f, 0.6f, 0.5f);
|
graphics_draw_color (0.8f, 0.6f, 0.5f, console);
|
||||||
graphics_write_color (0.8f, 0.6f, 0.5f);
|
graphics_draw_color (0.8f, 0.6f, 0.5f, console);
|
||||||
graphics_write_color (0.8f, 0.6f, 0.5f);
|
graphics_draw_color (0.8f, 0.6f, 0.5f, console);
|
||||||
graphics_write_color (0.8f, 0.6f, 0.5f);
|
graphics_draw_color (0.8f, 0.6f, 0.5f, console);
|
||||||
graphics_write_color (0.8f, 0.6f, 0.5f);
|
graphics_draw_color (0.8f, 0.6f, 0.5f, console);
|
||||||
graphics_write_color (0.8f, 0.6f, 0.5f);
|
graphics_draw_color (0.8f, 0.6f, 0.5f, console);
|
||||||
graphics_write_color (0.8f, 0.6f, 0.5f);
|
graphics_draw_color (0.8f, 0.6f, 0.5f, console);
|
||||||
|
|
||||||
return 8;
|
return 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
int write_space_ridges_lines ()
|
int draw_space_ridges_lines (int console)
|
||||||
{
|
{
|
||||||
graphics_write_line ( 0, 1, 0); graphics_write_line ( 7, 4, 0);
|
graphics_draw_line ( 0, 1, console); graphics_draw_line ( 7, 4, console);
|
||||||
graphics_write_line ( 0, 2, 0); graphics_write_line ( 7, 5, 0);
|
graphics_draw_line ( 0, 2, console); graphics_draw_line ( 7, 5, console);
|
||||||
graphics_write_line ( 0, 3, 0); graphics_write_line ( 7, 6, 0);
|
graphics_draw_line ( 0, 3, console); graphics_draw_line ( 7, 6, console);
|
||||||
|
|
||||||
graphics_write_line ( 1, 4, 0); graphics_write_line ( 2, 4, 0);
|
graphics_draw_line ( 1, 4, console); graphics_draw_line ( 2, 4, console);
|
||||||
graphics_write_line ( 1, 5, 0); graphics_write_line ( 3, 5, 0);
|
graphics_draw_line ( 1, 5, console); graphics_draw_line ( 3, 5, console);
|
||||||
graphics_write_line ( 2, 6, 0); graphics_write_line ( 3, 6, 0);
|
graphics_draw_line ( 2, 6, console); graphics_draw_line ( 3, 6, console);
|
||||||
|
|
||||||
return 12;
|
return 12;
|
||||||
}
|
}
|
||||||
|
|
||||||
long write_grids_on_space_faces_vertex (long x, long y, long z)
|
long draw_grids_on_space_faces_vertex (long x, long y, long z, int console)
|
||||||
{
|
{
|
||||||
float i, max = fmax(x, y); max = fmax(max, z);
|
float i, max = fmax(x, y); max = fmax(max, z);
|
||||||
|
|
||||||
for (i = 1; i < x; i++) {
|
for (i = 1; i < x; i++) {
|
||||||
|
|
||||||
graphics_write_vertex ((2 * i / x - 1) * x / max, - y / max, - z / max, 0);
|
graphics_draw_vertex ((2 * i / x - 1) * x / max, - y / max, - z / max, console);
|
||||||
graphics_write_vertex ((2 * i / x - 1) * x / max, - y / max, z / max, 0);
|
graphics_draw_vertex ((2 * i / x - 1) * x / max, - y / max, z / max, console);
|
||||||
graphics_write_vertex ((2 * i / x - 1) * x / max, y / max, z / max, 0);
|
graphics_draw_vertex ((2 * i / x - 1) * x / max, y / max, z / max, console);
|
||||||
graphics_write_vertex ((2 * i / x - 1) * x / max, y / max, - z / max, 0);
|
graphics_draw_vertex ((2 * i / x - 1) * x / max, y / max, - z / max, console);
|
||||||
|
|
||||||
graphics_write_color (0.55f, 0.55f, 0.55f);
|
graphics_draw_color (0.55f, 0.55f, 0.55f, console);
|
||||||
graphics_write_color (0.55f, 0.55f, 0.55f);
|
graphics_draw_color (0.55f, 0.55f, 0.55f, console);
|
||||||
graphics_write_color (0.55f, 0.55f, 0.55f);
|
graphics_draw_color (0.55f, 0.55f, 0.55f, console);
|
||||||
graphics_write_color (0.55f, 0.55f, 0.55f);
|
graphics_draw_color (0.55f, 0.55f, 0.55f, console);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* offset_vertex += (x - 1) * 4; */ /* offset_colors += (x - 1) * 4; */
|
/* offset_vertex += (x - 1) * 4; */ /* offset_colors += (x - 1) * 4; */
|
||||||
|
|
||||||
for (i = 1; i < y; i++) {
|
for (i = 1; i < y; i++) {
|
||||||
|
|
||||||
graphics_write_vertex (- x / max, (2 * i / y - 1) * y / max, - z / max, 0);
|
graphics_draw_vertex (- x / max, (2 * i / y - 1) * y / max, - z / max, console);
|
||||||
graphics_write_vertex (- x / max, (2 * i / y - 1) * y / max, z / max, 0);
|
graphics_draw_vertex (- x / max, (2 * i / y - 1) * y / max, z / max, console);
|
||||||
graphics_write_vertex ( x / max, (2 * i / y - 1) * y / max, z / max, 0);
|
graphics_draw_vertex ( x / max, (2 * i / y - 1) * y / max, z / max, console);
|
||||||
graphics_write_vertex ( x / max, (2 * i / y - 1) * y / max, - z / max, 0);
|
graphics_draw_vertex ( x / max, (2 * i / y - 1) * y / max, - z / max, console);
|
||||||
|
|
||||||
graphics_write_color (0.55f, 0.55f, 0.55f);
|
graphics_draw_color (0.55f, 0.55f, 0.55f, console);
|
||||||
graphics_write_color (0.55f, 0.55f, 0.55f);
|
graphics_draw_color (0.55f, 0.55f, 0.55f, console);
|
||||||
graphics_write_color (0.55f, 0.55f, 0.55f);
|
graphics_draw_color (0.55f, 0.55f, 0.55f, console);
|
||||||
graphics_write_color (0.55f, 0.55f, 0.55f);
|
graphics_draw_color (0.55f, 0.55f, 0.55f, console);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* offset_vertex += (y - 1) * 4; */ /* offset_colors += (y - 1) * 4; */
|
/* offset_vertex += (y - 1) * 4; */ /* offset_colors += (y - 1) * 4; */
|
||||||
|
|
||||||
for (i = 1; i < z; i++) {
|
for (i = 1; i < z; i++) {
|
||||||
|
|
||||||
graphics_write_vertex (- x / max, - y / max, (2 * i / z - 1) * z / max, 0);
|
graphics_draw_vertex (- x / max, - y / max, (2 * i / z - 1) * z / max, console);
|
||||||
graphics_write_vertex (- x / max, y / max, (2 * i / z - 1) * z / max, 0);
|
graphics_draw_vertex (- x / max, y / max, (2 * i / z - 1) * z / max, console);
|
||||||
graphics_write_vertex ( x / max, y / max, (2 * i / z - 1) * z / max, 0);
|
graphics_draw_vertex ( x / max, y / max, (2 * i / z - 1) * z / max, console);
|
||||||
graphics_write_vertex ( x / max, - y / max, (2 * i / z - 1) * z / max, 0);
|
graphics_draw_vertex ( x / max, - y / max, (2 * i / z - 1) * z / max, console);
|
||||||
|
|
||||||
graphics_write_color (0.55f, 0.55f, 0.55f);
|
graphics_draw_color (0.55f, 0.55f, 0.55f, console);
|
||||||
graphics_write_color (0.55f, 0.55f, 0.55f);
|
graphics_draw_color (0.55f, 0.55f, 0.55f, console);
|
||||||
graphics_write_color (0.55f, 0.55f, 0.55f);
|
graphics_draw_color (0.55f, 0.55f, 0.55f, console);
|
||||||
graphics_write_color (0.55f, 0.55f, 0.55f);
|
graphics_draw_color (0.55f, 0.55f, 0.55f, console);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (x + y + z - 3) * 3;
|
return (x + y + z - 3) * 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
long write_grids_on_space_faces_lines (long offset_vertex, long x, long y, long z)
|
long draw_grids_on_space_faces_lines (long offset_vertex, long x, long y, long z, int console)
|
||||||
{
|
{
|
||||||
offset_vertex = offset_vertex / 3;
|
offset_vertex = offset_vertex / 3;
|
||||||
|
|
||||||
for (int i = 0; i < x - 1; i ++) {
|
for (int i = 0; i < x - 1; i ++) {
|
||||||
|
|
||||||
/* graphics_write_line (offset_vertex + i * 4 + 0, offset_vertex + i * 4 + 1, 0); */
|
/* graphics_draw_line (offset_vertex + i * 4 + 0, offset_vertex + i * 4 + 1, console); */
|
||||||
graphics_write_line (offset_vertex + i * 4 + 1, offset_vertex + i * 4 + 2, 0);
|
graphics_draw_line (offset_vertex + i * 4 + 1, offset_vertex + i * 4 + 2, console);
|
||||||
graphics_write_line (offset_vertex + i * 4 + 2, offset_vertex + i * 4 + 3, 0);
|
graphics_draw_line (offset_vertex + i * 4 + 2, offset_vertex + i * 4 + 3, console);
|
||||||
/* graphics_write_line (offset_vertex + i * 4 + 3, offset_vertex + i * 4 + 0, 0); */
|
/* graphics_draw_line (offset_vertex + i * 4 + 3, offset_vertex + i * 4 + 0, console); */
|
||||||
}
|
}
|
||||||
|
|
||||||
offset_vertex += (x - 1) * 4;
|
offset_vertex += (x - 1) * 4;
|
||||||
|
|
||||||
for (int i = 0; i < y - 1; i ++) {
|
for (int i = 0; i < y - 1; i ++) {
|
||||||
|
|
||||||
/* graphics_write_line (offset_vertex + i * 4 + 0, offset_vertex + i * 4 + 1, 0); */
|
/* graphics_draw_line (offset_vertex + i * 4 + 0, offset_vertex + i * 4 + 1, console); */
|
||||||
/* graphics_write_line (offset_vertex + i * 4 + 1, offset_vertex + i * 4 + 2, 0); */
|
/* graphics_draw_line (offset_vertex + i * 4 + 1, offset_vertex + i * 4 + 2, console); */
|
||||||
graphics_write_line (offset_vertex + i * 4 + 2, offset_vertex + i * 4 + 3, 0);
|
graphics_draw_line (offset_vertex + i * 4 + 2, offset_vertex + i * 4 + 3, console);
|
||||||
graphics_write_line (offset_vertex + i * 4 + 3, offset_vertex + i * 4 + 0, 0);
|
graphics_draw_line (offset_vertex + i * 4 + 3, offset_vertex + i * 4 + 0, console);
|
||||||
}
|
}
|
||||||
|
|
||||||
offset_vertex += (y - 1) * 4;
|
offset_vertex += (y - 1) * 4;
|
||||||
|
|
||||||
for (int i = 0; i < z - 1; i ++) {
|
for (int i = 0; i < z - 1; i ++) {
|
||||||
|
|
||||||
graphics_write_line (offset_vertex + i * 4 + 0, offset_vertex + i * 4 + 1, 0);
|
graphics_draw_line (offset_vertex + i * 4 + 0, offset_vertex + i * 4 + 1, console);
|
||||||
/* graphics_write_line (offset_vertex + i * 4 + 1, offset_vertex + i * 4 + 2, 0); */
|
/* graphics_draw_line (offset_vertex + i * 4 + 1, offset_vertex + i * 4 + 2, console); */
|
||||||
/* graphics_write_line (offset_vertex + i * 4 + 2, offset_vertex + i * 4 + 3, 0); */
|
/* graphics_draw_line (offset_vertex + i * 4 + 2, offset_vertex + i * 4 + 3, console); */
|
||||||
graphics_write_line (offset_vertex + i * 4 + 3, offset_vertex + i * 4 + 0, 0);
|
graphics_draw_line (offset_vertex + i * 4 + 3, offset_vertex + i * 4 + 0, console);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (x + y + z - 3) * 4;
|
return (x + y + z - 3) * 4;
|
||||||
|
|
Loading…
Reference in New Issue