WIP: petits nettoyages is OK (j'hésite avant de tout vérifier...)
This commit is contained in:
parent
3f59e99ba1
commit
0596190f06
|
@ -355,6 +355,8 @@ static bool compute_arrow_3D(int space_size_x,
|
||||||
bool pref_lines_planes_or_mix,
|
bool pref_lines_planes_or_mix,
|
||||||
int vgap, int cgap, int lgap, int pgap,
|
int vgap, int cgap, int lgap, int pgap,
|
||||||
int weight, int site, int x, int y, int z)
|
int weight, int site, int x, int y, int z)
|
||||||
|
|
||||||
|
/* 1 flèche 3D > vgap += 15; igap += 16; cgap += 15; ++model_arrows_nb; */
|
||||||
{
|
{
|
||||||
float zero = 0.0f;
|
float zero = 0.0f;
|
||||||
float center = (1.0f / space_size_x) * (2 * x - space_size_x + 2);
|
float center = (1.0f / space_size_x) * (2 * x - space_size_x + 2);
|
||||||
|
@ -471,9 +473,9 @@ bool compute_space_and_arrows(int model_space_size_x,
|
||||||
if (A) for (int i = 0; i < model_arrows_nb; i++) {
|
if (A) for (int i = 0; i < model_arrows_nb; i++) {
|
||||||
printf("[%d] = %2d, %2d, %2d\n",\
|
printf("[%d] = %2d, %2d, %2d\n",\
|
||||||
i, *(arrows + i * 3), *(arrows + i * 3 + 1), *(arrows + i * 3 + 2));
|
i, *(arrows + i * 3), *(arrows + i * 3 + 1), *(arrows + i * 3 + 2));
|
||||||
}
|
/* } */
|
||||||
{ // ... on verra demain ...
|
/* { // ... on verra demain ... */
|
||||||
int i = 0;
|
/* int i = 0; */
|
||||||
|
|
||||||
compute_arrow_2D(model_space_size_x,
|
compute_arrow_2D(model_space_size_x,
|
||||||
vertex_base, color_base,
|
vertex_base, color_base,
|
||||||
|
|
|
@ -45,13 +45,35 @@
|
||||||
#define FRAG_SHADER_FILE "src/shaders/shader.frag"
|
#define FRAG_SHADER_FILE "src/shaders/shader.frag"
|
||||||
#define K 0
|
#define K 0
|
||||||
|
|
||||||
GLfloat *vertex_base = NULL;
|
/* ----------------- V A R I A B L E S G L O B A L E S ------------------ */
|
||||||
GLfloat *color_base = NULL;
|
|
||||||
|
// int model_dim; < INUTILE : dim est fonction de model_space_size_x, y ,z) */
|
||||||
|
int model_space_size_x = 0;
|
||||||
|
int model_space_size_y = 0;
|
||||||
|
int model_space_size_z = 0;
|
||||||
|
int model_arrows_nb = 0;
|
||||||
|
|
||||||
|
GLfloat *vertex_origin = NULL;
|
||||||
|
GLfloat *color_origin = NULL;
|
||||||
GLubyte *line_origin = NULL;
|
GLubyte *line_origin = NULL;
|
||||||
GLubyte *plan_origin = NULL;
|
GLubyte *plan_origin = NULL;
|
||||||
// GLubyte *arrows = NULL;
|
GLubyte arrows[] = { 1, 1, 0, 1, 2, 1, 1, 1, 4, 1, 2, 5, 1, 1, 8, 1, 2, 9 };
|
||||||
|
// arrows[] = { 1, 1, 0, 1, 2, 1, 1, 1, 10, 1, 2, 11, 1, 1, 20, 1, 2, 21 };
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
bool pref_3D_xor_2D_space = 0; // default view == 0 == 3D
|
||||||
|
bool pref_3D_xor_2D_arrows = 0; // default view == 0 == 3D
|
||||||
|
bool pref_style_mix_lines_planes = 0; // arrows as lines = 0, as planes = 1
|
||||||
|
bool pref_mark_unit_space_first = 0; // default == 0 == no mark
|
||||||
|
bool pref_mark_unit_space_last = 0; // default == 0 == no mark
|
||||||
|
bool pref_background_color = 0; // don't know yet...
|
||||||
|
|
||||||
|
int buffer_vertex_size = 0;
|
||||||
|
int buffer_colors_size = 0;
|
||||||
|
int buffer_lines_size = 0; // previously in graphics.h struct gl_area_entry.GLuint line_indices_nb;
|
||||||
|
int buffer_plans_size = 0; // previously in graphics.h struct gl_area_entry.GLuint plan_indices_nb;
|
||||||
|
|
||||||
|
|
||||||
|
/* ----------------- O P E N G L D E B U G M E S S A G E S ------------ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Prints verbose human-readable debug messages
|
* Prints verbose human-readable debug messages
|
||||||
|
@ -259,8 +281,8 @@ bool graphics_shutdown(const void *gl_area)
|
||||||
(gl_area_size())
|
(gl_area_size())
|
||||||
* sizeof(struct gl_area_entry *));
|
* sizeof(struct gl_area_entry *));
|
||||||
|
|
||||||
g_free(vertex_base);
|
g_free(vertex_origin);
|
||||||
g_free(color_base);
|
g_free(color_origin);
|
||||||
g_free(line_origin);
|
g_free(line_origin);
|
||||||
g_free(plan_origin);
|
g_free(plan_origin);
|
||||||
return true;
|
return true;
|
||||||
|
@ -484,47 +506,23 @@ bool graphics_init_shaders(const void *gl_area)
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
// int model_dim; < INUTILE : dim est fonction de model_space_size_x, y ,z) */
|
|
||||||
int model_space_size_x = 0;
|
|
||||||
int model_space_size_y = 0;
|
|
||||||
int model_space_size_z = 0;
|
|
||||||
int model_arrows_nb = 0;
|
|
||||||
GLubyte // arrows[] = { 1, 1, 0, 1, 2, 1, 1, 1, 10, 1, 2, 11, 1, 1, 20, 1, 2, 21 }; // GLubyte ?
|
|
||||||
arrows[] = { 1, 1, 0, 1, 2, 1, 1, 1, 3, 1, 2, 4, 1, 1, 6, 1, 2, 7 };
|
|
||||||
|
|
||||||
|
|
||||||
bool pref_3D_xor_2D_space = 0; // default view == 0 == 3D
|
|
||||||
bool pref_3D_xor_2D_arrows = 0; // default view == 0 == 3D
|
|
||||||
bool pref_lines_planes_or_mix = 0; // arrows as lines = 0, as planes = 1
|
|
||||||
bool pref_mark_unit_space_first = 0; // default == 0 == no mark
|
|
||||||
bool pref_mark_unit_space_last = 0; // default == 0 == no mark
|
|
||||||
bool pref_background_color = 0; // don't know yet...
|
|
||||||
|
|
||||||
int buffer_vertex_size = 0;
|
|
||||||
int buffer_colors_size = 0;
|
|
||||||
int buffer_lines_size = 0; // previously in graphics.h struct gl_area_entry.GLuint line_indices_nb;
|
|
||||||
int buffer_plans_size = 0; // previously in graphics.h struct gl_area_entry.GLuint plan_indices_nb;
|
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
// TODO Tester (presque) toutes les combinaisons possibles de ces variables !!!
|
// TODO Tester (presque) toutes les combinaisons possibles de ces variables !!!
|
||||||
// NB mark_unit_space_first & last m'auront surtout servi à debuguer.
|
// NB mark_unit_space_first & last m'auront surtout servi à debuguer.
|
||||||
// si inutiles, pourraient être oubliées ?...
|
// si inutiles, pourraient être oubliées ?...
|
||||||
|
|
||||||
static void get_model_data_and_user_preferences(){
|
static void get_model_data_and_user_preferences(){
|
||||||
// The model data (arrows) to use (from model.xml)
|
// The model data (arrows) to use (from model.xml)
|
||||||
// int *arrows = { 1, 1, 0, 1, 2, 1, 1, 1, 10, 1, 2, 11, 1, 1, 20, 1, 2, 21 };
|
|
||||||
|
|
||||||
model_space_size_x = 12; // 2 < model_space_size_x < 32
|
model_space_size_x = 10; // 2 < model_space_size_x < 32
|
||||||
model_arrows_nb = 6; // assert : leur emplacement est contraint par
|
model_arrows_nb = 6; // assert : leur emplacement est contraint par
|
||||||
// model_space_size_x, y, z et le nombre de sites
|
// model_space_size_x, y, z et le nombre de sites
|
||||||
|
|
||||||
pref_3D_xor_2D_space = 0; // default == 0 == 3D
|
pref_3D_xor_2D_space = 0; // default == 0 == 3D
|
||||||
pref_3D_xor_2D_arrows = 0; // default == 0 == 3D
|
pref_3D_xor_2D_arrows = 1; // default == 0 == 3D
|
||||||
pref_mark_unit_space_first = 0; // default == 0 == no mark
|
pref_mark_unit_space_first = 0; // default == 0 == no mark
|
||||||
pref_mark_unit_space_last = 1; // default == 0 == no mark
|
pref_mark_unit_space_last = 1; // default == 0 == no mark
|
||||||
pref_background_color = 0; // TODO
|
pref_background_color = 0; // TODO
|
||||||
pref_lines_planes_or_mix = 1; // arrows as lines = 0, as planes = 1
|
pref_style_mix_lines_planes = 0;// arrows as lines = 0, as planes = 1 TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
static void compute_buffers_sizes(int model_space_size_x,
|
static void compute_buffers_sizes(int model_space_size_x,
|
||||||
|
@ -533,7 +531,7 @@ static void compute_buffers_sizes(int model_space_size_x,
|
||||||
int model_arrows_nb,
|
int model_arrows_nb,
|
||||||
bool pref_3D_xor_2D_space,
|
bool pref_3D_xor_2D_space,
|
||||||
bool pref_3D_xor_2D_arrows,
|
bool pref_3D_xor_2D_arrows,
|
||||||
bool pref_lines_planes_or_mix,
|
bool pref_style_mix_lines_planes,
|
||||||
bool pref_mark_unit_space_first,
|
bool pref_mark_unit_space_first,
|
||||||
bool pref_mark_unit_space_last)
|
bool pref_mark_unit_space_last)
|
||||||
{
|
{
|
||||||
|
@ -555,48 +553,16 @@ static void compute_buffers_sizes(int model_space_size_x,
|
||||||
if (pref_mark_unit_space_last) buffer_lines_size += 4; // 2 diagonal lines
|
if (pref_mark_unit_space_last) buffer_lines_size += 4; // 2 diagonal lines
|
||||||
|
|
||||||
|
|
||||||
/* if (pref_3D_xor_2D_space) for (int k = 0; k < model_space_size_x; k++) { // 2D */
|
buffer_plans_size = 0; // fonction de : model_space_size_x, model_arrows_nb
|
||||||
/* assert(k * 6 < buffer_vertex_size); assert(k * 6 + 5 < buffer_vertex_size); */
|
|
||||||
/* assert(k * 6 < buffer_colors_size); assert(k * 6 + 5 < buffer_colors_size); */
|
|
||||||
/* assert(k + 4 < buffer_lines_size); assert(k + 8 < buffer_lines_size); // TODO check this line ! */
|
|
||||||
/* } else for (int k = 0; k < model_space_size_x; k++) { // 3D */
|
|
||||||
/* assert(k * 12 < buffer_vertex_size); assert(k * 12 + 11 < buffer_vertex_size); */
|
|
||||||
/* assert(k * 12 < buffer_colors_size); assert(k * 12 + 11 < buffer_colors_size); */
|
|
||||||
/* assert(k + 8 < buffer_lines_size); assert(k + 16 < buffer_lines_size); // TODO check this line ! */
|
|
||||||
/* } */
|
|
||||||
|
|
||||||
/* 1 flèche 3D > vgap += 15; igap += 16; cgap += 15; ++model_arrows_nb; */
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
buffer_plans_size = 8; // (4 + model_space_size_x * 4) + (model_arrows_nb * 8) + 2;
|
|
||||||
|
|
||||||
/* buffer_lines_ndx = buffer_lines_size * 2; */
|
|
||||||
/* buffer_plans_ndx = buffer_plans_size * 3; */
|
|
||||||
|
|
||||||
buffer_colors_size = (model_space_size_x + 1) * 12 + model_arrows_nb * 0; // TODO
|
buffer_colors_size = (model_space_size_x + 1) * 12 + model_arrows_nb * 0; // TODO
|
||||||
|
|
||||||
// assert(model_space_size_x * 6 < buffer_vertex_size); assert(model_space_size_x * 6 + 5 < buffer_vertex_size);
|
// assert(model_space_size_x * 6 < buffer_vertex_size); assert(model_space_size_x * 6 + 5 < buffer_vertex_size);
|
||||||
|
/* buffer_lines_ndx = buffer_lines_size * 2; */
|
||||||
printf("Initialization of buffers with %u vertices, %u colors, %u lines, %u plans. model_space_size_x = %d\n",
|
/* buffer_plans_ndx = buffer_plans_size * 3; */
|
||||||
|
printf("graphics.c.compute_buffers_sizes %u vertices, %u colors, %u lines, %u plans. model_space_size_x = %d\n",
|
||||||
buffer_vertex_size, buffer_colors_size, buffer_lines_size, buffer_plans_size, model_space_size_x);
|
buffer_vertex_size, buffer_colors_size, buffer_lines_size, buffer_plans_size, model_space_size_x);
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------- SCORIES ------------------------------------------------
|
|
||||||
/* int vgap = 0, cgap = 0, igap = 0; */
|
|
||||||
|
|
||||||
/* vgap += (6 * model_space_size_x); */
|
|
||||||
/* cgap += (6 * model_space_size_x); */
|
|
||||||
/* igap += model_space_size_x * 2; */
|
|
||||||
|
|
||||||
/* if (pref_mark_unit_space_first) igap += 4; // 4 vertices for 2 diagonal lines */
|
|
||||||
/* if (pref_mark_unit_space_last) igap += 4; // 4 vertices for 2 diagonal lines */
|
|
||||||
|
|
||||||
/* assert(vgap < buffer_vertex_size); assert(vgap + 9 < buffer_vertex_size); */
|
|
||||||
/* assert(igap < buffer_lines_size); */
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Initializes the buffer of a gl_area
|
/* Initializes the buffer of a gl_area
|
||||||
|
@ -620,17 +586,17 @@ void graphics_init_buffers(const void *gl_area)
|
||||||
model_arrows_nb,
|
model_arrows_nb,
|
||||||
pref_3D_xor_2D_space,
|
pref_3D_xor_2D_space,
|
||||||
pref_3D_xor_2D_arrows,
|
pref_3D_xor_2D_arrows,
|
||||||
pref_lines_planes_or_mix,
|
pref_style_mix_lines_planes,
|
||||||
pref_mark_unit_space_first,
|
pref_mark_unit_space_first,
|
||||||
pref_mark_unit_space_last);
|
pref_mark_unit_space_last);
|
||||||
|
|
||||||
vertex_base = g_malloc0(buffer_vertex_size * sizeof(GLfloat) * 2);
|
vertex_origin = g_malloc0(buffer_vertex_size * sizeof(GLfloat) * 2);
|
||||||
color_base = g_malloc0(buffer_colors_size * sizeof(GLfloat) * 2);
|
color_origin = g_malloc0(buffer_colors_size * sizeof(GLfloat) * 2);
|
||||||
line_origin = g_malloc0(buffer_lines_size * 2 * sizeof(GLubyte) * 2);
|
line_origin = g_malloc0(buffer_lines_size * 2 * sizeof(GLubyte) * 2);
|
||||||
plan_origin = g_malloc0(buffer_plans_size * 3 * sizeof(GLubyte) * 2);
|
plan_origin = g_malloc0(buffer_plans_size * 3 * sizeof(GLubyte) * 2);
|
||||||
|
|
||||||
compute_space_and_arrows (model_space_size_x,
|
compute_space_and_arrows (model_space_size_x,
|
||||||
vertex_base, color_base,
|
vertex_origin, color_origin,
|
||||||
line_origin, plan_origin,
|
line_origin, plan_origin,
|
||||||
arrows, model_arrows_nb,
|
arrows, model_arrows_nb,
|
||||||
buffer_vertex_size,
|
buffer_vertex_size,
|
||||||
|
@ -638,7 +604,7 @@ void graphics_init_buffers(const void *gl_area)
|
||||||
buffer_lines_size,
|
buffer_lines_size,
|
||||||
buffer_plans_size,
|
buffer_plans_size,
|
||||||
pref_3D_xor_2D_space,
|
pref_3D_xor_2D_space,
|
||||||
pref_lines_planes_or_mix,
|
pref_style_mix_lines_planes,
|
||||||
pref_mark_unit_space_first,
|
pref_mark_unit_space_first,
|
||||||
pref_mark_unit_space_last);
|
pref_mark_unit_space_last);
|
||||||
|
|
||||||
|
@ -646,14 +612,14 @@ void graphics_init_buffers(const void *gl_area)
|
||||||
|
|
||||||
glGenBuffers(1, &vertex_buffer);
|
glGenBuffers(1, &vertex_buffer);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer);
|
glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer);
|
||||||
glBufferData(GL_ARRAY_BUFFER, buffer_vertex_size * sizeof(vertex_base[0]), vertex_base, GL_STATIC_DRAW);
|
glBufferData(GL_ARRAY_BUFFER, buffer_vertex_size * sizeof(vertex_origin[0]), vertex_origin, GL_STATIC_DRAW);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
|
|
||||||
|
|
||||||
// colors
|
// colors
|
||||||
glGenBuffers(1, &color_buffer);
|
glGenBuffers(1, &color_buffer);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, color_buffer);
|
glBindBuffer(GL_ARRAY_BUFFER, color_buffer);
|
||||||
glBufferData(GL_ARRAY_BUFFER, buffer_colors_size * sizeof(color_base), color_base, GL_STATIC_DRAW);
|
glBufferData(GL_ARRAY_BUFFER, buffer_colors_size * sizeof(color_origin), color_origin, GL_STATIC_DRAW);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
|
|
||||||
// We only use one VAO, so we always keep it bound
|
// We only use one VAO, so we always keep it bound
|
||||||
|
|
Loading…
Reference in New Issue