diff --git a/data/models/dimers_random_walk_recursif.xml b/data/models/dimers_random_walk_recursif.xml new file mode 100644 index 0000000..0bd387c --- /dev/null +++ b/data/models/dimers_random_walk_recursif.xml @@ -0,0 +1,145 @@ + + + + + Test 21-03-2023 + + J + + J + + time_stamp + + 1.0 + + Ref + + + + + 0 + 9 + + + + + + + + + + + + + + + + 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/data/schemas/models_0_recursif.2.1.xmls b/data/schemas/models_0_recursif.2.1.xmls new file mode 100644 index 0000000..3714f41 --- /dev/null +++ b/data/schemas/models_0_recursif.2.1.xmls @@ -0,0 +1,235 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/include/graphics.h b/include/graphics.h index 1a640f6..74e83ec 100644 --- a/include/graphics.h +++ b/include/graphics.h @@ -40,7 +40,8 @@ struct gl_area_entry { GLuint m; GLuint v; GLuint p; - GLuint indices_nb; + GLuint line_indices_nb; + GLuint plan_indices_nb; }; /* diff --git a/include/space_2D.h b/include/space_2D.h new file mode 100644 index 0000000..e1beb83 --- /dev/null +++ b/include/space_2D.h @@ -0,0 +1,31 @@ +/* + * Gem-graph OpenGL experiments + * + * Desc: OpenGL utils header + * + * Copyright (C) 2023 Arthur Menges + * Copyright (C) 2023 Adrien Bourmault + * Copyright (C) 2023 Jean Sirmai + * + * This file is part of Gem-graph. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#pragma once +#include +#include +#include + +// bool compute_space_2D(struct gl_area_entry *entry, int state_size); diff --git a/learnopengl.com * Getting-started * OpenGL b/learnopengl.com * Getting-started * OpenGL new file mode 100644 index 0000000..e69de29 diff --git a/src/graphics/graphics.c b/src/graphics/graphics.c index 2eff4c0..77fea7c 100644 --- a/src/graphics/graphics.c +++ b/src/graphics/graphics.c @@ -38,6 +38,7 @@ #include "../../include/base.h" #include "../../include/ui.h" #include "../../include/graphics.h" +#include "../../include/space_2D.h" #define VERTEX_SHADER_FILE "src/shaders/shader.vert" #define FRAG_SHADER_FILE "src/shaders/shader.frag" @@ -45,12 +46,14 @@ GLfloat *vertex_base = NULL; GLfloat *color_base = NULL; -GLubyte *indices = NULL; +GLubyte *line_ndx = NULL; +GLubyte *plan_ndx = NULL; int dim = 0; int state_size = 0; int vertex_nb = 0; int colors_nb = 0; -int segments_nb = 0; +int lines_nb = 0; +int plans_nb = 0; int arrows_nb = 0; /* -------------------------------------------------------------------------- */ @@ -320,7 +323,8 @@ bool graphics_shutdown(const void *gl_area) g_free(vertex_base); g_free(color_base); - g_free(indices); + g_free(line_ndx); + g_free(plan_ndx); return true; } @@ -568,15 +572,23 @@ static bool compute_arrow_2D(struct gl_area_entry *entry, int state_size, int vg if (A) printf("x = %d site = %d center = %f tip = %f base = %f\n",\ x, site, center, tip, base); // vgap=%d igap=%d - assert(igap < entry->indices_nb); - assert(igap + 5 < entry->indices_nb); + assert(igap < entry->line_indices_nb); + assert(igap + 5 < entry->line_indices_nb); - *(indices + igap + 0) = vgap / 3 + 0; - *(indices + igap + 1) = vgap / 3 + 1; - *(indices + igap + 2) = vgap / 3 + 0; - *(indices + igap + 3) = vgap / 3 + 2; - *(indices + igap + 4) = vgap / 3 + 1; - *(indices + igap + 5) = vgap / 3 + 2; + *(line_ndx + igap + 0) = vgap / 3 + 0; + *(line_ndx + igap + 1) = vgap / 3 + 1; + *(line_ndx + igap + 2) = vgap / 3 + 0; + *(line_ndx + igap + 3) = vgap / 3 + 2; + *(line_ndx + igap + 4) = vgap / 3 + 1; + *(line_ndx + igap + 5) = vgap / 3 + 2; + + *(plan_ndx + 0) = vgap / 3 + 0; + *(plan_ndx + 1) = vgap / 3 + 1; + *(plan_ndx + 2) = vgap / 3 + 2; + + *(plan_ndx + 3) = vgap / 3 + 0; + *(plan_ndx + 4) = vgap / 3 + 1; + *(plan_ndx + 5) = vgap / 3 + 2; return 1; } @@ -616,32 +628,32 @@ static bool compute_arrow_3D(struct gl_area_entry *entry, int state_size, int vg if (A) printf("x = %d site = %d center = %f tip = %f base = %f\n",\ x, site, center, tip, base); // vgap=%d igap=%d - assert(igap < entry->indices_nb); - assert(igap + 5 < entry->indices_nb); + assert(igap < entry->line_indices_nb); + assert(igap + 5 < entry->line_indices_nb); - *(indices + igap + 0) = vgap / 3 + 0; - *(indices + igap + 1) = vgap / 3 + 1; + *(line_ndx + igap + 0) = vgap / 3 + 0; + *(line_ndx + igap + 1) = vgap / 3 + 1; - *(indices + igap + 2) = vgap / 3 + 0; - *(indices + igap + 3) = vgap / 3 + 2; + *(line_ndx + igap + 2) = vgap / 3 + 0; + *(line_ndx + igap + 3) = vgap / 3 + 2; - *(indices + igap + 4) = vgap / 3 + 0; - *(indices + igap + 5) = vgap / 3 + 3; + *(line_ndx + igap + 4) = vgap / 3 + 0; + *(line_ndx + igap + 5) = vgap / 3 + 3; - *(indices + igap + 6) = vgap / 3 + 0; - *(indices + igap + 7) = vgap / 3 + 4; + *(line_ndx + igap + 6) = vgap / 3 + 0; + *(line_ndx + igap + 7) = vgap / 3 + 4; - *(indices + igap + 8) = vgap / 3 + 1; - *(indices + igap + 9) = vgap / 3 + 2; + *(line_ndx + igap + 8) = vgap / 3 + 1; + *(line_ndx + igap + 9) = vgap / 3 + 2; - *(indices + igap + 10) = vgap / 3 + 2; - *(indices + igap + 11) = vgap / 3 + 3; + *(line_ndx + igap + 10) = vgap / 3 + 2; + *(line_ndx + igap + 11) = vgap / 3 + 3; - *(indices + igap + 12) = vgap / 3 + 3; - *(indices + igap + 13) = vgap / 3 + 4; + *(line_ndx + igap + 12) = vgap / 3 + 3; + *(line_ndx + igap + 13) = vgap / 3 + 4; - *(indices + igap + 14) = vgap / 3 + 4; - *(indices + igap + 15) = vgap / 3 + 1; + *(line_ndx + igap + 14) = vgap / 3 + 4; + *(line_ndx + igap + 15) = vgap / 3 + 1; return 1; } @@ -678,28 +690,28 @@ static bool compute_space_2D(struct gl_area_entry *entry, int state_size){ if (V) printf(" n = %d x 2 côté = [%1.1f]\n", state_size + 1, 2.0f / state_size); - *(indices + 0) = 0; - *(indices + 1) = state_size * 2 - 2; // barre horizontale du bas + *(line_ndx + 0) = 0; + *(line_ndx + 1) = state_size * 2 - 2; // barre horizontale du bas - *(indices + 2) = 1; - *(indices + 3) = state_size * 2 - 1; // barre horizontale du haut + *(line_ndx + 2) = 1; + *(line_ndx + 3) = state_size * 2 - 1; // barre horizontale du haut for (int k = 0; k < state_size * 2; k++){ - assert(k < entry->indices_nb); - assert(k + 4 < entry->indices_nb); + assert(k < entry->line_indices_nb); + assert(k + 4 < entry->line_indices_nb); - *(indices + k + 4) = k; + *(line_ndx + k + 4) = k; } - /* *(indices + state_size * 2 + 6 + 4) = 0; // diagonales pour marquer la case zéro */ - /* *(indices + state_size * 2 + 6 + 5) = 3; */ - /* *(indices + state_size * 2 + 6 + 6) = 1; */ - /* *(indices + state_size * 2 + 6 + 7) = 2; */ + /* *(line_ndx + state_size * 2 + 6 + 4) = 0; // diagonales pour marquer la case zéro */ + /* *(line_ndx + state_size * 2 + 6 + 5) = 3; */ + /* *(line_ndx + state_size * 2 + 6 + 6) = 1; */ + /* *(line_ndx + state_size * 2 + 6 + 7) = 2; */ - if (I) printf("indices (%d - state_size(0)) x (%d - state_size(1)) ", 0, 1); + if (I) printf("line_ndx (%d - state_size(0)) x (%d - state_size(1)) ", 0, 1); for (int v = 0; v < state_size + 2; v++) { - if (I) printf("(%d-%d) ", *(indices + v), *(indices + v + 1)); + if (I) printf("(%d-%d) ", *(line_ndx + v), *(line_ndx + v + 1)); } if (I) printf(" n = 4 + (%d x 2)\n", state_size + 2); @@ -743,20 +755,20 @@ static bool compute_space_3D(struct gl_area_entry *entry, int state_size){ *(vertex_base + k * 12 + 10) = - 1.0f / state_size; *(vertex_base + k * 12 + 11) = 1.0f / state_size; - *(color_base + k * 12 + 0) = 0.8f; // rouge - *(color_base + k * 12 + 1) = 0.2f; - *(color_base + k * 12 + 2) = 0.2f; + *(color_base + k * 12 + 0) = 0.8f; + *(color_base + k * 12 + 1) = 0.8f; + *(color_base + k * 12 + 2) = 0.8f; - *(color_base + k * 12 + 3) = 0.8f; // jaune + *(color_base + k * 12 + 3) = 0.8f; *(color_base + k * 12 + 4) = 0.8f; - *(color_base + k * 12 + 5) = 0.2f; + *(color_base + k * 12 + 5) = 0.8f; - *(color_base + k * 12 + 6) = 0.2f; // vert + *(color_base + k * 12 + 6) = 0.8f; *(color_base + k * 12 + 7) = 0.8f; - *(color_base + k * 12 + 8) = 0.2f; + *(color_base + k * 12 + 8) = 0.8f; - *(color_base + k * 12 + 9) = 0.8f; // magenta - *(color_base + k * 12 + 10) = 0.2f; + *(color_base + k * 12 + 9) = 0.8f; + *(color_base + k * 12 + 10) = 0.8f; *(color_base + k * 12 + 11) = 0.8f; /* 0.8, 0.8, 0.8, // blanc */ @@ -772,48 +784,58 @@ static bool compute_space_3D(struct gl_area_entry *entry, int state_size){ if (V) printf(" n = %d x 2 côté = [%1.1f]\n", state_size + 1, 2.0f / state_size); - *(indices + 4) = 0; - *(indices + 5) = state_size * 4 - 4; // barre horizontale du bas arr + *(line_ndx + 4) = 0; + *(line_ndx + 5) = state_size * 4 - 4; // barre horizontale du bas arr - *(indices + 6) = 1; - *(indices + 7) = state_size * 4 - 3; // barre horizontale du haut arr + *(line_ndx + 6) = 1; + *(line_ndx + 7) = state_size * 4 - 3; // barre horizontale du haut arr - *(indices + 0) = 2; - *(indices + 1) = state_size * 4 - 2; // barre horizontale du bas av + *(line_ndx + 0) = 2; + *(line_ndx + 1) = state_size * 4 - 2; // barre horizontale du bas av + + *(line_ndx + 2) = 3; + *(line_ndx + 3) = state_size * 4 - 1; // barre horizontale du haut av + + + *(plan_ndx + 0) = 0; + *(plan_ndx + 1) = 1; + *(plan_ndx + 2) = 2; + + *(plan_ndx + 3) = 0; + *(plan_ndx + 4) = 1; + *(plan_ndx + 5) = 3; - *(indices + 2) = 3; - *(indices + 3) = state_size * 4 - 1; // barre horizontale du haut av for (int k = 8; k <= state_size * 8; k += 8){ // for (int k = 8; k < state_size * 8; k += 8){ - assert(k < entry->indices_nb); - assert(k + 8 < entry->indices_nb); + assert(k < entry->line_indices_nb); + assert(k + 8 < entry->line_indices_nb); - *(indices + k + 0) = k / 2 - 4; // + 0; - *(indices + k + 1) = k / 2 - 2; // + 2; + *(line_ndx + k + 0) = k / 2 - 4; // + 0; + *(line_ndx + k + 1) = k / 2 - 2; // + 2; - *(indices + k + 2) = k / 2 - 3; // + 1; - *(indices + k + 3) = k / 2 - 1; // + 3; + *(line_ndx + k + 2) = k / 2 - 3; // + 1; + *(line_ndx + k + 3) = k / 2 - 1; // + 3; - *(indices + k + 4) = k / 2 - 4; // + 0; - *(indices + k + 5) = k / 2 - 1; // + 3; + *(line_ndx + k + 4) = k / 2 - 4; // + 0; + *(line_ndx + k + 5) = k / 2 - 1; // + 3; - *(indices + k + 6) = k / 2 - 3; // + 1; - *(indices + k + 7) = k / 2 - 2; // + 2; + *(line_ndx + k + 6) = k / 2 - 3; // + 1; + *(line_ndx + k + 7) = k / 2 - 2; // + 2; } - *(indices + entry->indices_nb - 4) = 0 + 0; // diagonales pour marquer la case zéro - *(indices + entry->indices_nb - 3) = 0 + 1; + *(line_ndx + entry->line_indices_nb - 4) = 0 + 0; // diagonales pour marquer la case zéro + *(line_ndx + entry->line_indices_nb - 3) = 0 + 1; - *(indices + entry->indices_nb - 2) = 0 + 2; // diagonales pour marquer la case zéro - *(indices + entry->indices_nb - 1) = 0 + 3; + *(line_ndx + entry->line_indices_nb - 2) = 0 + 2; // diagonales pour marquer la case zéro + *(line_ndx + entry->line_indices_nb - 1) = 0 + 3; - if (I) printf("indices (%d - state_size(0)) x (%d - state_size(1)) ", 0, 1); + if (I) printf("line_ndx (%d - state_size(0)) x (%d - state_size(1)) ", 0, 1); for (int v = 0; v < state_size + 2; v++) { - if (I) printf("(%d-%d) ", *(indices + v), *(indices + v + 1)); + if (I) printf("(%d-%d) ", *(line_ndx + v), *(line_ndx + v + 1)); } if (I) printf(" n = 4 + (%d x 2)\n", state_size + 2); @@ -823,7 +845,7 @@ static bool compute_space_3D(struct gl_area_entry *entry, int state_size){ /* Initializes the buffer of a gl_area * @param gl_area, ptr to the gl_area widget - * Note : indices[] is defined in graphics_cube.h + * Note : line_ndx[] is defined in graphics_cube.h * @return void */ @@ -836,7 +858,7 @@ void graphics_init_buffers(const void *gl_area) entry = find_entry_from_ptr(gl_area); - //{1, 1, 0, 1, 2, 1, 1, 1, 10, 1, 2, 11, 1, 1, 20, 1, 2, 21}; +// {1, 1, 0, 1, 2, 1, 1, 1, 10, 1, 2, 11, 1, 1, 20, 1, 2, 21}; dim = 1; state_size = 13; // 2 < state_size < 32 arrows_nb = 4; @@ -844,36 +866,39 @@ void graphics_init_buffers(const void *gl_area) vertex_nb = (state_size + 1) * 6 + arrows_nb * 9; vertex_nb = (state_size + 1) * 12 + arrows_nb * 15; colors_nb = (state_size + 1) * 12 + arrows_nb * 0; // TODO - segments_nb = (2 + state_size) + (arrows_nb * 3); - segments_nb = (4 + state_size * 4) + (arrows_nb * 8) + 2; // + 2; pour les 2 diagonales + lines_nb = (2 + state_size) + (arrows_nb * 3); + lines_nb = (4 + state_size * 4) + (arrows_nb * 8) + 2; // + 2; pour les 2 diagonales + plans_nb = 8; //(4 + state_size * 4) + (arrows_nb * 8) + 2; // bhuingfyunfyuguinlgi svbysbubsyu qvyqytqujtvcttcef - entry->indices_nb = segments_nb * 2; + entry->line_indices_nb = lines_nb * 2; + entry->plan_indices_nb = plans_nb * 3; - printf("Initialization of buffers with %u indices, %u vertices and %u colors & state_size = %d\n", - entry->indices_nb, vertex_nb, colors_nb, state_size); + printf("Initialization of buffers with %u line_ndx, %u vertices and %u colors & state_size = %d\n", + entry->line_indices_nb, vertex_nb, colors_nb, state_size); - //XXX g_malloc +// g_malloc vertex_base = g_malloc0(vertex_nb * sizeof(GLfloat) * 2); color_base = g_malloc0(colors_nb * sizeof(GLfloat) * 2); - indices = g_malloc0(segments_nb * 2 * sizeof(GLubyte) * 2); + line_ndx = g_malloc0(lines_nb * 2 * sizeof(GLubyte) * 2); + plan_ndx = g_malloc0(plans_nb * 3 * sizeof(GLubyte) * 2); -// compute_space_2D(entry, state_size); vgap += (6 * state_size); igap += state_size * 2 + 4; cgap += (6 * state_size); + compute_space_2D(entry, state_size); vgap += (6 * state_size); igap += state_size * 2 + 4; cgap += (6 * state_size); - compute_space_3D(entry, state_size); vgap += (12 * state_size); igap += state_size * 8 + 8; cgap += (12 * state_size); +// compute_space_3D(entry, state_size); vgap += (12 * state_size); igap += state_size * 8 + 8; cgap += (12 * state_size); - /* compute_arrow_2D(entry, state_size, vgap, igap, 1, 1, 2, 0, 0); vgap += 9; igap += 6; cgap += 15; ++arrows_nb; */ - /* compute_arrow_2D(entry, state_size, vgap, igap, 1, 1, 0, 0, 0); vgap += 9; igap += 6; cgap += 15; ++arrows_nb; */ - /* compute_arrow_2D(entry, state_size, vgap, igap, 1, 0, 3, 0, 0); vgap += 9; igap += 6; cgap += 15; ++arrows_nb; */ + compute_arrow_2D(entry, state_size, vgap, igap, 1, 0, 0, 0, 0); vgap += 9; igap += 6; cgap += 15; ++arrows_nb; + compute_arrow_2D(entry, state_size, vgap, igap, 1, 1, 2, 0, 0); vgap += 9; igap += 6; cgap += 15; ++arrows_nb; + compute_arrow_2D(entry, state_size, vgap, igap, 1, 0, 3, 0, 0); vgap += 9; igap += 6; cgap += 15; ++arrows_nb; /* compute_arrow_2D(entry, state_size, vgap, igap, 1, 1, 3, 0, 0); vgap += 9; igap += 6; cgap += 15; ++arrows_nb; */ /* compute_arrow_2D(entry, state_size, vgap, igap, 1, 0, state_size - 2, 0, 0); vgap += 9; igap += 6; cgap += 15; ++arrows_nb; */ - /* compute_arrow_2D(entry, state_size, vgap, igap, 1, 1, state_size - 2, 0, 0); vgap += 9; igap += 6; cgap += 15; ++arrows_nb; */ + compute_arrow_2D(entry, state_size, vgap, igap, 1, 1, state_size - 2, 0, 0); vgap += 9; igap += 6; cgap += 15; ++arrows_nb; - compute_arrow_3D(entry, state_size, vgap, igap, 1, 0, 0, 0, 0); vgap += 15; igap += 16; cgap += 15; ++arrows_nb; - compute_arrow_3D(entry, state_size, vgap, igap, 1, 1, 2, 0, 0); vgap += 15; igap += 16; cgap += 15; ++arrows_nb; - compute_arrow_3D(entry, state_size, vgap, igap, 1, 0, 3, 0, 0); vgap += 15; igap += 16; cgap += 15; ++arrows_nb; - //compute_arrow_3D(entry, state_size, vgap, igap, 1, 1, 3, 0, 0); vgap += 15; igap += 16; cgap += 15; ++arrows_nb; - //compute_arrow_3D(entry, state_size, vgap, igap, 1, 0, state_size - 2, 0, 0); vgap += 15; igap += 16; cgap += 15; ++arrows_nb; - compute_arrow_3D(entry, state_size, vgap, igap, 1, 1, state_size - 2, 0, 0); vgap += 15; igap += 16; cgap += 15; ++arrows_nb; + /* compute_arrow_3D(entry, state_size, vgap, igap, 1, 0, 0, 0, 0); vgap += 15; igap += 16; cgap += 15; ++arrows_nb; */ + /* compute_arrow_3D(entry, state_size, vgap, igap, 1, 1, 2, 0, 0); vgap += 15; igap += 16; cgap += 15; ++arrows_nb; */ + /* compute_arrow_3D(entry, state_size, vgap, igap, 1, 0, 3, 0, 0); vgap += 15; igap += 16; cgap += 15; ++arrows_nb; */ + /* compute_arrow_3D(entry, state_size, vgap, igap, 1, 1, 3, 0, 0); vgap += 15; igap += 16; cgap += 15; ++arrows_nb; */ + /* compute_arrow_3D(entry, state_size, vgap, igap, 1, 0, state_size - 2, 0, 0); vgap += 15; igap += 16; cgap += 15; ++arrows_nb; */ + /* compute_arrow_3D(entry, state_size, vgap, igap, 1, 1, state_size - 2, 0, 0); vgap += 15; igap += 16; cgap += 15; ++arrows_nb; */ // We only use one VAO, so we always keep it bound glGenVertexArrays(1, &vao); @@ -931,7 +956,7 @@ void graphics_draw(const void *gl_area) compute_i(m); compute_i(v); - glClearColor(0, 0, 0, 0); + glClearColor(0.3f, 0, 0, 0.8f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); /* Use our shaders */ @@ -954,7 +979,8 @@ void graphics_draw(const void *gl_area) glEnable(GL_DEPTH_TEST); - glDrawElements(GL_LINES, entry->indices_nb, GL_UNSIGNED_BYTE, indices); + glDrawElements(GL_LINES, entry->line_indices_nb, GL_UNSIGNED_BYTE, line_ndx); + glDrawElements(GL_TRIANGLES, entry->plan_indices_nb, GL_UNSIGNED_BYTE, plan_ndx); /* We finished using the buffers and program */ glDisableVertexAttribArray(0); diff --git a/src/graphics/space_2D.c b/src/graphics/space_2D.c new file mode 100644 index 0000000..3d8b701 --- /dev/null +++ b/src/graphics/space_2D.c @@ -0,0 +1,119 @@ +/* + * Gem-graph OpenGL experiments + * + * Desc: GL functions + * + * Copyright (C) 2023 Arthur Menges + * Copyright (C) 2023 Adrien Bourmault + * Copyright (C) 2023 Jean Sirmai + * + * This file is part of Gem-graph. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "../../include/base.h" +#include "../../include/ui.h" +#include "../../include/graphics.h" + +#define VERTEX_SHADER_FILE "src/shaders/shader.vert" +#define FRAG_SHADER_FILE "src/shaders/shader.frag" +#define K 0 + +/* GLfloat *vertex_base = NULL; */ +/* GLfloat *color_base = NULL; */ +/* GLubyte *line_ndx = NULL; */ +/* GLubyte *plan_ndx = NULL; */ +/* int dim = 0; */ +/* int state_size = 0; */ +/* int vertex_nb = 0; */ +/* int colors_nb = 0; */ +/* int lines_nb = 0; */ +/* int plans_nb = 0; */ +/* int arrows_nb = 0; */ + +/* #define V 1 */ +/* #define I 0 */ +/* #define EDGE 0.999999 */ +/* bool compute_space_2D(struct gl_area_entry *entry, int state_size){ */ + +/* float x = 0; */ +/* // for (int k = 0; k < state_size + 1; k++) <=> + 1 car */ +/* // on passe du nombre de cases = (n) */ +/* // au nombre de séparations entre les cases + les deux bords = (n + 1) */ + +/* if (V) printf("vertices "); */ +/* for (int k = 0; k < state_size; k++){ // barres verticales */ +/* // */ +/* x = ((state_size % 2) * (state_size / 2 - k) */ +/* + (state_size % 2 - 1) * (k + 0.5f - state_size / 2)) / state_size * 2 * EDGE; */ + +/* if (V) printf("[%1.1f] ", x); */ + +/* assert(k * 6 < vertex_nb); */ +/* assert(k * 6 + 5 < vertex_nb); */ + +/* *(vertex_base + k * 6 + 0) = - x; */ +/* *(vertex_base + k * 6 + 1) = 1.0f / state_size; */ +/* *(vertex_base + k * 6 + 2) = 0.0f; */ + +/* *(vertex_base + k * 6 + 3) = - x; */ +/* *(vertex_base + k * 6 + 4) = - 1.0f / state_size; */ +/* *(vertex_base + k * 6 + 5) = 0.0f; */ +/* } */ + +/* if (V) printf(" n = %d x 2 côté = [%1.1f]\n", state_size + 1, 2.0f / state_size); */ + +/* *(line_ndx + 0) = 0; */ +/* *(line_ndx + 1) = state_size * 2 - 2; // barre horizontale du bas */ + +/* *(line_ndx + 2) = 1; */ +/* *(line_ndx + 3) = state_size * 2 - 1; // barre horizontale du haut */ + +/* for (int k = 0; k < state_size * 2; k++){ */ + +/* assert(k < entry->line_indices_nb); */ +/* assert(k + 4 < entry->line_indices_nb); */ + +/* *(line_ndx + k + 4) = k; */ +/* } */ + + /* *(line_ndx + state_size * 2 + 6 + 4) = 0; // diagonales pour marquer la case zéro */ + /* *(line_ndx + state_size * 2 + 6 + 5) = 3; */ + /* *(line_ndx + state_size * 2 + 6 + 6) = 1; */ + /* *(line_ndx + state_size * 2 + 6 + 7) = 2; */ + +/* if (I) printf("line_ndx (%d - state_size(0)) x (%d - state_size(1)) ", 0, 1); */ +/* for (int v = 0; v < state_size + 2; v++) { */ +/* if (I) printf("(%d-%d) ", *(line_ndx + v), *(line_ndx + v + 1)); */ +/* } */ + +/* if (I) printf(" n = 4 + (%d x 2)\n", state_size + 2); */ + +/* return 1; */ +/* } */ + diff --git a/src/shaders/shader.vert b/src/shaders/shader.vert index 588e6fa..39f3f08 100644 --- a/src/shaders/shader.vert +++ b/src/shaders/shader.vert @@ -12,5 +12,5 @@ out vec4 color; void main(void) { gl_Position = projection_matrix * view_matrix * model_matrix * vec4(in_position, 1); - color = vec4(1 * in_color.rgb, 1); + color = vec4(1 * in_color.rgb, 0.2f); } \ No newline at end of file