WIP: encore quelques petits réglages... ça y est presque.

This commit is contained in:
Jean Sirmai 2023-10-12 09:48:15 +02:00
parent f223dd4433
commit 24ffed7223
Signed by: jean
GPG Key ID: FB3115C340E057E3
3 changed files with 38 additions and 19 deletions

View File

@ -27,9 +27,9 @@
#include <stdbool.h> #include <stdbool.h>
#include <GL/glu.h> #include <GL/glu.h>
void write_space_ridges (long offset_vertex, long offset_lines, long x, long y, long z); void write_space_ridges (long offset_vertex, long offset_colors, long offset_lines, long x, long y, long z);
void write_space_faces_grids (long offset_vertex, long offset_lines, long x, long y, long z); void write_space_faces_grids (long offset_vertex, long offset_colors, long offset_lines, long x, long y, long z, int style);
/* /*
* Writes grid lines intersections to vertex and color buffers * Writes grid lines intersections to vertex and color buffers

View File

@ -888,11 +888,11 @@ void __attribute__((optimize("no-unroll-loops"))) main_test_graphics (void)
show_user_choices(arrows, arrows_nb, space_X, space_Y, space_Z, pref_show_grids, 0, 0); show_user_choices(arrows, arrows_nb, space_X, space_Y, space_Z, pref_show_grids, 0, 0);
long offset_vertex = 0, offset_lines = 0; long offset_vertex = 0, offset_colors = 0, offset_lines = 0;
write_space_ridges (offset_vertex, offset_lines, space_X, space_Y, space_Z); write_space_ridges (offset_vertex, offset_colors, offset_lines, space_X, space_Y, space_Z);
offset_vertex = 8, offset_lines = 12; offset_vertex = 8, offset_colors = 8, offset_lines = 12;
write_space_faces_grids (offset_vertex, offset_lines, space_X, space_Y, space_Z); write_space_faces_grids (offset_vertex, offset_colors, offset_lines, space_X, space_Y, space_Z, 1);
/* ARROWS */ /* ARROWS */
/* NB The 12 vertices required to draw 6 arrows in each cube /* NB The 12 vertices required to draw 6 arrows in each cube

View File

@ -25,7 +25,7 @@
#include "../../include/base.h" #include "../../include/base.h"
#include "../../include/graphics.h" #include "../../include/graphics.h"
void write_space_ridges (long offset_vertex, long offset_lines, long x, long y, long z) void write_space_ridges (long offset_vertex, long offset_colors, long offset_lines, long x, long y, long z)
{ {
float max = fmax(x, y); max = fmax(max, z); float max = fmax(x, y); max = fmax(max, z);
@ -50,27 +50,33 @@ void write_space_ridges (long offset_vertex, long offset_lines, long x, long y,
graphics_write_line ( 2, 6); graphics_write_line ( 3, 6); graphics_write_line ( 2, 6); graphics_write_line ( 3, 6);
} }
void write_space_faces_grids (long offset_vertex, long offset_lines, long x, long y, long z) void write_space_faces_grids (long offset_vertex, long offset_colors, long offset_lines, long x, long y, long z, int style)
{ {
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++) { if (style) 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); 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_color (0.5f, 0.5f, 0.5f);
graphics_write_color (0.5f, 0.5f, 0.5f);
graphics_write_color (0.5f, 0.5f, 0.5f);
graphics_write_color (0.5f, 0.5f, 0.5f);
} }
/* for (i = 0; i < x; i ++) { */ if (style) for (i = 0; i < x; i ++) {
/* graphics_write_line (offset_vertex + i * 4 + 0, offset_vertex + i * 4 + 1); */ 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 + 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 + 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 + 3, offset_vertex + i * 4 + 0);
/* } */ }
offset_vertex += (x - 1) * 4; if (style) offset_vertex += (x - 1) * 4;
if (style) offset_colors += (x - 1) * 4;
for (i = 1; i < y; i++) { for (i = 1; i < y; i++) {
@ -78,17 +84,24 @@ void write_space_faces_grids (long offset_vertex, long offset_lines, long x, lon
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); graphics_write_vertex ( x / max, (2 * i / y - 1) * y / max, - z / max);
graphics_write_color (0.5f, 0.5f, 0.5f);
graphics_write_color (0.5f, 0.5f, 0.5f);
graphics_write_color (0.5f, 0.5f, 0.5f);
graphics_write_color (0.5f, 0.5f, 0.5f);
} }
for (i = 0; i < y - 1; i ++) { for (i = 0; i < y - 1; i ++) {
/* graphics_write_line (offset_vertex + i * 4 + 0, offset_vertex + i * 4 + 1); */ if (style)
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 + 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 + 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 + 3, offset_vertex + i * 4 + 0);
} }
offset_vertex += (y - 1) * 4; offset_vertex += (y - 2) * 4;
offset_colors += (y - 2) * 4;
for (i = 1; i < z; i++) { for (i = 1; i < z; i++) {
@ -96,13 +109,19 @@ void write_space_faces_grids (long offset_vertex, long offset_lines, long x, lon
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); graphics_write_vertex ( x / max, - y / max, (2 * i / z - 1) * z / max);
graphics_write_color (0.5f, 0.5f, 0.5f);
graphics_write_color (0.5f, 0.5f, 0.5f);
graphics_write_color (0.5f, 0.5f, 0.5f);
graphics_write_color (0.5f, 0.5f, 0.5f);
} }
for (i = 0; i <= z; i ++) { for (i = 0; i <= z; i ++) {
graphics_write_line (offset_vertex + i * 4 + 0, offset_vertex + i * 4 + 1); 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 + 1, offset_vertex + i * 4 + 2);
/* graphics_write_line (offset_vertex + i * 4 + 2, offset_vertex + i * 4 + 3); */ if (style)
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 + 3, offset_vertex + i * 4 + 0);
} }
} }