First one-dimensional representation
Users have choice for display: - arrows are 2D or 3D - space units are 2D or 3D Signed-off-by: Jean Sirmai <jean@a-lec.org>
This commit is contained in:
parent
eaa39dc29f
commit
f32fa02299
|
@ -1,34 +0,0 @@
|
||||||
/*
|
|
||||||
* Gem-graph OpenGL experiments
|
|
||||||
*
|
|
||||||
* Desc: OpenGL utils header
|
|
||||||
*
|
|
||||||
* 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/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <GL/glu.h>
|
|
||||||
|
|
||||||
bool compute_arrow_3D(int state_size,
|
|
||||||
GLfloat *vertex_base, GLfloat *color_base,
|
|
||||||
GLubyte *line_ndx, GLubyte *plan_ndx,
|
|
||||||
int vgap, int igap, int cgap,
|
|
||||||
int weight, int site, int x, int y, int z);
|
|
||||||
|
|
|
@ -26,9 +26,22 @@
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <GL/glu.h>
|
#include <GL/glu.h>
|
||||||
|
|
||||||
bool compute_arrow_2D(int state_size,
|
bool compute_space_and_arrows(int model_space_size_x,
|
||||||
GLfloat *vertex_base, GLfloat *color_base,
|
int model_space_size_y,
|
||||||
GLubyte *line_ndx, GLubyte *plan_ndx,
|
int model_space_size_z,
|
||||||
int vgap, int igap, int cgap,
|
|
||||||
int weight, int site, int x, int y, int z);
|
GLubyte *arrows,
|
||||||
|
int model_arrows_nb,
|
||||||
|
|
||||||
|
int pref_3D_xor_2D_space,
|
||||||
|
int pref_3D_xor_2D_arrows,
|
||||||
|
int pref_mark_unit_space,
|
||||||
|
int pref_style_lines_planes,
|
||||||
|
int pref_style_mix_colors,
|
||||||
|
|
||||||
|
GLfloat *vertex_origin,
|
||||||
|
GLfloat *color_origin,
|
||||||
|
GLubyte *line_origin,
|
||||||
|
GLubyte *plan_origin);
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
*
|
*
|
||||||
* Copyright (C) 2023 Arthur Menges <arthur.menges@a-lec.org>
|
* Copyright (C) 2023 Arthur Menges <arthur.menges@a-lec.org>
|
||||||
* Copyright (C) 2023 Adrien Bourmault <neox@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.
|
* This file is part of Gem-graph.
|
||||||
*
|
*
|
||||||
|
@ -40,8 +41,9 @@ struct gl_area_entry {
|
||||||
GLuint m; // init_shaders, draw
|
GLuint m; // init_shaders, draw
|
||||||
GLuint v; // init_shaders, draw
|
GLuint v; // init_shaders, draw
|
||||||
GLuint p; // init_shaders, draw
|
GLuint p; // init_shaders, draw
|
||||||
GLuint line_indices_nb; // init_buffers, draw, compute_space, arrow_2D, 3D
|
// GLuint line_indices_nb; // now : graphics.c > int buffer_lines_ndx
|
||||||
GLuint plan_indices_nb; // init_buffers, draw, compute_space, arrow_2D, 3D
|
// GLuint plan_indices_nb; // now : graphics.c > int buffer_plans_ndx
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
|
@ -1,44 +0,0 @@
|
||||||
/*
|
|
||||||
* Gem-graph OpenGL experiments
|
|
||||||
*
|
|
||||||
* Desc: OpenGL utils header
|
|
||||||
*
|
|
||||||
* 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/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <GL/glu.h>
|
|
||||||
|
|
||||||
int graphics_compute_lines(int line_indices_nb,
|
|
||||||
GLfloat *vertex_base, GLfloat *color_base,
|
|
||||||
GLubyte *line_ndx, int lines_nb,
|
|
||||||
int dim, int state_size,
|
|
||||||
int vertex_nb,
|
|
||||||
int colors_nb,
|
|
||||||
int arrows_nb);
|
|
||||||
|
|
||||||
int graphics_compute_plans(int plan_indices_nb,
|
|
||||||
GLfloat *vertex_base, GLfloat *color_base,
|
|
||||||
GLubyte *plan_ndx, int plans_nb,
|
|
||||||
int dim, int state_size,
|
|
||||||
int vertex_nb,
|
|
||||||
int colors_nb,
|
|
||||||
int arrows_nb);
|
|
||||||
|
|
|
@ -1,103 +0,0 @@
|
||||||
/*
|
|
||||||
* Gem-graph OpenGL experiments
|
|
||||||
*
|
|
||||||
* Desc: OpenGL utils header
|
|
||||||
*
|
|
||||||
* Copyright (C) 2023 Arthur Menges <arthur.menges@a-lec.org>
|
|
||||||
* Copyright (C) 2023 Adrien Bourmault <neox@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/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
// v5----- v4
|
|
||||||
// /| /|
|
|
||||||
// v1------v0|
|
|
||||||
// | | | |
|
|
||||||
// | |v6---|-|v7
|
|
||||||
// |/ |/
|
|
||||||
// v2------v3
|
|
||||||
//
|
|
||||||
// static GLfloat vertex_base[] = {
|
|
||||||
// 0.5, 0.5, 0.5, // v0
|
|
||||||
// -0.5, 0.5, 0.5, // v1
|
|
||||||
// -0.5,-0.5, 0.5, // v2
|
|
||||||
// 0.5,-0.5, 0.5, // v3
|
|
||||||
// 0.5, 0.5,-0.5, // v4
|
|
||||||
// -0.5, 0.5,-0.5, // v5
|
|
||||||
// -0.5,-0.5,-0.5, // v6
|
|
||||||
// 0.5,-0.5,-0.5, // v7
|
|
||||||
// };
|
|
||||||
static GLfloat vertex_base_ignore[] = {
|
|
||||||
0.5, .0f, .0f, // v0
|
|
||||||
-0.5, .0f, .0f, // v1
|
|
||||||
-0.5,-0.5, .0f, // v2
|
|
||||||
0.5,-0.5, .0f, // v3
|
|
||||||
0.5, .0f,-.0f, // v4
|
|
||||||
-0.5, .0f,-.0f, // v5
|
|
||||||
-0.5,-0.5,-.0f, // v6
|
|
||||||
0.5,-0.5,-.0f, // v7
|
|
||||||
};
|
|
||||||
|
|
||||||
static GLubyte indices_ignore[] = {
|
|
||||||
0,1,
|
|
||||||
1,2,
|
|
||||||
2,3,
|
|
||||||
3,0,
|
|
||||||
|
|
||||||
4,5,
|
|
||||||
5,6,
|
|
||||||
6,7,
|
|
||||||
7,4,
|
|
||||||
|
|
||||||
0,4,
|
|
||||||
1,5,
|
|
||||||
2,6,
|
|
||||||
3,7,
|
|
||||||
|
|
||||||
// 2,4,
|
|
||||||
// 3,5,
|
|
||||||
// 0,6,
|
|
||||||
// 1,7,
|
|
||||||
|
|
||||||
};
|
|
||||||
// v5------v4
|
|
||||||
// /| /|
|
|
||||||
// v1------v0|
|
|
||||||
// | | | |
|
|
||||||
// | v6----|-v7
|
|
||||||
// |/ |/
|
|
||||||
// v2------v3
|
|
||||||
//
|
|
||||||
|
|
||||||
|
|
||||||
static GLfloat color_base[] = {
|
|
||||||
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
|
|
||||||
};
|
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
|
||||||
|
|
|
@ -1,32 +0,0 @@
|
||||||
/*
|
|
||||||
* Gem-graph OpenGL experiments
|
|
||||||
*
|
|
||||||
* Desc: OpenGL utils header
|
|
||||||
*
|
|
||||||
* 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/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <GL/glu.h>
|
|
||||||
|
|
||||||
bool compute_space_2D(int state_size,
|
|
||||||
GLfloat *vertex_base, GLfloat *color_base,
|
|
||||||
GLubyte *line_ndx,
|
|
||||||
bool pref_mark_unit_space_zero, int dgap);
|
|
|
@ -1,32 +0,0 @@
|
||||||
/*
|
|
||||||
* 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/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <GL/glu.h>
|
|
||||||
|
|
||||||
bool compute_space_3D(int state_size,
|
|
||||||
GLfloat *vertex_base, GLfloat *color_base,
|
|
||||||
GLubyte *line_ndx,
|
|
||||||
bool pref_mark_unit_space_zero, int dgap);
|
|
|
@ -1,71 +0,0 @@
|
||||||
/*
|
|
||||||
* 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/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <epoxy/gl.h>
|
|
||||||
//#include <GL/glu.h>
|
|
||||||
|
|
||||||
bool compute_arrow_2D(int state_size,
|
|
||||||
GLfloat *vertex_base, GLfloat *color_base,
|
|
||||||
GLubyte *line_ndx, GLubyte *plan_ndx,
|
|
||||||
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);
|
|
||||||
|
|
||||||
*(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;
|
|
||||||
|
|
||||||
|
|
||||||
*(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;
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,104 +0,0 @@
|
||||||
/*
|
|
||||||
* 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/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <epoxy/gl.h>
|
|
||||||
//#include <GL/glu.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#define A 0
|
|
||||||
bool compute_arrow_3D(int state_size,
|
|
||||||
GLfloat *vertex_base, GLfloat *color_base,
|
|
||||||
GLubyte *line_ndx, GLubyte *plan_ndx,
|
|
||||||
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);
|
|
||||||
|
|
||||||
if (A) printf("compute_arrow_3D vgap = %d\n", vgap);
|
|
||||||
|
|
||||||
*(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) = 0.4f / state_size;
|
|
||||||
|
|
||||||
*(vertex_base + vgap + 6) = base;
|
|
||||||
*(vertex_base + vgap + 7) = 0.4f / state_size;
|
|
||||||
*(vertex_base + vgap + 8) = - 0.4f / state_size;
|
|
||||||
|
|
||||||
*(vertex_base + vgap + 9) = base;
|
|
||||||
*(vertex_base + vgap + 10) = - 0.4f / state_size;
|
|
||||||
*(vertex_base + vgap + 11) = - 0.4f / state_size;
|
|
||||||
|
|
||||||
*(vertex_base + vgap + 12) = base;
|
|
||||||
*(vertex_base + vgap + 13) = - 0.4f / state_size;
|
|
||||||
*(vertex_base + vgap + 14) = 0.4f / state_size;
|
|
||||||
|
|
||||||
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 + 0;
|
|
||||||
*(line_ndx + igap + 5) = vgap / 3 + 3;
|
|
||||||
|
|
||||||
*(line_ndx + igap + 6) = vgap / 3 + 0;
|
|
||||||
*(line_ndx + igap + 7) = vgap / 3 + 4;
|
|
||||||
|
|
||||||
*(line_ndx + igap + 8) = vgap / 3 + 1;
|
|
||||||
*(line_ndx + igap + 9) = vgap / 3 + 2;
|
|
||||||
|
|
||||||
*(line_ndx + igap + 10) = vgap / 3 + 2;
|
|
||||||
*(line_ndx + igap + 11) = vgap / 3 + 3;
|
|
||||||
|
|
||||||
*(line_ndx + igap + 12) = vgap / 3 + 3;
|
|
||||||
*(line_ndx + igap + 13) = vgap / 3 + 4;
|
|
||||||
|
|
||||||
*(line_ndx + igap + 14) = vgap / 3 + 4;
|
|
||||||
*(line_ndx + igap + 15) = vgap / 3 + 1;
|
|
||||||
|
|
||||||
|
|
||||||
*(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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,663 @@
|
||||||
|
/*
|
||||||
|
* Gem-graph OpenGL experiments
|
||||||
|
*
|
||||||
|
* Desc: OpenGL utils header
|
||||||
|
*
|
||||||
|
* Copyright (C) 2023 Jean Sirmai <jean@a-lec.org>
|
||||||
|
* Copyleft (something) ( ;- )) Isn't that fun ?! -------|cbF@^@ââ63-OPM,FJ&_(_((T^RQ491486Jn||lpv)=à)o!
|
||||||
|
* []xgey('"auU~|~`RIO7y89+1/CHR+-/+à&Ç-_'(-_çéy&#
|
||||||
|
* "tà(utgey(91JI2aFIgB[|[~&Ç(=À'7hu0eiCHR+-/+à&Ç-)
|
||||||
|
*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//#pragma once
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <epoxy/gl.h>
|
||||||
|
#include <GL/glu.h>
|
||||||
|
#include <GL/glext.h>
|
||||||
|
#include <glib-2.0/glib.h>
|
||||||
|
#include <math.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
#include "../../include/ui.h"
|
||||||
|
#include "../../include/graphics.h"
|
||||||
|
#include "../../include/buffers.h"
|
||||||
|
|
||||||
|
int vertex_ndx = 0;
|
||||||
|
int colors_ndx = 0;
|
||||||
|
int lines_ndx = 0;
|
||||||
|
int plans_ndx = 0;
|
||||||
|
|
||||||
|
#define EDGE 0.999999
|
||||||
|
|
||||||
|
#define S 0
|
||||||
|
#define S3 0
|
||||||
|
#define SA 1
|
||||||
|
#define A3 0
|
||||||
|
|
||||||
|
#define L 0
|
||||||
|
#define V 0
|
||||||
|
#define C 0
|
||||||
|
#define P 0
|
||||||
|
|
||||||
|
static bool compute_space_2D(int space_size_x,
|
||||||
|
int space_size_y,
|
||||||
|
int space_size_z,
|
||||||
|
|
||||||
|
int pref_mark_unit_space,
|
||||||
|
int pref_style_lines_planes,
|
||||||
|
int pref_style_mix_colors,
|
||||||
|
|
||||||
|
GLfloat *vertex_origin,
|
||||||
|
GLfloat *color_origin,
|
||||||
|
GLubyte *line_origin,
|
||||||
|
GLubyte *plan_origin)
|
||||||
|
{
|
||||||
|
|
||||||
|
float x = 0;
|
||||||
|
// for (int k = 0; k < space_size_x + 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 (S) printf("space_2D vertex ");
|
||||||
|
for (int k = 0; k < space_size_x; k++){ // barres verticales
|
||||||
|
//
|
||||||
|
x = ((space_size_x % 2) * (space_size_x / 2 - k)
|
||||||
|
+ (space_size_x % 2 - 1) * (k + 0.5f - space_size_x / 2)) / space_size_x * 2 * EDGE;
|
||||||
|
|
||||||
|
if (S) printf("[%1.1f] ", x);
|
||||||
|
|
||||||
|
*(vertex_origin + k * 6 + 0) = - x;
|
||||||
|
*(vertex_origin + k * 6 + 1) = 1.0f / space_size_x;
|
||||||
|
*(vertex_origin + k * 6 + 2) = 0.0f;
|
||||||
|
|
||||||
|
*(vertex_origin + k * 6 + 3) = - x;
|
||||||
|
*(vertex_origin + k * 6 + 4) = - 1.0f / space_size_x;
|
||||||
|
*(vertex_origin + k * 6 + 5) = 0.0f;
|
||||||
|
|
||||||
|
// fun > if (k == space_size_x - 1) *(vertex_origin + k * 6 + 5) = 0.1f;
|
||||||
|
|
||||||
|
vertex_ndx += 6; if (V) printf(" => vertex_ndx = %3d space 2D\n", vertex_ndx);
|
||||||
|
|
||||||
|
*(color_origin + k * 6 + 0) = 1;
|
||||||
|
*(color_origin + k * 6 + 1) = 0;
|
||||||
|
*(color_origin + k * 6 + 2) = 0;
|
||||||
|
|
||||||
|
*(color_origin + k * 6 + 3) = 1;
|
||||||
|
*(color_origin + k * 6 + 4) = 1;
|
||||||
|
*(color_origin + k * 6 + 5) = 0;
|
||||||
|
|
||||||
|
colors_ndx += 6;
|
||||||
|
|
||||||
|
*(line_origin + k * 2 + 0) = k * 2 + 0;
|
||||||
|
*(line_origin + k * 2 + 1) = k * 2 + 1;
|
||||||
|
|
||||||
|
lines_ndx += 2; if (L) printf(" => lines_ndx = %3d space 2D\n", lines_ndx);
|
||||||
|
}
|
||||||
|
|
||||||
|
*(color_origin + 0) = 0;
|
||||||
|
*(color_origin + 1) = 0;
|
||||||
|
*(color_origin + 2) = 0;
|
||||||
|
|
||||||
|
*(color_origin + 3) = 1;
|
||||||
|
*(color_origin + 4) = 1;
|
||||||
|
*(color_origin + 5) = 1;
|
||||||
|
|
||||||
|
*(color_origin + (space_size_x - 1) * 6 + 0) = 1;
|
||||||
|
*(color_origin + (space_size_x - 1) * 6 + 1) = 1;
|
||||||
|
*(color_origin + (space_size_x - 1) * 6 + 2) = 1;
|
||||||
|
|
||||||
|
*(color_origin + (space_size_x - 1) * 6 + 3) = 0;
|
||||||
|
*(color_origin + (space_size_x - 1) * 6 + 4) = 0;
|
||||||
|
*(color_origin + (space_size_x - 1) * 6 + 5) = 0;
|
||||||
|
|
||||||
|
colors_ndx += 12; if (C) printf(" => colors_ndx = %d\n", colors_ndx);
|
||||||
|
|
||||||
|
*(line_origin + lines_ndx + 0) = 0;
|
||||||
|
*(line_origin + lines_ndx + 1) = space_size_x * 2 - 2; // barre horizontale du bas
|
||||||
|
|
||||||
|
*(line_origin + lines_ndx + 2) = 1;
|
||||||
|
*(line_origin + lines_ndx + 3) = space_size_x * 2 - 1; // barre horizontale du haut
|
||||||
|
|
||||||
|
lines_ndx += 4; if (L) printf("H=> lines_ndx = %3d space 2D H\n", lines_ndx);
|
||||||
|
|
||||||
|
if (pref_mark_unit_space == 1 || pref_mark_unit_space == 3) // diagonales to mark first space unit
|
||||||
|
{
|
||||||
|
*(line_origin + lines_ndx + 0) = 0;
|
||||||
|
*(line_origin + lines_ndx + 1) = 3;
|
||||||
|
|
||||||
|
*(line_origin + lines_ndx + 2) = 1;
|
||||||
|
*(line_origin + lines_ndx + 3) = 2;
|
||||||
|
|
||||||
|
lines_ndx += 4; if (L) printf("X=> lines_ndx = %3d space 2D X\n", lines_ndx);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pref_mark_unit_space == 2 || pref_mark_unit_space == 3) // diagonales to mark last space unit
|
||||||
|
{
|
||||||
|
*(line_origin + lines_ndx + 0) = (space_size_x - 2) * 2 + 0;
|
||||||
|
*(line_origin + lines_ndx + 1) = (space_size_x - 2) * 2 + 3;
|
||||||
|
|
||||||
|
*(line_origin + lines_ndx + 2) = (space_size_x - 2) * 2 + 1;
|
||||||
|
*(line_origin + lines_ndx + 3) = (space_size_x - 2) * 2 + 2;
|
||||||
|
|
||||||
|
lines_ndx +=4; if (L) printf("X=> lines_ndx = %3d space 2D X\n", lines_ndx);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (S) printf(" n = %d x 2 côté = [%1.1f]\n", space_size_x + 1, 2.0f / space_size_x);
|
||||||
|
if (S) printf("space_2D line_origin (%d - space_size_x(0)) x (%d - space_size_x(1)) ", 0, 1);
|
||||||
|
for (int v = 0; v < space_size_x + 2; v++)
|
||||||
|
if (S) printf("(%d-%d) ", *(line_origin + v), *(line_origin + v + 1));
|
||||||
|
if (S) printf(" n = 4 + (%d x 2)\n", space_size_x + 2);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define A2 1
|
||||||
|
static int compute_arrow_2D(int space_size_x,
|
||||||
|
int space_size_y,
|
||||||
|
int space_size_z,
|
||||||
|
|
||||||
|
int weight,
|
||||||
|
int site,
|
||||||
|
int x,
|
||||||
|
int y,
|
||||||
|
int z,
|
||||||
|
|
||||||
|
int pref_style_lines_planes,
|
||||||
|
int pref_style_mix_colors,
|
||||||
|
|
||||||
|
GLfloat *vertex_origin,
|
||||||
|
GLfloat *color_origin,
|
||||||
|
GLubyte *line_origin,
|
||||||
|
GLubyte *plan_origin)
|
||||||
|
{
|
||||||
|
printf("compute_arrow_2D load = %d site = %d x = %d\n", weight, site, x);
|
||||||
|
float zero = 0.0f;
|
||||||
|
float center = (1.0f / space_size_x) * (2 * x - space_size_x + 2);
|
||||||
|
float tip = center + (2 * site - 1) * (1.0f / space_size_x - 0.01f);
|
||||||
|
float base = center + (2 * site - 1) * (0.1f / space_size_x);
|
||||||
|
float lat = 0.4f / space_size_x;
|
||||||
|
|
||||||
|
*(vertex_origin + vertex_ndx + 0) = tip;
|
||||||
|
*(vertex_origin + vertex_ndx + 1) = zero;
|
||||||
|
*(vertex_origin + vertex_ndx + 2) = zero;
|
||||||
|
|
||||||
|
*(vertex_origin + vertex_ndx + 3) = base;
|
||||||
|
*(vertex_origin + vertex_ndx + 4) = lat;
|
||||||
|
*(vertex_origin + vertex_ndx + 5) = zero;
|
||||||
|
|
||||||
|
*(vertex_origin + vertex_ndx + 6) = base;
|
||||||
|
*(vertex_origin + vertex_ndx + 7) = - lat;
|
||||||
|
*(vertex_origin + vertex_ndx + 8) = zero;
|
||||||
|
|
||||||
|
vertex_ndx += 9; if (V) printf(" => vertex_ndx = %3d arrow_2D\n", vertex_ndx);
|
||||||
|
|
||||||
|
if (pref_style_lines_planes == 0) {
|
||||||
|
|
||||||
|
if (V) printf("0=> lines_ndx = %d\n", lines_ndx);
|
||||||
|
|
||||||
|
*(line_origin + lines_ndx + 0) = vertex_ndx / 3 - 3;
|
||||||
|
*(line_origin + lines_ndx + 1) = vertex_ndx / 3 - 2;
|
||||||
|
|
||||||
|
*(line_origin + lines_ndx + 2) = vertex_ndx / 3 - 3;
|
||||||
|
*(line_origin + lines_ndx + 3) = vertex_ndx / 3 - 1;
|
||||||
|
|
||||||
|
*(line_origin + lines_ndx + 4) = vertex_ndx / 3 - 2;
|
||||||
|
*(line_origin + lines_ndx + 5) = vertex_ndx / 3 - 1;
|
||||||
|
|
||||||
|
lines_ndx += 6; if (L) printf("|=> lines_ndx = %3d arrow_2D\n", lines_ndx);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (pref_style_lines_planes == 1) {
|
||||||
|
*(plan_origin + plans_ndx + 0) = vertex_ndx / 3 + 0;
|
||||||
|
*(plan_origin + plans_ndx + 1) = vertex_ndx / 3 + 1;
|
||||||
|
*(plan_origin + plans_ndx + 2) = vertex_ndx / 3 + 2;
|
||||||
|
|
||||||
|
*(plan_origin + plans_ndx + 3) = vertex_ndx / 3 + 0;
|
||||||
|
*(plan_origin + plans_ndx + 4) = vertex_ndx / 3 + 1;
|
||||||
|
*(plan_origin + plans_ndx + 5) = vertex_ndx / 3 + 2;
|
||||||
|
|
||||||
|
plans_ndx += 6; if (P) printf("|=> plans_ndx = %d\n", plans_ndx);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool compute_space_3D (int space_size_x,
|
||||||
|
int space_size_y,
|
||||||
|
int space_size_z,
|
||||||
|
|
||||||
|
int pref_mark_unit_space,
|
||||||
|
int pref_style_lines_planes,
|
||||||
|
int pref_style_mix_colors,
|
||||||
|
|
||||||
|
GLfloat *vertex_origin,
|
||||||
|
GLfloat *color_origin,
|
||||||
|
GLubyte *line_origin,
|
||||||
|
GLubyte *plan_origin)
|
||||||
|
{
|
||||||
|
|
||||||
|
float x = 0;
|
||||||
|
// for (int k = 0; k < space_size_x + 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 (S3) printf("space 3D (vertex) x localizations ");
|
||||||
|
for (int k = 0; k < space_size_x; k++){ // barres verticales
|
||||||
|
//
|
||||||
|
x = ((space_size_x % 2) * (space_size_x / 2 - k)
|
||||||
|
+ (space_size_x % 2 - 1) * (k + 0.5f - space_size_x / 2)) / space_size_x * 2 * EDGE;
|
||||||
|
|
||||||
|
if (S3) printf("[%1.1f] ", x);
|
||||||
|
|
||||||
|
*(vertex_origin + k * 12 + 0) = - x;
|
||||||
|
*(vertex_origin + k * 12 + 1) = 1.0f / space_size_x;
|
||||||
|
*(vertex_origin + k * 12 + 2) = 1.0f / space_size_x;
|
||||||
|
|
||||||
|
*(vertex_origin + k * 12 + 3) = - x;
|
||||||
|
*(vertex_origin + k * 12 + 4) = - 1.0f / space_size_x;
|
||||||
|
*(vertex_origin + k * 12 + 5) = - 1.0f / space_size_x;
|
||||||
|
|
||||||
|
*(vertex_origin + k * 12 + 6) = - x;
|
||||||
|
*(vertex_origin + k * 12 + 7) = 1.0f / space_size_x;
|
||||||
|
*(vertex_origin + k * 12 + 8) = - 1.0f / space_size_x;
|
||||||
|
|
||||||
|
*(vertex_origin + k * 12 + 9) = - x;
|
||||||
|
*(vertex_origin + k * 12 + 10) = - 1.0f / space_size_x;
|
||||||
|
*(vertex_origin + k * 12 + 11) = 1.0f / space_size_x;
|
||||||
|
|
||||||
|
vertex_ndx += 12; if (V) printf(" => vertex_ndx = %3d space_3D\n", vertex_ndx);
|
||||||
|
|
||||||
|
*(color_origin + k * 12 + 0) = 1; // 1 - (k / space_size_x);
|
||||||
|
*(color_origin + k * 12 + 1) = 0;
|
||||||
|
*(color_origin + k * 12 + 2) = 0;
|
||||||
|
|
||||||
|
*(color_origin + k * 12 + 3) = 0.2f;
|
||||||
|
*(color_origin + k * 12 + 4) = 1;
|
||||||
|
*(color_origin + k * 12 + 5) = 0;
|
||||||
|
|
||||||
|
*(color_origin + k * 12 + 6) = 1;
|
||||||
|
*(color_origin + k * 12 + 7) = 1;
|
||||||
|
*(color_origin + k * 12 + 8) = 0;
|
||||||
|
|
||||||
|
*(color_origin + k * 12 + 9) = 0;
|
||||||
|
*(color_origin + k * 12 + 10) = 0;
|
||||||
|
*(color_origin + k * 12 + 11) = 1;
|
||||||
|
|
||||||
|
colors_ndx += 12; if (C) printf(" => colors_ndx = %d\n", colors_ndx);
|
||||||
|
}
|
||||||
|
|
||||||
|
*(color_origin + 0) = 0;
|
||||||
|
*(color_origin + 1) = 0;
|
||||||
|
*(color_origin + 2) = 0;
|
||||||
|
|
||||||
|
*(color_origin + 3) = 1;
|
||||||
|
*(color_origin + 4) = 1;
|
||||||
|
*(color_origin + 5) = 1;
|
||||||
|
|
||||||
|
*(color_origin + 6) = 0;
|
||||||
|
*(color_origin + 7) = 0;
|
||||||
|
*(color_origin + 8) = 0;
|
||||||
|
|
||||||
|
*(color_origin + 9) = 1;
|
||||||
|
*(color_origin + 10) = 1;
|
||||||
|
*(color_origin + 11) = 1;
|
||||||
|
|
||||||
|
colors_ndx += 12; if (C) printf(" => colors_ndx = %d\n", colors_ndx);
|
||||||
|
|
||||||
|
*(color_origin + (space_size_x - 1) * 12 + 0) = 1;
|
||||||
|
*(color_origin + (space_size_x - 1) * 12 + 1) = 1;
|
||||||
|
*(color_origin + (space_size_x - 1) * 12 + 2) = 1;
|
||||||
|
|
||||||
|
*(color_origin + (space_size_x - 1) * 12 + 3) = 0;
|
||||||
|
*(color_origin + (space_size_x - 1) * 12 + 4) = 0;
|
||||||
|
*(color_origin + (space_size_x - 1) * 12 + 5) = 0;
|
||||||
|
|
||||||
|
*(color_origin + (space_size_x - 1) * 12 + 6) = 0;
|
||||||
|
*(color_origin + (space_size_x - 1) * 12 + 7) = 0;
|
||||||
|
*(color_origin + (space_size_x - 1) * 12 + 8) = 0;
|
||||||
|
|
||||||
|
*(color_origin + (space_size_x - 1) * 12 + 9) = 1;
|
||||||
|
*(color_origin + (space_size_x - 1) * 12 + 10) = 1;
|
||||||
|
*(color_origin + (space_size_x - 1) * 12 + 11) = 1;
|
||||||
|
|
||||||
|
colors_ndx += 12; if (C) printf(" => colors_ndx = %d\n", colors_ndx);
|
||||||
|
|
||||||
|
if (S3) printf(" n = %d x 2 côté = [%1.1f]\n", space_size_x + 1, 2.0f / space_size_x);
|
||||||
|
|
||||||
|
*(line_origin + 4) = 0;
|
||||||
|
*(line_origin + 5) = space_size_x * 4 - 4; // barre horizontale du bas arr
|
||||||
|
|
||||||
|
*(line_origin + 6) = 1;
|
||||||
|
*(line_origin + 7) = space_size_x * 4 - 3; // barre horizontale du haut arr
|
||||||
|
|
||||||
|
*(line_origin + 0) = 2;
|
||||||
|
*(line_origin + 1) = space_size_x * 4 - 2; // barre horizontale du bas av
|
||||||
|
|
||||||
|
*(line_origin + 2) = 3;
|
||||||
|
*(line_origin + 3) = space_size_x * 4 - 1; // barre horizontale du haut av
|
||||||
|
|
||||||
|
lines_ndx += 8; if (L) printf("|=> lines_ndx = %3d space 3D\n", lines_ndx);
|
||||||
|
|
||||||
|
/* *(plan_origin + 0) = 0; */
|
||||||
|
/* *(plan_origin + 1) = 1; */
|
||||||
|
/* *(plan_origin + 2) = 2; */
|
||||||
|
|
||||||
|
/* *(plan_origin + 3) = 0; */
|
||||||
|
/* *(plan_origin + 4) = 1; */
|
||||||
|
/* *(plan_origin + 5) = 3; */
|
||||||
|
// plans_ndx += 6; if (P) printf("|=> plans_ndx = %d\n", plans_ndx);
|
||||||
|
|
||||||
|
|
||||||
|
for (int k = 8; k <= space_size_x * 8; k += 8){ // for (int k = 8; k < space_size_x * 8; k += 8){
|
||||||
|
|
||||||
|
|
||||||
|
*(line_origin + k + 0) = k / 2 - 4; // + 0;
|
||||||
|
*(line_origin + k + 1) = k / 2 - 2; // + 2;
|
||||||
|
|
||||||
|
*(line_origin + k + 2) = k / 2 - 3; // + 1;
|
||||||
|
*(line_origin + k + 3) = k / 2 - 1; // + 3;
|
||||||
|
|
||||||
|
*(line_origin + k + 4) = k / 2 - 4; // + 0;
|
||||||
|
*(line_origin + k + 5) = k / 2 - 1; // + 3;
|
||||||
|
|
||||||
|
*(line_origin + k + 6) = k / 2 - 3; // + 1;
|
||||||
|
*(line_origin + k + 7) = k / 2 - 2; // + 2;
|
||||||
|
|
||||||
|
lines_ndx += 8; if (L) printf("|=> lines_ndx = %3d space_3D\n", lines_ndx);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pref_mark_unit_space == 1 || pref_mark_unit_space == 3) {
|
||||||
|
|
||||||
|
*(line_origin + (2 + space_size_x) * 8 - 4) = 0 + 0; // diagonales pour marquer la case zéro
|
||||||
|
*(line_origin + (2 + space_size_x) * 8 - 3) = 0 + 1;
|
||||||
|
|
||||||
|
*(line_origin + (2 + space_size_x) * 8 - 2) = 0 + 2; // diagonales pour marquer la case zéro
|
||||||
|
*(line_origin + (2 + space_size_x) * 8 - 1) = 0 + 3;
|
||||||
|
|
||||||
|
lines_ndx += 4; if (L) printf("|=> lines_ndx = %3d space_3D\n", lines_ndx);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pref_mark_unit_space == 2 || pref_mark_unit_space == 3) {
|
||||||
|
|
||||||
|
*(line_origin + (2 + space_size_x) * 8 - 8) = (space_size_x - 1) * 4 + 0; // diagonales pour marquer la case finale
|
||||||
|
*(line_origin + (2 + space_size_x) * 8 - 7) = (space_size_x - 1) * 4 + 1;
|
||||||
|
|
||||||
|
*(line_origin + (2 + space_size_x) * 8 - 6) = (space_size_x - 1) * 4 + 2; // diagonales pour marquer la case finale
|
||||||
|
*(line_origin + (2 + space_size_x) * 8 - 5) = (space_size_x - 1) * 4 + 3;
|
||||||
|
|
||||||
|
lines_ndx += 4; if (L) printf("|=> lines_ndx = %3d space_3D\n", lines_ndx);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (S3) printf("space 3D buffer_lines (from-to) ");
|
||||||
|
for (int v = 0; v < space_size_x + 2; v++) {
|
||||||
|
if (S3) printf("(%d-%d) ", *(line_origin + v), *(line_origin + v + 1));
|
||||||
|
}
|
||||||
|
if (S3) printf("\n");
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool compute_arrow_3D(int space_size_x,
|
||||||
|
int space_size_y,
|
||||||
|
int space_size_z,
|
||||||
|
|
||||||
|
int weight,
|
||||||
|
int site,
|
||||||
|
int x,
|
||||||
|
int y,
|
||||||
|
int z,
|
||||||
|
|
||||||
|
int pref_style_lines_planes,
|
||||||
|
int pref_style_mix_colors,
|
||||||
|
|
||||||
|
GLfloat *vertex_origin,
|
||||||
|
GLfloat *color_origin,
|
||||||
|
GLubyte *line_origin,
|
||||||
|
GLubyte *plan_origin)
|
||||||
|
|
||||||
|
{
|
||||||
|
float zero = 0.0f;
|
||||||
|
float center = (1.0f / space_size_x) * (2 * x - space_size_x + 2);
|
||||||
|
float tip = center + (2 * site - 1) * (1.0f / space_size_x);
|
||||||
|
float base = center + (2 * site - 1) * (0.1f / space_size_x);
|
||||||
|
|
||||||
|
*(vertex_origin + vertex_ndx + 0) = center + (2 * site - 1) * (1.0f / space_size_x - 0.01f);
|
||||||
|
*(vertex_origin + vertex_ndx + 1) = zero;
|
||||||
|
*(vertex_origin + vertex_ndx + 2) = zero;
|
||||||
|
|
||||||
|
*(vertex_origin + vertex_ndx + 3) = base;
|
||||||
|
*(vertex_origin + vertex_ndx + 4) = 0.4f / space_size_x;
|
||||||
|
*(vertex_origin + vertex_ndx + 5) = 0.4f / space_size_x;
|
||||||
|
|
||||||
|
*(vertex_origin + vertex_ndx + 6) = base;
|
||||||
|
*(vertex_origin + vertex_ndx + 7) = 0.4f / space_size_x;
|
||||||
|
*(vertex_origin + vertex_ndx + 8) = - 0.4f / space_size_x;
|
||||||
|
|
||||||
|
*(vertex_origin + vertex_ndx + 9) = base;
|
||||||
|
*(vertex_origin + vertex_ndx + 10) = - 0.4f / space_size_x;
|
||||||
|
*(vertex_origin + vertex_ndx + 11) = - 0.4f / space_size_x;
|
||||||
|
|
||||||
|
*(vertex_origin + vertex_ndx + 12) = base;
|
||||||
|
*(vertex_origin + vertex_ndx + 13) = - 0.4f / space_size_x;
|
||||||
|
*(vertex_origin + vertex_ndx + 14) = 0.4f / space_size_x;
|
||||||
|
|
||||||
|
vertex_ndx += 15; if (V) printf(" => vertex_ndx = %3d arrow_3D\n", vertex_ndx);
|
||||||
|
|
||||||
|
if (A3) printf("center = %f tip = %f base = %f\n",\
|
||||||
|
center, tip, base); // space_size_x * 12=%d igap=%d
|
||||||
|
|
||||||
|
if (pref_style_lines_planes == 0) {
|
||||||
|
|
||||||
|
*(line_origin + lines_ndx + 0) = vertex_ndx / 3 - 5;
|
||||||
|
*(line_origin + lines_ndx + 1) = vertex_ndx / 3 - 4;
|
||||||
|
|
||||||
|
*(line_origin + lines_ndx + 2) = vertex_ndx / 3 - 5;
|
||||||
|
*(line_origin + lines_ndx + 3) = vertex_ndx / 3 - 3;
|
||||||
|
|
||||||
|
*(line_origin + lines_ndx + 4) = vertex_ndx / 3 - 5;
|
||||||
|
*(line_origin + lines_ndx + 5) = vertex_ndx / 3 - 2;
|
||||||
|
|
||||||
|
*(line_origin + lines_ndx + 6) = vertex_ndx / 3 - 5;
|
||||||
|
*(line_origin + lines_ndx + 7) = vertex_ndx / 3 - 1;
|
||||||
|
|
||||||
|
*(line_origin + lines_ndx + 8) = vertex_ndx / 3 - 4;
|
||||||
|
*(line_origin + lines_ndx + 9) = vertex_ndx / 3 - 3;
|
||||||
|
|
||||||
|
*(line_origin + lines_ndx + 10) = vertex_ndx / 3 - 3;
|
||||||
|
*(line_origin + lines_ndx + 11) = vertex_ndx / 3 - 2;
|
||||||
|
|
||||||
|
*(line_origin + lines_ndx + 12) = vertex_ndx / 3 - 2;
|
||||||
|
*(line_origin + lines_ndx + 13) = vertex_ndx / 3 - 1;
|
||||||
|
|
||||||
|
*(line_origin + lines_ndx + 14) = vertex_ndx / 3 - 1;
|
||||||
|
*(line_origin + lines_ndx + 15) = vertex_ndx / 3 - 4;
|
||||||
|
|
||||||
|
lines_ndx += 16; if (L) printf("|=> lines_ndx = %3d arrow_3D\n", lines_ndx);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pref_style_lines_planes == 1) {
|
||||||
|
|
||||||
|
*(plan_origin + plans_ndx + 0) = space_size_x * 12 / 3 + 0;
|
||||||
|
*(plan_origin + plans_ndx + 1) = space_size_x * 12 / 3 + 1;
|
||||||
|
*(plan_origin + plans_ndx + 2) = space_size_x * 12 / 3 + 2;
|
||||||
|
|
||||||
|
*(plan_origin + plans_ndx + 3) = space_size_x * 12 / 3 + 0;
|
||||||
|
*(plan_origin + plans_ndx + 4) = space_size_x * 12 / 3 + 3;
|
||||||
|
*(plan_origin + plans_ndx + 5) = space_size_x * 12 / 3 + 4;
|
||||||
|
|
||||||
|
*(plan_origin + plans_ndx + 0) = space_size_x * 12 / 3 + 0;
|
||||||
|
*(plan_origin + plans_ndx + 1) = space_size_x * 12 / 3 + 1;
|
||||||
|
*(plan_origin + plans_ndx + 2) = space_size_x * 12 / 3 + 3;
|
||||||
|
|
||||||
|
*(plan_origin + plans_ndx + 3) = space_size_x * 12 / 3 + 0;
|
||||||
|
*(plan_origin + plans_ndx + 4) = space_size_x * 12 / 3 + 2;
|
||||||
|
*(plan_origin + plans_ndx + 5) = space_size_x * 12 / 3 + 4;
|
||||||
|
|
||||||
|
plans_ndx += 12; if (P) printf("|=> plans_ndx = %3d arrow_3D\n", plans_ndx);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void show_user_choices(int model_space_size_x,
|
||||||
|
int model_space_size_y,
|
||||||
|
int model_space_size_z,
|
||||||
|
|
||||||
|
GLubyte *arrows,
|
||||||
|
int model_arrows_nb,
|
||||||
|
|
||||||
|
int pref_3D_xor_2D_space,
|
||||||
|
int pref_3D_xor_2D_arrows,
|
||||||
|
int pref_mark_unit_space,
|
||||||
|
int pref_style_lines_planes,
|
||||||
|
int pref_style_mix_colors)
|
||||||
|
{
|
||||||
|
printf("model + user constraints : x,y,z = (%d, %d, %d) ", model_space_size_x, model_space_size_y, model_space_size_z);
|
||||||
|
if (pref_3D_xor_2D_space == 0) printf("3D space ");
|
||||||
|
if (pref_3D_xor_2D_space == 1) printf("2D space ");
|
||||||
|
if (model_arrows_nb > 0) printf("[%d] ", model_arrows_nb);
|
||||||
|
if (pref_3D_xor_2D_arrows == 0) printf("3D arrow(s) ");
|
||||||
|
if (pref_3D_xor_2D_arrows == 1) printf("2D arrow(s) ");
|
||||||
|
if (pref_mark_unit_space == 0) printf("no unit_space marks ");
|
||||||
|
if (pref_mark_unit_space == 1) printf("first unit space marked ");
|
||||||
|
if (pref_mark_unit_space == 2) printf("last unit_space marked ");
|
||||||
|
if (pref_mark_unit_space == 3) printf("first and last units space marked ");
|
||||||
|
if (! pref_style_lines_planes) printf("style_lines_planes = 0 ");
|
||||||
|
if (pref_style_lines_planes > 0)printf("style_lines_planes = %d ", pref_style_lines_planes);
|
||||||
|
if (! pref_style_mix_colors) printf("style_mix_colors = 0 ");
|
||||||
|
if (pref_style_mix_colors > 0) printf("style_mix_colors = %d ", pref_style_mix_colors);
|
||||||
|
if (model_arrows_nb > 0) printf("\n[ n] load site x ---- < arrows array >\
|
||||||
|
---------------------------------------------------------------------\n");
|
||||||
|
// arrows = { 1, 1, 0, 1, 2, 1, 1, 1, 10, 1, 2, 11, 1, 1, 20, 1, 2, 21 }
|
||||||
|
if (SA) for (int i = 0; i < model_arrows_nb; i++)
|
||||||
|
printf("[%2d] = %2d, %2d, %2d \n",\
|
||||||
|
i, *(arrows + i * 3), *(arrows + i * 3 + 1), *(arrows + i * 3 + 2));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool compute_space_and_arrows(int model_space_size_x,
|
||||||
|
int model_space_size_y,
|
||||||
|
int model_space_size_z,
|
||||||
|
|
||||||
|
GLubyte *arrows,
|
||||||
|
int model_arrows_nb,
|
||||||
|
|
||||||
|
int pref_3D_xor_2D_space,
|
||||||
|
int pref_3D_xor_2D_arrows,
|
||||||
|
int pref_mark_unit_space,
|
||||||
|
int pref_style_lines_planes,
|
||||||
|
int pref_style_mix_colors,
|
||||||
|
|
||||||
|
GLfloat *vertex_origin,
|
||||||
|
GLfloat *color_origin,
|
||||||
|
GLubyte *line_origin,
|
||||||
|
GLubyte *plan_origin)
|
||||||
|
|
||||||
|
{
|
||||||
|
if (SA) show_user_choices(model_space_size_x,
|
||||||
|
model_space_size_y,
|
||||||
|
model_space_size_z,
|
||||||
|
|
||||||
|
arrows,
|
||||||
|
model_arrows_nb,
|
||||||
|
|
||||||
|
pref_3D_xor_2D_space,
|
||||||
|
pref_3D_xor_2D_arrows,
|
||||||
|
pref_mark_unit_space,
|
||||||
|
pref_style_lines_planes,
|
||||||
|
pref_style_mix_colors);
|
||||||
|
|
||||||
|
if (pref_3D_xor_2D_space) compute_space_2D (
|
||||||
|
model_space_size_x,
|
||||||
|
model_space_size_y,
|
||||||
|
model_space_size_z,
|
||||||
|
|
||||||
|
pref_mark_unit_space,
|
||||||
|
pref_style_lines_planes,
|
||||||
|
pref_style_mix_colors,
|
||||||
|
|
||||||
|
vertex_origin,
|
||||||
|
color_origin,
|
||||||
|
line_origin,
|
||||||
|
plan_origin);
|
||||||
|
|
||||||
|
else compute_space_3D (
|
||||||
|
model_space_size_x,
|
||||||
|
model_space_size_y,
|
||||||
|
model_space_size_z,
|
||||||
|
|
||||||
|
pref_mark_unit_space,
|
||||||
|
pref_style_lines_planes,
|
||||||
|
pref_style_mix_colors,
|
||||||
|
|
||||||
|
vertex_origin,
|
||||||
|
color_origin,
|
||||||
|
line_origin,
|
||||||
|
plan_origin);
|
||||||
|
|
||||||
|
for (int i = 0; i < model_arrows_nb; i++)
|
||||||
|
if (pref_3D_xor_2D_arrows) compute_arrow_2D(
|
||||||
|
model_space_size_x,
|
||||||
|
model_space_size_y,
|
||||||
|
model_space_size_z,
|
||||||
|
|
||||||
|
*(arrows + i * 3 + 0), // weight (load)
|
||||||
|
*(arrows + i * 3 + 1), // site
|
||||||
|
*(arrows + i * 3 + 2), // x
|
||||||
|
0, // y
|
||||||
|
0, // z
|
||||||
|
|
||||||
|
pref_style_lines_planes,
|
||||||
|
pref_style_mix_colors,
|
||||||
|
|
||||||
|
vertex_origin,
|
||||||
|
color_origin,
|
||||||
|
line_origin,
|
||||||
|
plan_origin);
|
||||||
|
|
||||||
|
else compute_arrow_3D(
|
||||||
|
model_space_size_x,
|
||||||
|
model_space_size_y,
|
||||||
|
model_space_size_z,
|
||||||
|
|
||||||
|
*(arrows + i * 3 + 0), // weight (load)
|
||||||
|
*(arrows + i * 3 + 1), // site
|
||||||
|
*(arrows + i * 3 + 2), // x
|
||||||
|
0, // y
|
||||||
|
0, // z
|
||||||
|
|
||||||
|
pref_style_lines_planes,
|
||||||
|
pref_style_mix_colors,
|
||||||
|
|
||||||
|
vertex_origin,
|
||||||
|
color_origin,
|
||||||
|
line_origin,
|
||||||
|
plan_origin);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
* Desc: OpenGL utils header
|
* Desc: OpenGL utils header
|
||||||
*
|
*
|
||||||
* Copyright (C) 2023 Jean Sirmai <jean@a-lec.org>
|
* Copyright (C) 2023 Jean Sirmai <jean@a-lec.org>
|
||||||
|
* Copyleft (something) ( ;- )) Isn't that fun ?! ----------------,cbF@^@ââ63-OPM,FJ&_(_((T^RQJn||lpv)=à)o -----------------------------------------------------
|
||||||
*
|
*
|
||||||
* This file is part of Gem-graph.
|
* This file is part of Gem-graph.
|
||||||
*
|
*
|
||||||
|
@ -39,8 +40,8 @@
|
||||||
|
|
||||||
#include "../../include/base.h"
|
#include "../../include/base.h"
|
||||||
#include "../../include/ui.h"
|
#include "../../include/ui.h"
|
||||||
#include "../../include/graphics_control.h"
|
#include "../../include/graphics.h"
|
||||||
#include "../../include/graphics_compute.h"
|
#include "../../include/buffers.h"
|
||||||
#include "../../include/space_2D.h"
|
#include "../../include/space_2D.h"
|
||||||
#include "../../include/space_3D.h"
|
#include "../../include/space_3D.h"
|
||||||
#include "../../include/arrow_2D.h"
|
#include "../../include/arrow_2D.h"
|
||||||
|
@ -70,7 +71,7 @@ int graphics_compute_lines(int line_indices_nb,
|
||||||
vertex_nb = (state_size + 1) * 12 + arrows_nb * 15;
|
vertex_nb = (state_size + 1) * 12 + arrows_nb * 15;
|
||||||
colors_nb = (state_size + 1) * 12 + arrows_nb * 0; // TODO
|
colors_nb = (state_size + 1) * 12 + arrows_nb * 0; // TODO
|
||||||
// lines_nb = (2 + state_size) + (arrows_nb * 3); // cas 2D
|
// 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
|
lines_nb = (4 + state_size * 4) + (arrows_nb * 8) + 4; // + 4; pour les 4 diagonales (29/6/2023 pour voir)
|
||||||
//// plans_nb = 8; //(4 + state_size * 4) + (arrows_nb * 8) + 2; // bhuingfyunfyuguinlgi svbysbubsyu qvyqytqujtvcttcef
|
//// plans_nb = 8; //(4 + state_size * 4) + (arrows_nb * 8) + 2; // bhuingfyunfyuguinlgi svbysbubsyu qvyqytqujtvcttcef
|
||||||
|
|
||||||
line_indices_nb = lines_nb * 2;
|
line_indices_nb = lines_nb * 2;
|
||||||
|
@ -100,7 +101,7 @@ int graphics_compute_lines(int line_indices_nb,
|
||||||
}
|
}
|
||||||
|
|
||||||
compute_space_3D(state_size, vertex_base, color_base, line_ndx,
|
compute_space_3D(state_size, vertex_base, color_base, line_ndx,
|
||||||
0,4); // patch provisoire
|
0,0); // patch provisoire
|
||||||
// pref_mark_unit_space_zero, dgap){
|
// pref_mark_unit_space_zero, dgap){
|
||||||
vgap += (12 * state_size); igap += state_size * 8 + 8; cgap += (12 * state_size);
|
vgap += (12 * state_size); igap += state_size * 8 + 8; cgap += (12 * state_size);
|
||||||
|
|
||||||
|
@ -256,7 +257,7 @@ int graphics_compute_plans(int plan_indices_nb,
|
||||||
// assert(k + 8 < line_indices_nb); assert(k + 16 < line_indices_nb);
|
// assert(k + 8 < line_indices_nb); assert(k + 16 < line_indices_nb);
|
||||||
|
|
||||||
compute_space_3D(state_size, vertex_base, color_base, plan_ndx,
|
compute_space_3D(state_size, vertex_base, color_base, plan_ndx,
|
||||||
0,4); // patch provisoire
|
0,0); // patch provisoire
|
||||||
//pref_mark_unit_space_zero, dgap){
|
//pref_mark_unit_space_zero, dgap){
|
||||||
|
|
||||||
vgap += (12 * state_size); igap += state_size * 8 + 8; cgap += (12 * state_size);
|
vgap += (12 * state_size); igap += state_size * 8 + 8; cgap += (12 * state_size);
|
||||||
|
@ -359,4 +360,3 @@ int graphics_compute_plans(int plan_indices_nb,
|
||||||
/// }
|
/// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,24 +36,41 @@
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#include "../../include/base.h"
|
//#include "../../include/base.h"
|
||||||
#include "../../include/ui.h"
|
#include "../../include/ui.h"
|
||||||
#include "../../include/graphics_control.h"
|
#include "../../include/graphics.h"
|
||||||
#include "../../include/space_2D.h"
|
#include "../../include/buffers.h"
|
||||||
#include "../../include/space_3D.h"
|
|
||||||
#include "../../include/arrow_2D.h"
|
|
||||||
#include "../../include/arrow_3D.h"
|
|
||||||
|
|
||||||
#define VERTEX_SHADER_FILE "src/shaders/shader.vert"
|
#define VERTEX_SHADER_FILE "src/shaders/shader.vert"
|
||||||
#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;
|
|
||||||
GLubyte *line_ndx = NULL;
|
|
||||||
GLubyte *plan_ndx = 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 *buffer_vertex_origin = NULL;
|
||||||
|
GLfloat *buffer_colors_origin = NULL;
|
||||||
|
GLubyte *buffer_lines_origin = NULL;
|
||||||
|
GLubyte *buffer_plans_origin = NULL;
|
||||||
|
|
||||||
|
int pref_3D_xor_2D_space = 0; // default view == 0 == 3D
|
||||||
|
int pref_3D_xor_2D_arrows = 0; // default view == 0 == 3D
|
||||||
|
int pref_mark_unit_space = 0; // default == 0 == no marks
|
||||||
|
int pref_style_lines_planes = 0; // arrows as lines = 0, as planes = 1
|
||||||
|
int pref_style_mix_colors = 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
|
||||||
|
@ -261,10 +278,10 @@ 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(buffer_vertex_origin);
|
||||||
g_free(color_base);
|
g_free(buffer_colors_origin);
|
||||||
g_free(line_ndx);
|
g_free(buffer_lines_origin);
|
||||||
g_free(plan_ndx);
|
g_free(buffer_plans_origin);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -484,68 +501,121 @@ bool graphics_init_shaders(const void *gl_area)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
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;
|
|
||||||
bool pref_3D_xor_2D_space = 0; // default view == 0 == 3D
|
|
||||||
bool pref_3D_xor_2D_arrows = 0; // default view == 0 == 3D
|
|
||||||
bool pref_mark_unit_space_zero = 0; // default == 0 == no mark
|
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
GLubyte arrows[] = { 1, 1, 0, 1, 0, 1, 1, 1, 4, 1, 0, 5, 1, 1, 8, 1, 0, 9 };
|
||||||
|
// arrows[] = { 1, 1, 0, 1, 2, 1, 1, 1, 10, 1, 2, 11, 1, 1, 20, 1, 2, 21 };
|
||||||
|
|
||||||
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)
|
|
||||||
// { 1, 1, 0, 1, 2, 1, 1, 1, 10, 1, 2, 11, 1, 1, 20, 1, 2, 21 };
|
|
||||||
|
|
||||||
dim = 1;
|
model_space_size_x = 11; // 2 < model_space_size_x < 32
|
||||||
state_size = 9; // 2 < state_size < 32
|
model_arrows_nb = 6; // assert : l'emplacement des flèches est contraint
|
||||||
arrows_nb = 4; // assert : leur emplacement doit être fonction de state_size
|
// par 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; // 0 = 3D 1 = 2D
|
||||||
pref_3D_xor_2D_arrows = 1; // default == 0 == 3D
|
pref_3D_xor_2D_arrows = 0; // 0 = 3D 1 = 2D
|
||||||
pref_mark_unit_space_zero = 1; // default == 0 == no mark
|
pref_mark_unit_space = 3; // 0 = no marks, 1 = 1st, 2 = last, 3 = both
|
||||||
|
pref_style_lines_planes = 0; // 0 = arrows as lines, 1 = as planes, 2 = mix
|
||||||
|
pref_style_mix_colors = 0; // TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
static void compute_vertex_colors_lines_plans_nb(int dim,
|
|
||||||
int state_size,
|
|
||||||
int arrows_nb,
|
|
||||||
bool pref_3D_xor_2D_space,
|
|
||||||
bool pref_3D_xor_2D_arrows,
|
|
||||||
bool pref_mark_unit_space_zero,
|
|
||||||
struct gl_area_entry *entry){
|
|
||||||
if (pref_3D_xor_2D_space) vertex_nb = (state_size + 1) * 6 + arrows_nb * 9; // case 2D
|
|
||||||
else vertex_nb = (state_size + 1) * 12 + arrows_nb * 15; // case 3D
|
|
||||||
|
|
||||||
if (pref_3D_xor_2D_space) lines_nb = (2 + state_size) + (arrows_nb * 3); // case 2D
|
|
||||||
else lines_nb = (4 + state_size * 4) + (arrows_nb * 8); // case 3D
|
|
||||||
|
|
||||||
if (pref_mark_unit_space_zero) lines_nb += 2; // 2 diagonal lines
|
|
||||||
//
|
|
||||||
plans_nb = 8; // (4 + state_size * 4) + (arrows_nb * 8) + 2;
|
|
||||||
|
|
||||||
entry->line_indices_nb = lines_nb * 2;
|
|
||||||
entry->plan_indices_nb = plans_nb * 3;
|
|
||||||
|
|
||||||
colors_nb = (state_size + 1) * 12 + arrows_nb * 0; // TODO
|
|
||||||
|
|
||||||
assert(state_size * 6 < vertex_nb); assert(state_size * 6 + 5 < vertex_nb);
|
|
||||||
|
|
||||||
printf("Prefer : mark_unit_space_zero = %d pref_3D_xor_2D_space = %d state_size = %d\n",
|
|
||||||
pref_mark_unit_space_zero, pref_3D_xor_2D_space, 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);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#define S 1
|
||||||
|
static void compute_buffers_sizes(int model_space_size_x,
|
||||||
|
int model_space_size_y,
|
||||||
|
int model_space_size_z,
|
||||||
|
|
||||||
|
int model_arrows_nb,
|
||||||
|
|
||||||
|
int pref_3D_xor_2D_space,
|
||||||
|
int pref_3D_xor_2D_arrows,
|
||||||
|
int pref_mark_unit_space,
|
||||||
|
int pref_style_lines_planes,
|
||||||
|
int pref_style_mix_colors)
|
||||||
|
{
|
||||||
|
int two_ladder_amounts = 4; // 2 parallels to connect 4 vertices
|
||||||
|
|
||||||
|
if (pref_3D_xor_2D_space) { // 2D the ladder has 2 amounts
|
||||||
|
buffer_vertex_size = model_space_size_x * 6;
|
||||||
|
buffer_colors_size = model_space_size_x * 6;
|
||||||
|
buffer_plans_size = 0;
|
||||||
|
buffer_lines_size = model_space_size_x * 2 + two_ladder_amounts;
|
||||||
|
|
||||||
|
} else { // 3D the ladder has 4 amounts, now
|
||||||
|
buffer_vertex_size = (model_space_size_x + 1) * 12;
|
||||||
|
buffer_colors_size = (model_space_size_x + 1) * 12;
|
||||||
|
buffer_plans_size = 0;
|
||||||
|
buffer_lines_size = (model_space_size_x + 1) * 12 + 2 * two_ladder_amounts;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* There, increment in buffer_lines_size is the same for 2D & 3D */
|
||||||
|
if (pref_mark_unit_space == 1 || pref_mark_unit_space == 3) buffer_lines_size += 4; // 2 diagonal lines
|
||||||
|
if (pref_mark_unit_space == 2 || pref_mark_unit_space == 3) buffer_lines_size += 4; // 2 diagonal lines
|
||||||
|
|
||||||
|
if (pref_3D_xor_2D_arrows) { // 2D
|
||||||
|
buffer_vertex_size += model_arrows_nb * 9;
|
||||||
|
buffer_colors_size += model_arrows_nb * 9;
|
||||||
|
buffer_plans_size += 0;
|
||||||
|
buffer_lines_size += model_arrows_nb * 6;
|
||||||
|
|
||||||
|
} else { // 3D
|
||||||
|
buffer_vertex_size += model_arrows_nb * 15;
|
||||||
|
buffer_colors_size += model_arrows_nb * 15;
|
||||||
|
buffer_plans_size += 0;
|
||||||
|
buffer_lines_size += model_arrows_nb * 16;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* buffer_plans_size est fonction de : model_space_size_x, model_arrows_nb et de pref_style_lines_planes */
|
||||||
|
|
||||||
|
if (S) printf("allocated buffers sizes :%4d/3 = %3d vertices, %4d/3 = %3d colors,\
|
||||||
|
%4d/2 = %3d lines, %4d/3 = %3d plans. (space_size_x = %d)\n",
|
||||||
|
buffer_vertex_size, buffer_vertex_size / 3, buffer_colors_size, buffer_colors_size / 3,
|
||||||
|
buffer_lines_size, buffer_lines_size / 2, buffer_plans_size, buffer_plans_size / 3, model_space_size_x);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Initializes the buffer of a gl_area
|
/* Initializes the buffer of a gl_area
|
||||||
* Calls according to the user preferences
|
* Calls according to the user preferences
|
||||||
* @param gl_area, ptr to the gl_area widget
|
* @param gl_area, ptr to the gl_area widget
|
||||||
* Note : line_ndx[] is no more defined in graphics_cube.h
|
* Note : buffer_lines_origin[] is no more defined in graphics_cube.h
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
#define A 0
|
#define A 0
|
||||||
|
@ -555,70 +625,55 @@ void graphics_init_buffers(const void *gl_area)
|
||||||
entry = find_entry_from_ptr(gl_area);
|
entry = find_entry_from_ptr(gl_area);
|
||||||
|
|
||||||
get_model_data_and_user_preferences();
|
get_model_data_and_user_preferences();
|
||||||
compute_vertex_colors_lines_plans_nb(dim, state_size, arrows_nb,
|
/* une struct en retour pour ne plus utiliser de variables globales ? */
|
||||||
pref_3D_xor_2D_space,
|
|
||||||
pref_3D_xor_2D_arrows,
|
|
||||||
pref_mark_unit_space_zero,
|
|
||||||
entry);
|
|
||||||
|
|
||||||
// g_malloc
|
compute_buffers_sizes (model_space_size_x,
|
||||||
vertex_base = g_malloc0(vertex_nb * sizeof(GLfloat) * 2);
|
model_space_size_y,
|
||||||
color_base = g_malloc0(colors_nb * sizeof(GLfloat) * 2);
|
model_space_size_z,
|
||||||
line_ndx = g_malloc0(lines_nb * 2 * sizeof(GLubyte) * 2);
|
|
||||||
plan_ndx = g_malloc0(plans_nb * 3 * sizeof(GLubyte) * 2);
|
|
||||||
|
|
||||||
|
model_arrows_nb,
|
||||||
|
|
||||||
int vgap = 0, igap = 0, cgap = 0, dgap = 0;
|
pref_3D_xor_2D_space,
|
||||||
|
pref_3D_xor_2D_arrows,
|
||||||
|
pref_mark_unit_space,
|
||||||
|
pref_style_lines_planes,
|
||||||
|
pref_style_mix_colors);
|
||||||
|
|
||||||
if (pref_mark_unit_space_zero) dgap = 4; // 4 vertices for 2 diagonal lines
|
buffer_vertex_origin = g_malloc0(buffer_vertex_size * sizeof(GLfloat) * 2);
|
||||||
vgap += (6 * state_size);
|
buffer_colors_origin = g_malloc0(buffer_colors_size * sizeof(GLfloat) * 2);
|
||||||
igap += state_size * 2 + dgap;
|
buffer_lines_origin = g_malloc0(buffer_lines_size * 2 * sizeof(GLubyte) * 2);
|
||||||
cgap += (6 * state_size);
|
buffer_plans_origin = g_malloc0(buffer_plans_size * 3 * sizeof(GLubyte) * 2);
|
||||||
|
|
||||||
if (pref_3D_xor_2D_space) compute_space_2D(state_size,
|
compute_space_and_arrows (model_space_size_x,
|
||||||
vertex_base, color_base,
|
model_space_size_y,
|
||||||
line_ndx,
|
model_space_size_z,
|
||||||
pref_mark_unit_space_zero, dgap);
|
|
||||||
|
|
||||||
else compute_space_3D(state_size,
|
arrows,
|
||||||
vertex_base, color_base,
|
model_arrows_nb,
|
||||||
line_ndx,
|
|
||||||
pref_mark_unit_space_zero, dgap);
|
|
||||||
|
|
||||||
for (int k = 0; k < state_size; k++){
|
pref_3D_xor_2D_space,
|
||||||
assert(k * 12 < vertex_nb); assert(k * 12 + 11 < vertex_nb);
|
pref_3D_xor_2D_arrows,
|
||||||
assert(k * 12 < colors_nb); assert(k * 12 + 11 < colors_nb);
|
pref_mark_unit_space,
|
||||||
assert(k + 8 < entry->line_indices_nb); assert(k + 16 < entry->line_indices_nb);
|
pref_style_lines_planes,
|
||||||
}
|
pref_style_mix_colors,
|
||||||
|
|
||||||
assert(vgap < vertex_nb); assert(vgap + 9 < vertex_nb);
|
buffer_vertex_origin,
|
||||||
assert(igap < entry->line_indices_nb); assert(igap + 5 < entry->line_indices_nb);
|
buffer_colors_origin,
|
||||||
|
buffer_lines_origin,
|
||||||
|
buffer_plans_origin);
|
||||||
/* compute_arrow_3D(state_size, */
|
|
||||||
/* vertex_base, color_base, */
|
|
||||||
/* line_ndx, plan_ndx, */
|
|
||||||
/* vgap, igap, cgap, */
|
|
||||||
/* 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; */
|
|
||||||
|
|
||||||
GLuint vao, vertex_buffer, color_buffer;
|
GLuint vao, vertex_buffer, color_buffer;
|
||||||
|
|
||||||
glGenBuffers(1, &vertex_buffer);
|
glGenBuffers(1, &vertex_buffer);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer);
|
glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer);
|
||||||
glBufferData(GL_ARRAY_BUFFER, vertex_nb * sizeof(vertex_base[0]), vertex_base, GL_STATIC_DRAW);
|
glBufferData(GL_ARRAY_BUFFER, buffer_vertex_size * sizeof(buffer_vertex_origin[0]), buffer_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, colors_nb * sizeof(color_base), color_base, GL_STATIC_DRAW);
|
glBufferData(GL_ARRAY_BUFFER, buffer_colors_size * sizeof(buffer_colors_origin), buffer_colors_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
|
||||||
|
@ -667,7 +722,8 @@ void graphics_draw(const void *gl_area)
|
||||||
/* Use our shaders */
|
/* Use our shaders */
|
||||||
glUseProgram(entry->program);
|
glUseProgram(entry->program);
|
||||||
|
|
||||||
glClearColor(0, 0, 0, 0.2f); // glClearColor(0.3f, 0, 0, 0.8f);
|
if (pref_style_mix_colors == 0) glClearColor(0, 0, 0, 0.4f);
|
||||||
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
/* Update the "mvp" matrix we use in the shader */
|
/* Update the "mvp" matrix we use in the shader */
|
||||||
|
@ -687,8 +743,8 @@ void graphics_draw(const void *gl_area)
|
||||||
|
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
|
||||||
glDrawElements(GL_LINES, entry->line_indices_nb, GL_UNSIGNED_BYTE, line_ndx);
|
glDrawElements(GL_LINES, buffer_lines_size, GL_UNSIGNED_BYTE, buffer_lines_origin);
|
||||||
glDrawElements(GL_TRIANGLES, entry->plan_indices_nb, GL_UNSIGNED_BYTE, plan_ndx);
|
glDrawElements(GL_TRIANGLES, buffer_plans_size, GL_UNSIGNED_BYTE, buffer_plans_origin);
|
||||||
|
|
||||||
/* We finished using the buffers and program */
|
/* We finished using the buffers and program */
|
||||||
glDisableVertexAttribArray(0);
|
glDisableVertexAttribArray(0);
|
|
@ -1,83 +0,0 @@
|
||||||
/*
|
|
||||||
* 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_2D(int state_size,
|
|
||||||
GLfloat *vertex_base, GLfloat *color_base,
|
|
||||||
GLubyte *line_ndx,
|
|
||||||
bool pref_mark_unit_space_zero, int dgap){
|
|
||||||
|
|
||||||
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 * 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++) *(line_ndx + k + 4) = k;
|
|
||||||
|
|
||||||
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 (pref_mark_unit_space_zero) { // diagonales pour marquer la case zéro
|
|
||||||
*(line_ndx + state_size * 2 + 6 + dgap + 0) = 0;
|
|
||||||
*(line_ndx + state_size * 2 + 6 + dgap + 1) = 3;
|
|
||||||
*(line_ndx + state_size * 2 + 6 + dgap + 2) = 1;
|
|
||||||
*(line_ndx + state_size * 2 + 6 + dgap + 3) = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (I) printf(" n = 4 + (%d x 2)\n", state_size + 2);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,156 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 1
|
|
||||||
#define EDGE 0.999999
|
|
||||||
|
|
||||||
bool compute_space_3D(int state_size,
|
|
||||||
GLfloat *vertex_base, GLfloat *color_base,
|
|
||||||
GLubyte *line_ndx,
|
|
||||||
bool pref_mark_unit_space_zero, int dgap){
|
|
||||||
|
|
||||||
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) = 1 - (k / state_size);
|
|
||||||
*(color_base + k * 12 + 1) = 0.2f;
|
|
||||||
*(color_base + k * 12 + 2) = (k / state_size);
|
|
||||||
|
|
||||||
*(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 + 6) = 0.8f;
|
|
||||||
*(color_base + k * 12 + 7) = (k / state_size);
|
|
||||||
*(color_base + k * 12 + 8) = 0.2f;
|
|
||||||
|
|
||||||
*(color_base + k * 12 + 9) = 1 - (k / state_size);
|
|
||||||
*(color_base + k * 12 + 10) = 0.2f;
|
|
||||||
*(color_base + k * 12 + 11) = 0.9f;
|
|
||||||
|
|
||||||
// if (k == 0) for (int j = 0; j < 12; j++) *(color_base + j) = 0.2f;
|
|
||||||
|
|
||||||
/* 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pref_mark_unit_space_zero) {
|
|
||||||
|
|
||||||
*(line_ndx + (2 + state_size) * 8 - 4) = 0 + 0; // diagonales pour marquer la case zéro
|
|
||||||
*(line_ndx + (2 + state_size) * 8 - 3) = 0 + 1;
|
|
||||||
|
|
||||||
*(line_ndx + (2 + state_size) * 8 - 2) = 0 + 2; // diagonales pour marquer la case zéro
|
|
||||||
*(line_ndx + (2 + state_size) * 8 - 1) = 0 + 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (I) printf("line_ndx ");
|
|
||||||
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) dgap = %d\n", state_size + 2, dgap);
|
|
||||||
if (I) printf("pref_mark_unit_space_zero = %d ", pref_mark_unit_space_zero);
|
|
||||||
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -12,5 +12,6 @@ out vec4 color;
|
||||||
void main(void)
|
void main(void)
|
||||||
{
|
{
|
||||||
gl_Position = projection_matrix * view_matrix * model_matrix * vec4(in_position, 1);
|
gl_Position = projection_matrix * view_matrix * model_matrix * vec4(in_position, 1);
|
||||||
color = vec4(1 * in_color.rgb, 0.2f);
|
color = vec4(1 * in_color.rgb, 1);
|
||||||
|
// color = vec4(1 * in_color.rgb, 0.2f);
|
||||||
}
|
}
|
|
@ -25,7 +25,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "../../include/base.h"
|
#include "../../include/base.h"
|
||||||
#include "../../include/graphics_control.h"
|
#include "../../include/graphics.h"
|
||||||
#include "../../include/ui.h"
|
#include "../../include/ui.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue