diff --git a/include/arrows.h b/include/arrows.h index 45d4ea6..2b54c9f 100644 --- a/include/arrows.h +++ b/include/arrows.h @@ -38,8 +38,8 @@ typedef struct arrow_t { 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 write_one_arrow_line(int offset_vertex, int print); +int draw_one_arrow_line(int offset_vertex, int print); diff --git a/include/graphics.h b/include/graphics.h index 8fe31b0..b234bad 100644 --- a/include/graphics.h +++ b/include/graphics.h @@ -44,8 +44,6 @@ struct gl_area_entry { GLuint m; // init_shaders, draw GLuint v; // 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); +/* + * 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 * @@ -108,25 +126,7 @@ void graphics_init_buffers(const void *gl_area); * * @return void */ -void graphics_write_line (GLuint a, GLuint b, int print); - -/* - * 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); +void graphics_draw_line (GLuint a, GLuint b, int console); /* * 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 */ -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 diff --git a/include/grid.h b/include/grid.h index 766abd2..78c94ea 100644 --- a/include/grid.h +++ b/include/grid.h @@ -34,8 +34,8 @@ * * @return void */ -int write_space_ridges_vertex (long offset_vertex, long x, long y, long z); -int write_space_ridges_lines (); +int draw_space_ridges_vertex (long offset_vertex, long x, long y, long z, int console); +int draw_space_ridges_lines (int console); /* * Writes grid lines on space faces @@ -44,6 +44,6 @@ int write_space_ridges_lines (); * * @return void */ -long write_grids_on_space_faces_vertex (long x, long y, long z); -long write_grids_on_space_faces_lines (long offset_vertex, long x, long y, long z); +long draw_grids_on_space_faces_vertex (long x, long y, long z, int console); +long draw_grids_on_space_faces_lines (long offset_vertex, long x, long y, long z, int console); diff --git a/src/graphics/arrows.c b/src/graphics/arrows.c index 0a8042e..dd55e9d 100644 --- a/src/graphics/arrows.c +++ b/src/graphics/arrows.c @@ -33,8 +33,8 @@ * Z - Z = NORTH - SOUTH = bleu - jaune */ -int write_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 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 console) { 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), vz = (2 * k / space_Z_int - 1) * space_Z_int / max + (1 / max); - graphics_write_vertex(vx, vy, vz, print); - graphics_write_color(0.4f, 0.4f, 0.4f); + graphics_draw_vertex(vx, vy, vz, console); + graphics_draw_color(0.4f, 0.4f, 0.4f, console); // réduit légèrement les longueurs des flèches // 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){ case EAST: - 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); + graphics_draw_vertex (vx - (site % 2 - 1) * (1 / max) + (site % 2 - 1) * arrow_tip_padding, vy, vz, console); + graphics_draw_color (1.0f, 0.0f, 0.0f, console); break; case WEST: - 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); + graphics_draw_vertex (vx - (site % 2) * (1 / max) + (site % 2) * arrow_tip_padding, vy, vz, console); + graphics_draw_color (0.0f, 1.0f, 1.0f, console); break; case ZENITH: - graphics_write_vertex (vx, vy - (site % 2 - 1) * (1 / max) + (site % 2 - 1) * arrow_tip_padding, vz, print); - graphics_write_color(0.0f, 0.6f, 0.1f); + graphics_draw_vertex (vx, vy - (site % 2 - 1) * (1 / max) + (site % 2 - 1) * arrow_tip_padding, vz, console); + graphics_draw_color(0.0f, 0.6f, 0.1f, console); break; case NADIR: - graphics_write_vertex (vx, vy - (site % 2) * (1 / max) + (site % 2) * arrow_tip_padding, vz, print); - graphics_write_color(0.6f, 0.1f, 0.7f); + graphics_draw_vertex (vx, vy - (site % 2) * (1 / max) + (site % 2) * arrow_tip_padding, vz, console); + graphics_draw_color(0.6f, 0.1f, 0.7f, console); break; case SOUTH: - graphics_write_vertex (vx, vy, vz - (site % 2 + 1) * (1 / max) + (site % 2 + 1) * arrow_tip_padding, print); - graphics_write_color(0.05f, 0.4f, 1.0f); + graphics_draw_vertex (vx, vy, vz - (site % 2 + 1) * (1 / max) + (site % 2 + 1) * arrow_tip_padding, console); + graphics_draw_color(0.05f, 0.4f, 1.0f, console); break; case NORTH: - graphics_write_vertex (vx, vy, vz - (site % 2 - 2) * (1 / max) + (site % 2 - 2) * arrow_tip_padding, print); - graphics_write_color(1.0f, 1.0f, 0.0f); + graphics_draw_vertex (vx, vy, vz - (site % 2 - 2) * (1 / max) + (site % 2 - 2) * arrow_tip_padding, console); + graphics_draw_color(1.0f, 1.0f, 0.0f, console); 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; } diff --git a/src/graphics/graphics.c b/src/graphics/graphics.c index 30d5187..cd9b25a 100644 --- a/src/graphics/graphics.c +++ b/src/graphics/graphics.c @@ -36,6 +36,7 @@ #define FRAG_SHADER_FILE "src/shaders/shader.frag" static struct arrow_t *arrows_ptr; + GLfloat *buffer_vertex_origin = NULL; GLfloat *buffer_colors_origin = NULL; GLuint *buffer_lines_origin = NULL; @@ -126,7 +127,7 @@ static void graphics_debug_callback(GLenum source, GLenum type, GLuint id, * * @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_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 + 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; @@ -150,7 +151,7 @@ void graphics_write_vertex (GLfloat x, GLfloat y, GLfloat z, int print) * * @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_size + 3) * sizeof(GLfloat)); @@ -171,7 +172,7 @@ void graphics_write_color (GLfloat r, GLfloat g, GLfloat b) * * @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_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 + 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; @@ -194,7 +195,7 @@ void graphics_write_line (GLuint a, GLuint b, int print) * * @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_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].z = z; - write_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_vertex(space_X, space_Y, space_Z, load, site, x, y, z, console); + draw_one_arrow_line (buffer_vertex_size / 3 - 2, console); 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_size - 6 + i]; - buffer_vertex_size -= 6; // <<< l'inverse de ce qui est fait dans : graphics_write_vertex() - buffer_colors_size -= 6; // <<< l'inverse de ce qui est fait dans : graphics_write_colors() - buffer_lines_size -= 2; // <<< l'inverse de ce qui est fait dans : graphics_write_line() + 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_draw_colors() + 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)); 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; } assert (address <= arrows_nb); + if (console) { 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); @@ -756,14 +758,14 @@ void main_test_graphics (void) 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) { space_X = 1 + rand() % randomize; space_Y = 1 + rand() % randomize; space_Z = 1 + rand() % randomize; } 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) /*------------------------------------------------------------------------*/ - - write_space_ridges_vertex (buffer_vertex_size, space_X, space_Y, space_Z); - write_space_ridges_lines (); - write_grids_on_space_faces_vertex (space_X, space_Y, space_Z); - write_grids_on_space_faces_lines (buffer_lines_size, space_X, space_Y, space_Z); + draw_space_ridges_vertex (buffer_vertex_size, space_X, space_Y, space_Z, console); + draw_space_ridges_lines (console); + draw_grids_on_space_faces_vertex (space_X, space_Y, space_Z, console); + draw_grids_on_space_faces_lines (buffer_lines_size, space_X, space_Y, space_Z, console); buffer_vertex_0_arrow = buffer_vertex_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++) { 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"); } 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; - printf("\nend initial arrows drawing\n"); - if (randomize) for (int i = 0; i < 6; i++) - arrows_nb = set_arrow (arrows_ptr, arrows_nb, space_X, space_Y, space_Z, - rand() % 1, // load - rand() % 6, // site - rand() % space_X, // x - rand() % space_Y, // y - rand() % space_Z, // z - console); - 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); + /* if (randomize) for (int i = 0; i < 6; i++) */ + /* arrows_nb = set_arrow (arrows_ptr, arrows_nb, space_X, space_Y, space_Z, */ + /* rand() % 1, // load */ + /* rand() % 6, // site */ + /* rand() % space_X, // x */ + /* rand() % space_Y, // y */ + /* rand() % space_Z, // z */ + /* console); */ + /* 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); */ - int angle = 9; - 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++) - if (u + v + w < angle * 3) - arrows_nb = set_arrow (arrows_ptr, arrows_nb, 1, 1, 1, 0, i, u, v, w, 0); + /* int angle = 9; */ + /* 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++) */ + /* if (u + v + w < angle * 3) */ + /* 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) - printf("+ effacement des flèches dans l'angle-origine\ - <=> contrôle graphique de la fonction erase_arrow()\n"); + /* if (space_X > angle && space_Y > angle && space_Z > angle) */ + /* printf("+ effacement des flèches dans l'angle-origine\ */ + /* <=> 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); diff --git a/src/graphics/grid.c b/src/graphics/grid.c index d618888..9ff5474 100644 --- a/src/graphics/grid.c +++ b/src/graphics/grid.c @@ -25,128 +25,128 @@ #include "../../include/base.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_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_draw_vertex (offset_vertex + x / max, offset_vertex - y / max, - z / max, console); + graphics_draw_vertex (offset_vertex - x / max, offset_vertex + y / max, - z / max, console); + 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_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_draw_vertex (offset_vertex + x / max, offset_vertex + y / max, - z / max, console); + graphics_draw_vertex (offset_vertex + x / max, offset_vertex - y / max, + z / max, console); + 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_write_color (0.8f, 0.6f, 0.5f); - graphics_write_color (0.8f, 0.6f, 0.5f); - graphics_write_color (0.8f, 0.6f, 0.5f); - graphics_write_color (0.8f, 0.6f, 0.5f); - graphics_write_color (0.8f, 0.6f, 0.5f); - graphics_write_color (0.8f, 0.6f, 0.5f); - graphics_write_color (0.8f, 0.6f, 0.5f); + graphics_draw_color (0.8f, 0.6f, 0.5f, console); + graphics_draw_color (0.8f, 0.6f, 0.5f, console); + graphics_draw_color (0.8f, 0.6f, 0.5f, console); + graphics_draw_color (0.8f, 0.6f, 0.5f, console); + graphics_draw_color (0.8f, 0.6f, 0.5f, console); + graphics_draw_color (0.8f, 0.6f, 0.5f, console); + graphics_draw_color (0.8f, 0.6f, 0.5f, console); + graphics_draw_color (0.8f, 0.6f, 0.5f, console); 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_write_line ( 0, 2, 0); graphics_write_line ( 7, 5, 0); - graphics_write_line ( 0, 3, 0); graphics_write_line ( 7, 6, 0); + graphics_draw_line ( 0, 1, console); graphics_draw_line ( 7, 4, console); + graphics_draw_line ( 0, 2, console); graphics_draw_line ( 7, 5, console); + 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_write_line ( 1, 5, 0); graphics_write_line ( 3, 5, 0); - graphics_write_line ( 2, 6, 0); graphics_write_line ( 3, 6, 0); + graphics_draw_line ( 1, 4, console); graphics_draw_line ( 2, 4, console); + graphics_draw_line ( 1, 5, console); graphics_draw_line ( 3, 5, console); + graphics_draw_line ( 2, 6, console); graphics_draw_line ( 3, 6, console); 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); for (i = 1; i < x; i++) { - 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_draw_vertex ((2 * i / x - 1) * x / max, - y / max, - z / max, console); + graphics_draw_vertex ((2 * i / x - 1) * x / max, - y / max, z / max, console); + graphics_draw_vertex ((2 * i / x - 1) * x / max, y / max, z / max, console); + graphics_draw_vertex ((2 * i / x - 1) * x / max, y / max, - z / max, console); - graphics_write_color (0.55f, 0.55f, 0.55f); - graphics_write_color (0.55f, 0.55f, 0.55f); - graphics_write_color (0.55f, 0.55f, 0.55f); - graphics_write_color (0.55f, 0.55f, 0.55f); + graphics_draw_color (0.55f, 0.55f, 0.55f, console); + graphics_draw_color (0.55f, 0.55f, 0.55f, console); + graphics_draw_color (0.55f, 0.55f, 0.55f, console); + graphics_draw_color (0.55f, 0.55f, 0.55f, console); } /* offset_vertex += (x - 1) * 4; */ /* offset_colors += (x - 1) * 4; */ for (i = 1; i < y; i++) { - 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_draw_vertex (- x / max, (2 * i / y - 1) * y / max, - z / max, console); + graphics_draw_vertex (- x / max, (2 * i / y - 1) * y / max, z / max, console); + graphics_draw_vertex ( x / max, (2 * i / y - 1) * y / max, z / max, console); + graphics_draw_vertex ( x / max, (2 * i / y - 1) * y / max, - z / max, console); - graphics_write_color (0.55f, 0.55f, 0.55f); - graphics_write_color (0.55f, 0.55f, 0.55f); - graphics_write_color (0.55f, 0.55f, 0.55f); - graphics_write_color (0.55f, 0.55f, 0.55f); + graphics_draw_color (0.55f, 0.55f, 0.55f, console); + graphics_draw_color (0.55f, 0.55f, 0.55f, console); + graphics_draw_color (0.55f, 0.55f, 0.55f, console); + graphics_draw_color (0.55f, 0.55f, 0.55f, console); } /* offset_vertex += (y - 1) * 4; */ /* offset_colors += (y - 1) * 4; */ for (i = 1; i < z; i++) { - 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_draw_vertex (- x / max, - y / max, (2 * i / z - 1) * z / max, console); + graphics_draw_vertex (- x / max, y / max, (2 * i / z - 1) * z / max, console); + graphics_draw_vertex ( x / max, y / max, (2 * i / z - 1) * z / max, console); + graphics_draw_vertex ( x / max, - y / max, (2 * i / z - 1) * z / max, console); - graphics_write_color (0.55f, 0.55f, 0.55f); - graphics_write_color (0.55f, 0.55f, 0.55f); - graphics_write_color (0.55f, 0.55f, 0.55f); - graphics_write_color (0.55f, 0.55f, 0.55f); + graphics_draw_color (0.55f, 0.55f, 0.55f, console); + graphics_draw_color (0.55f, 0.55f, 0.55f, console); + graphics_draw_color (0.55f, 0.55f, 0.55f, console); + graphics_draw_color (0.55f, 0.55f, 0.55f, console); } 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; for (int i = 0; i < x - 1; i ++) { - /* 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); */ + /* graphics_draw_line (offset_vertex + i * 4 + 0, offset_vertex + i * 4 + 1, console); */ + graphics_draw_line (offset_vertex + i * 4 + 1, offset_vertex + i * 4 + 2, console); + graphics_draw_line (offset_vertex + i * 4 + 2, offset_vertex + i * 4 + 3, console); + /* graphics_draw_line (offset_vertex + i * 4 + 3, offset_vertex + i * 4 + 0, console); */ } 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, 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); + /* graphics_draw_line (offset_vertex + i * 4 + 0, offset_vertex + i * 4 + 1, console); */ + /* graphics_draw_line (offset_vertex + i * 4 + 1, offset_vertex + i * 4 + 2, console); */ + graphics_draw_line (offset_vertex + i * 4 + 2, offset_vertex + i * 4 + 3, console); + graphics_draw_line (offset_vertex + i * 4 + 3, offset_vertex + i * 4 + 0, console); } 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, 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); + graphics_draw_line (offset_vertex + i * 4 + 0, offset_vertex + i * 4 + 1, console); + /* graphics_draw_line (offset_vertex + i * 4 + 1, offset_vertex + i * 4 + 2, console); */ + /* graphics_draw_line (offset_vertex + i * 4 + 2, offset_vertex + i * 4 + 3, console); */ + graphics_draw_line (offset_vertex + i * 4 + 3, offset_vertex + i * 4 + 0, console); } return (x + y + z - 3) * 4;