WIP: un p'tit coup d'espace 3D (sans les flèches)

This commit is contained in:
Jean Sirmai 2023-06-15 20:48:40 +02:00
parent a0cce217b2
commit e9d45b3e88
Signed by: jean
GPG Key ID: FB3115C340E057E3
5 changed files with 291 additions and 155 deletions

View File

@ -3,8 +3,6 @@
*
* Desc: OpenGL utils header
*
* Copyright (C) 2023 Arthur Menges <arthur.menges@a-lec.org>
* Copyright (C) 2023 Adrien Bourmault <neox@a-lec.org>
* Copyright (C) 2023 Jean Sirmai <jean@a-lec.org>
*
* This file is part of Gem-graph.

View File

@ -3,8 +3,6 @@
*
* Desc: OpenGL utils header
*
* Copyright (C) 2023 Arthur Menges <arthur.menges@a-lec.org>
* Copyright (C) 2023 Adrien Bourmault <neox@a-lec.org>
* Copyright (C) 2023 Jean Sirmai <jean@a-lec.org>
*
* This file is part of Gem-graph.

26
include/space_3D.h Normal file
View File

@ -0,0 +1,26 @@
/*
* Gem-graph OpenGL experiments
*
* Desc: GL functions
*
* Copyright (C) 2023 Jean Sirmai <jean@a-lec.org>
*
* 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 <http://www.gnu.org/licenses/>.
*/
bool compute_space_3D(int state_size,
GLfloat *vertex_base, GLfloat *color_base,
GLubyte *line_ndx, int ad_hoc_diag);

View File

@ -40,6 +40,7 @@
#include "../../include/ui.h"
#include "../../include/graphics_control.h"
#include "../../include/space_2D.h"
#include "../../include/space_3D.h"
#include "../../include/arrow_2D.h"
#define VERTEX_SHADER_FILE "src/shaders/shader.vert"
@ -546,48 +547,6 @@ bool graphics_init_shaders(const void *gl_area)
return true;
}
/* #define A 0 */
/* static bool compute_arrow_2D(int state_size, int vgap, int igap, int cgap, int weight, int site, int x, int y, int z){ */
/* float zero = 0.0f; */
/* float center = (1.0f / state_size) * (2 * x - state_size + 2); */
/* float tip = center + (2 * site - 1) * (1.0f / state_size); */
/* float base = center + (2 * site - 1) * (0.1f / state_size); */
/* printf("compute_arrow_2D vgap = %d vertex_nb = %d\n", vgap, vertex_nb); */
/* *(vertex_base + vgap + 0) = center + (2 * site - 1) * (1.0f / state_size - 0.01f); */
/* *(vertex_base + vgap + 1) = zero; */
/* *(vertex_base + vgap + 2) = zero; */
/* *(vertex_base + vgap + 3) = base; */
/* *(vertex_base + vgap + 4) = 0.4f / state_size; */
/* *(vertex_base + vgap + 5) = zero; */
/* *(vertex_base + vgap + 6) = base; */
/* *(vertex_base + vgap + 7) = - 0.4f / state_size; */
/* *(vertex_base + vgap + 8) = zero; */
/* if (A) printf("x = %d site = %d center = %f tip = %f base = %f\n",\ */
/* x, site, center, tip, base); // vgap=%d igap=%d */
/* *(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; */
/* } */
#define A 0
static bool compute_arrow_3D(struct gl_area_entry *entry, int state_size, int vgap, int igap, int weight, int site, int x, int y, int z){
@ -655,61 +614,61 @@ static bool compute_arrow_3D(struct gl_area_entry *entry, int state_size, int vg
return 1;
}
#define V 1
#define I 0
#define EDGE 0.999999
/* #define V 1 */
/* #define I 0 */
/* #define EDGE 0.999999 */
static bool compute_space_3D(struct gl_area_entry *entry, int state_size){
/* static bool compute_space_3D(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)
/* 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("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);
/* if (V) printf("[%1.1f] ", x); */
assert(k * 12 < vertex_nb);
assert(k * 12 + 11 < vertex_nb);
assert(k * 12 < colors_nb);
assert(k * 12 + 11 < colors_nb);
/* assert(k * 12 < vertex_nb); */
/* assert(k * 12 + 11 < vertex_nb); */
/* assert(k * 12 < colors_nb); */
/* assert(k * 12 + 11 < colors_nb); */
*(vertex_base + k * 12 + 0) = - x;
*(vertex_base + k * 12 + 1) = 1.0f / state_size;
*(vertex_base + k * 12 + 2) = 1.0f / state_size;
/* *(vertex_base + k * 12 + 0) = - x; */
/* *(vertex_base + k * 12 + 1) = 1.0f / state_size; */
/* *(vertex_base + k * 12 + 2) = 1.0f / state_size; */
*(vertex_base + k * 12 + 3) = - x;
*(vertex_base + k * 12 + 4) = - 1.0f / state_size;
*(vertex_base + k * 12 + 5) = - 1.0f / state_size;
/* *(vertex_base + k * 12 + 3) = - x; */
/* *(vertex_base + k * 12 + 4) = - 1.0f / state_size; */
/* *(vertex_base + k * 12 + 5) = - 1.0f / state_size; */
*(vertex_base + k * 12 + 6) = - x;
*(vertex_base + k * 12 + 7) = 1.0f / state_size;
*(vertex_base + k * 12 + 8) = - 1.0f / state_size;
/* *(vertex_base + k * 12 + 6) = - x; */
/* *(vertex_base + k * 12 + 7) = 1.0f / state_size; */
/* *(vertex_base + k * 12 + 8) = - 1.0f / state_size; */
*(vertex_base + k * 12 + 9) = - x;
*(vertex_base + k * 12 + 10) = - 1.0f / state_size;
*(vertex_base + k * 12 + 11) = 1.0f / state_size;
/* *(vertex_base + k * 12 + 9) = - x; */
/* *(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;
*(color_base + k * 12 + 1) = 0.8f;
*(color_base + k * 12 + 2) = 0.8f;
/* *(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;
*(color_base + k * 12 + 4) = 0.8f;
*(color_base + k * 12 + 5) = 0.8f;
/* *(color_base + k * 12 + 3) = 0.8f; */
/* *(color_base + k * 12 + 4) = 0.8f; */
/* *(color_base + k * 12 + 5) = 0.8f; */
*(color_base + k * 12 + 6) = 0.8f;
*(color_base + k * 12 + 7) = 0.8f;
*(color_base + k * 12 + 8) = 0.8f;
/* *(color_base + k * 12 + 6) = 0.8f; */
/* *(color_base + k * 12 + 7) = 0.8f; */
/* *(color_base + k * 12 + 8) = 0.8f; */
*(color_base + k * 12 + 9) = 0.8f;
*(color_base + k * 12 + 10) = 0.8f;
*(color_base + k * 12 + 11) = 0.8f;
/* *(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 */
/* 0.8, 0.8, 0.2, // jaune */
@ -720,68 +679,68 @@ static bool compute_space_3D(struct gl_area_entry *entry, int state_size){
/* 0.2, 0.8, 0.2, // vert */
/* 0.8, 0.2, 0.8, // magenta */
}
/* } */
if (V) printf(" n = %d x 2 côté = [%1.1f]\n", state_size + 1, 2.0f / state_size);
/* if (V) printf(" n = %d x 2 côté = [%1.1f]\n", state_size + 1, 2.0f / state_size); */
*(line_ndx + 4) = 0;
*(line_ndx + 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 */
*(line_ndx + 6) = 1;
*(line_ndx + 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 */
*(line_ndx + 0) = 2;
*(line_ndx + 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
/* *(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 + 0) = 0; */
/* *(plan_ndx + 1) = 1; */
/* *(plan_ndx + 2) = 2; */
*(plan_ndx + 3) = 0;
*(plan_ndx + 4) = 1;
*(plan_ndx + 5) = 3;
/* *(plan_ndx + 3) = 0; */
/* *(plan_ndx + 4) = 1; */
/* *(plan_ndx + 5) = 3; */
for (int k = 8; k <= state_size * 8; k += 8){ // for (int k = 8; k < state_size * 8; k += 8){
/* for (int k = 8; k <= state_size * 8; k += 8){ // for (int k = 8; k < state_size * 8; k += 8){ */
assert(k < entry->line_indices_nb);
assert(k + 8 < entry->line_indices_nb);
/* assert(k < entry->line_indices_nb); */
/* assert(k + 8 < entry->line_indices_nb); */
*(line_ndx + k + 0) = k / 2 - 4; // + 0;
*(line_ndx + k + 1) = k / 2 - 2; // + 2;
/* *(line_ndx + k + 0) = k / 2 - 4; // + 0; */
/* *(line_ndx + k + 1) = k / 2 - 2; // + 2; */
*(line_ndx + k + 2) = k / 2 - 3; // + 1;
*(line_ndx + k + 3) = k / 2 - 1; // + 3;
/* *(line_ndx + k + 2) = k / 2 - 3; // + 1; */
/* *(line_ndx + k + 3) = k / 2 - 1; // + 3; */
*(line_ndx + k + 4) = k / 2 - 4; // + 0;
*(line_ndx + k + 5) = k / 2 - 1; // + 3;
/* *(line_ndx + k + 4) = k / 2 - 4; // + 0; */
/* *(line_ndx + k + 5) = k / 2 - 1; // + 3; */
*(line_ndx + k + 6) = k / 2 - 3; // + 1;
*(line_ndx + k + 7) = k / 2 - 2; // + 2;
}
/* *(line_ndx + k + 6) = k / 2 - 3; // + 1; */
/* *(line_ndx + k + 7) = k / 2 - 2; // + 2; */
/* } */
*(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;
/* *(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; */
*(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;
/* *(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("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("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);
/* if (I) printf(" n = 4 + (%d x 2)\n", state_size + 2); */
return 1;
}
/* return 1; */
/* } */
/* Initializes the buffer of a gl_area
* Calls according to the user preferences
@ -807,8 +766,8 @@ 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
lines_nb = (2 + state_size) + (arrows_nb * 3);
// lines_nb = (4 + state_size * 4) + (arrows_nb * 8) + 2; // + 2; pour les 2 diagonales
// lines_nb = (2 + state_size) + (arrows_nb * 3); // cas 2D
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->line_indices_nb = lines_nb * 2;
@ -824,42 +783,48 @@ void graphics_init_buffers(const void *gl_area)
plan_ndx = g_malloc0(plans_nb * 3 * sizeof(GLubyte) * 2);
assert(state_size * 6 < vertex_nb); assert(state_size * 6 + 5 < vertex_nb);
compute_space_2D(state_size, vertex_base, line_ndx);
vgap += (6 * state_size); igap += state_size * 2 + 4; cgap += (6 * state_size);
// compute_space_2D(state_size, vertex_base, line_ndx);
// vgap += (6 * state_size); igap += state_size * 2 + 4; cgap += (6 * state_size);
*(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;
// compute_space_3D(entry, state_size); vgap += (12 * state_size); igap += state_size * 8 + 8; cgap += (12 * state_size);
for (int k = 0; k < state_size; k++){
assert(k * 12 < vertex_nb); assert(k * 12 + 11 < vertex_nb);
assert(k * 12 < colors_nb); assert(k * 12 + 11 < colors_nb);
assert(k + 8 < entry->line_indices_nb); assert(k + 16 < entry->line_indices_nb);
}
compute_space_3D(state_size, vertex_base, color_base, line_ndx, entry->line_indices_nb);
vgap += (12 * state_size); igap += state_size * 8 + 8; cgap += (12 * state_size);
assert(vgap < vertex_nb); assert(vgap + 9 < vertex_nb);
assert(igap < entry->line_indices_nb); assert(igap + 5 < entry->line_indices_nb);
compute_arrow_2D(state_size, vertex_base, color_base,
line_ndx, plan_ndx, vgap, igap, cgap, 1, 0, 0, 0, 0);
// if (A) printf("compute_arrow_2D vgap = %d vertex_nb = %d\n", vgap, vertex_nb);
// if (A) printf("x = %d site = %d center = %f tip = %f base = %f\n",\
// x, site, center, tip, base); // vgap=%d igap=%d
vgap += 9; igap += 6; cgap += 15; ++arrows_nb;
/* assert(vgap < vertex_nb); assert(vgap + 9 < vertex_nb); */
/* assert(igap < entry->line_indices_nb); assert(igap + 5 < entry->line_indices_nb); */
/* compute_arrow_2D(state_size, vertex_base, color_base, */
/* line_ndx, plan_ndx, vgap, igap, cgap, 1, 0, 0, 0, 0); */
/* // if (A) printf("compute_arrow_2D vgap = %d vertex_nb = %d\n", vgap, vertex_nb); */
/* // if (A) printf("x = %d site = %d center = %f tip = %f base = %f\n",\ */
/* // x, site, center, tip, base); // vgap=%d igap=%d */
/* vgap += 9; igap += 6; cgap += 15; ++arrows_nb; */
assert(vgap < vertex_nb); assert(vgap + 9 < vertex_nb);
assert(igap < entry->line_indices_nb); assert(igap + 5 < entry->line_indices_nb);
compute_arrow_2D(state_size, vertex_base, color_base,
line_ndx, plan_ndx, vgap, igap, cgap, 1, 1, 2, 0, 0);
vgap += 9; igap += 6; cgap += 15; ++arrows_nb;
/* assert(vgap < vertex_nb); assert(vgap + 9 < vertex_nb); */
/* assert(igap < entry->line_indices_nb); assert(igap + 5 < entry->line_indices_nb); */
/* compute_arrow_2D(state_size, vertex_base, color_base, */
/* line_ndx, plan_ndx, vgap, igap, cgap, 1, 1, 2, 0, 0); */
/* vgap += 9; igap += 6; cgap += 15; ++arrows_nb; */
assert(vgap < vertex_nb); assert(vgap + 9 < vertex_nb);
assert(igap < entry->line_indices_nb); assert(igap + 5 < entry->line_indices_nb);
compute_arrow_2D(state_size, vertex_base, color_base,
line_ndx, plan_ndx, vgap, igap, cgap, 1, 0, 3, 0, 0);
vgap += 9; igap += 6; cgap += 15; ++arrows_nb;
/* assert(vgap < vertex_nb); assert(vgap + 9 < vertex_nb); */
/* assert(igap < entry->line_indices_nb); assert(igap + 5 < entry->line_indices_nb); */
/* compute_arrow_2D(state_size, vertex_base, color_base, */
/* line_ndx, plan_ndx, vgap, igap, cgap, 1, 0, 3, 0, 0); */
/* vgap += 9; igap += 6; cgap += 15; ++arrows_nb; */
assert(vgap < vertex_nb); assert(vgap + 9 < vertex_nb);
assert(igap < entry->line_indices_nb); assert(igap + 5 < entry->line_indices_nb);
compute_arrow_2D(state_size, vertex_base, color_base,
line_ndx, plan_ndx, vgap, igap, cgap, 1, 1, state_size - 2, 0, 0);
vgap += 9; igap += 6; cgap += 15; ++arrows_nb;
/* assert(vgap < vertex_nb); assert(vgap + 9 < vertex_nb); */
/* assert(igap < entry->line_indices_nb); assert(igap + 5 < entry->line_indices_nb); */
/* compute_arrow_2D(state_size, vertex_base, color_base, */
/* line_ndx, plan_ndx, vgap, igap, cgap, 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; */

149
src/graphics/space_3D.c Normal file
View File

@ -0,0 +1,149 @@
/*
* Gem-graph OpenGL experiments
*
* Desc: GL functions
*
* Copyright (C) 2023 Jean Sirmai <jean@a-lec.org>
*
* 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 <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <epoxy/gl.h>
#define V 1
#define I 0
#define EDGE 0.999999
bool compute_space_3D(int state_size,
GLfloat *vertex_base, GLfloat *color_base,
GLubyte *line_ndx, int ad_hoc_diag){
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);
*(vertex_base + k * 12 + 0) = - x;
*(vertex_base + k * 12 + 1) = 1.0f / state_size;
*(vertex_base + k * 12 + 2) = 1.0f / state_size;
*(vertex_base + k * 12 + 3) = - x;
*(vertex_base + k * 12 + 4) = - 1.0f / state_size;
*(vertex_base + k * 12 + 5) = - 1.0f / state_size;
*(vertex_base + k * 12 + 6) = - x;
*(vertex_base + k * 12 + 7) = 1.0f / state_size;
*(vertex_base + k * 12 + 8) = - 1.0f / state_size;
*(vertex_base + k * 12 + 9) = - x;
*(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;
*(color_base + k * 12 + 1) = 0.8f;
*(color_base + k * 12 + 2) = 0.8f;
*(color_base + k * 12 + 3) = 0.8f;
*(color_base + k * 12 + 4) = 0.8f;
*(color_base + k * 12 + 5) = 0.8f;
*(color_base + k * 12 + 6) = 0.8f;
*(color_base + k * 12 + 7) = 0.8f;
*(color_base + k * 12 + 8) = 0.8f;
*(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 */
/* 0.8, 0.8, 0.2, // jaune */
/* 0.8, 0.2, 0.2, // rouge */
/* 0.2, 0.2, 0.2, // noir */
/* 0.2, 0.2, 0.2, // gris */
/* 0.2, 0.8, 0.8, // cyan */
/* 0.2, 0.8, 0.2, // vert */
/* 0.8, 0.2, 0.8, // magenta */
}
if (V) printf(" n = %d x 2 côté = [%1.1f]\n", state_size + 1, 2.0f / state_size);
*(line_ndx + 4) = 0;
*(line_ndx + 5) = state_size * 4 - 4; // barre horizontale du bas arr
*(line_ndx + 6) = 1;
*(line_ndx + 7) = state_size * 4 - 3; // barre horizontale du haut arr
*(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; */
for (int k = 8; k <= state_size * 8; k += 8){ // for (int k = 8; k < state_size * 8; k += 8){
*(line_ndx + k + 0) = k / 2 - 4; // + 0;
*(line_ndx + k + 1) = k / 2 - 2; // + 2;
*(line_ndx + k + 2) = k / 2 - 3; // + 1;
*(line_ndx + k + 3) = k / 2 - 1; // + 3;
*(line_ndx + k + 4) = k / 2 - 4; // + 0;
*(line_ndx + k + 5) = k / 2 - 1; // + 3;
*(line_ndx + k + 6) = k / 2 - 3; // + 1;
*(line_ndx + k + 7) = k / 2 - 2; // + 2;
}
*(line_ndx + ad_hoc_diag - 4) = 0 + 0; // diagonales pour marquer la case zéro
*(line_ndx + ad_hoc_diag - 3) = 0 + 1;
*(line_ndx + ad_hoc_diag - 2) = 0 + 2; // diagonales pour marquer la case zéro
*(line_ndx + ad_hoc_diag - 1) = 0 + 3;
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;
}