First 3D representation
Space units are 3D, arrows are 3D, space can be 3D/2D/1D. Every dimension length can be defined independently. At this time, arrows are drawn after a statically-defined array. Signed-off-by: Jean Sirmai <jean@a-lec.org>
This commit is contained in:
parent
f32fa02299
commit
bdad3857a9
|
@ -0,0 +1,46 @@
|
||||||
|
L'utilisation d'OpenGL fait que la première version de Gem-graph sera tout naturellement en 3D. Le modèle de marche aléatoire de dimères sera aussi facile à y réaliser que dans un modèle 1D (on pourrait même se servir d'une seule règle au lieu de deux !) (mais deux règles permettront un meilleur rendu).
|
||||||
|
|
||||||
|
Modifier la forme des flèches ?
|
||||||
|
Pour cette première version, la forme "central star" + "cône" a l'avantage de la simplicité.
|
||||||
|
La "central star" de chaque cube est commune aux six flèches possibles qui sont orientées chacune vers une face différente.
|
||||||
|
Dans la version actuelle, elle est redessinée si plusieurs flèches sont dans le même cube.
|
||||||
|
Ce dessin est peu coûteux (deux lignes superposées pour chaque nouvelle flèche)
|
||||||
|
et ce cas (plusieurs flèches dans le même cube) sera peu fréquent dans les premiers modèles développés. Mais... TODO
|
||||||
|
|
||||||
|
Le plus simple serait un trait allant du centre d'un cube au centre d'une de ses faces. Ce serait peu lisible pour des objets mais pourrait avoir un intérêt pour les tags (balises) éventuellement associés aux objets ou situations. Ces tags seraient machine-readable. Nécessairement. Seraient-ils human-readable aussi ? Ce serait idéal ! A inventer ou essayer, en tout cas.
|
||||||
|
Un seul trait aurait sûrement un intérêt dans la représentation de voisinages de Moore 3D (Je préfère ne pas imaginer ça pour l'instant ! Il va falloir choisir de ne représenter ou de ne visualiser qu'une partie des connexions à la fois...).
|
||||||
|
|
||||||
|
Le premier objectif des versions à venir est l'extension du voisinage. Un voisinage type von Neumann 3D - le plus simple possible si on le veut symétrique par rapport aux axes de l'espace - est tout à fait indiqué pour cette première version. Mais les versions à venir devraient travailler en priorité avec des voisinages type Moore 3D approximativement spériques de rayon proche de celui de l'espace local.
|
||||||
|
Par ailleurs, Gem-graph ne peut avoir sa puissance théorique maximale que s'il peut utiliser un voisinage étendu à tout l'espace. Mais cette puissance est vraisemblablement inutile, sauf pour les démonstrations mathématiques d'équivalence avec les automates cellulaires, par exemple, ou d'autres formalismes.
|
||||||
|
Par ailleurs, il est d'ores et déjà possible d'utiliser pleinement le "poids" (weight) ou la "charge" (load) des flèches.
|
||||||
|
|
||||||
|
! WARNING ! J'ai inversé pôle Nord et pôle Sud. Et c'est à corriger, je pense. 👀️
|
||||||
|
Ce sera une convention, bien sûr. Mais comment la choisir ? J'ai imaginé superposer repère orthonormé et repère géodésique.
|
||||||
|
Si je regarde un repère orthonormé 3D:
|
||||||
|
les +x sont à ma droite, les -x à ma gauche (Est - Ouest)
|
||||||
|
les +y en haut, les -y en bas (Zénith - Nadir) et... si l'axe des z vient vers moi,
|
||||||
|
les +z sont derrière moi et les -z devant. Donc les -z sont au Nord (que je regarde) et les +z sont au Sud.
|
||||||
|
|
||||||
|
Les vertex situés aux intersections des "grilles" (X-X, Y-Y et Z-Z) sont-ils utiles ?
|
||||||
|
Ils le seraient si ses cubes individuels étaient coloriés ou soulignés pour mettre en valeur des flèches qu'ils contiennent ou d'autres particularités.
|
||||||
|
Mais tant qu'il n'est pas possible de rendre sélectivement transparentes les parois de cubes individuels (ou de tel ou tel objet dessiné par les flèches), cette fonction est inutilisable et les vertex situés aux intersections des grilles sont donc inutiles.
|
||||||
|
On pourrait ne garder que ceux situés sur les faces de l'espace qui, eux, servent à tracer les grilles X-X, Y-Y et Z-Z.
|
||||||
|
Le nombre de vertex de l'espace serait alors de 12 par cube-unité (soit 12 * x * y * z) plus les vertex intersections des seules faces de l'espace (soit (x * y + x * z + y * z) * 2).
|
||||||
|
A raison, bien sûr de trois nombres par vertex plus les couleurs.
|
||||||
|
|
||||||
|
Je comprends (maintenant seulement !) que si des régions du buffer lignes (idem pour le buffer triangles) sont laissées vides (occupées par des zéros) elles seront néanmoins redessinées en permanence et que le seul moyen d'éviter cela est de réallouer la taille du buffer à chaque délétion ou chaque ajout de flèche.
|
||||||
|
|
||||||
|
Néanmoins, lorsque le nombre de flèches présent dans l'espace est invariant, - cas de mes premiers modèles - il peut être avantageux de travailler dans un buffer de taille fixe. Il faut, pour cela, fixer une "densité maximale de flèches dans l'espace" nécessairement arbitraire.
|
||||||
|
Bien que ce nombre reste toujours arbitraire, on peut estimer que certaines de ses valeurs seront plus utiles/utilisables que d'autres :
|
||||||
|
- un espace totalement vide ou totalement saturé ne pourrait rien représenter
|
||||||
|
- un espace trop vide ou trop plein (à définir - c'est intuitif) aurait peu de chances de représenter des phénomènes intéressants. La marche aléatoire d'un seul ou de quelques dimères dans un grand espace, par exemple, servira plus de test pour le bon fonctionnement de Gem-graph que de modèle d'étude.
|
||||||
|
- on peut considérer un espace rempli de flèches aux 2/3 comme équivalent à un espace repli au tiers (1/3) mais où les flèches seraient écrites "en creux" et, par conséquent, moins lisibles. Inutile, donc, de remplir plus de la moitié de l'espace.
|
||||||
|
D'expérience,
|
||||||
|
- les densités de l'ordre du tiers (1/3 des unités de l'espace occupées par au moins une flèche) suffisent à représenter un nombre de phénomènes tel qu'il n'est pas nécessaire, au moins dans un premier temps, de prévoir davantage (mais des réalloc sont toujours possibles) et les densités trop fortes sont peu lisibles.
|
||||||
|
Un buffer lignes pourrait donc avoir une taille fixe qui serait calculée selon les paramètres suivants :
|
||||||
|
- x * y * z = nombre de cubes
|
||||||
|
- nombre de flèches moyen par cube = 2 (il s'agit d'un nombre "moyen" qui surestime très probablement le nombre de flèches utilisé par la plupart des modèles)
|
||||||
|
- dessin d'une flèche seule dans un cube = 3 + 4 traits (soit 14 nombres)
|
||||||
|
Faut-il coder cette option ?
|
||||||
|
|
||||||
|
|
|
@ -26,22 +26,23 @@
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <GL/glu.h>
|
#include <GL/glu.h>
|
||||||
|
|
||||||
bool compute_space_and_arrows(int model_space_size_x,
|
bool compute_space_and_arrows(long model_space_size_x,
|
||||||
int model_space_size_y,
|
long model_space_size_y,
|
||||||
int model_space_size_z,
|
long model_space_size_z,
|
||||||
|
|
||||||
GLubyte *arrows,
|
GLuint *arrows,
|
||||||
int model_arrows_nb,
|
int model_arrows_nb,
|
||||||
|
|
||||||
int pref_3D_xor_2D_space,
|
// int pref_mark_unit_space,
|
||||||
int pref_3D_xor_2D_arrows,
|
// int pref_style_lines_planes,
|
||||||
int pref_mark_unit_space,
|
// int pref_style_mix_colors,
|
||||||
int pref_style_lines_planes,
|
int pref_show_grid,
|
||||||
int pref_style_mix_colors,
|
int pref_test_diagonal,
|
||||||
|
|
||||||
GLfloat *vertex_origin,
|
GLfloat *vertex_origin,
|
||||||
GLfloat *color_origin,
|
GLfloat *color_origin,
|
||||||
GLubyte *line_origin,
|
GLuint *line_origin,
|
||||||
GLubyte *plan_origin);
|
GLuint *plan_origin);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,362 +0,0 @@
|
||||||
/*
|
|
||||||
* 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^RQJn||lpv)=à)o -----------------------------------------------------
|
|
||||||
*
|
|
||||||
* 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/base.h"
|
|
||||||
#include "../../include/ui.h"
|
|
||||||
#include "../../include/graphics.h"
|
|
||||||
#include "../../include/buffers.h"
|
|
||||||
#include "../../include/space_2D.h"
|
|
||||||
#include "../../include/space_3D.h"
|
|
||||||
#include "../../include/arrow_2D.h"
|
|
||||||
#include "../../include/arrow_3D.h"
|
|
||||||
|
|
||||||
#define A 0
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
/// struct gl_area_entry *entry;
|
|
||||||
/// GLuint vao, vertex_buffer, color_buffer;
|
|
||||||
int vgap = 0, igap = 0, pgap = 0, cgap = 0;
|
|
||||||
|
|
||||||
/// entry = find_entry_from_ptr(gl_area);
|
|
||||||
|
|
||||||
// {1, 1, 0, 1, 2, 1, 1, 1, 10, 1, 2, 11, 1, 1, 20, 1, 2, 21}; < from model.xml
|
|
||||||
dim = 1;
|
|
||||||
state_size = 7; // 2 < state_size < 32
|
|
||||||
arrows_nb = 4; // assert : leur emplacement doit être fonction de state_size
|
|
||||||
|
|
||||||
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); // cas 2D
|
|
||||||
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
|
|
||||||
|
|
||||||
line_indices_nb = lines_nb * 2;
|
|
||||||
|
|
||||||
printf("Initialization of buffers with %u line_ndx, %u vertices and %u colors & state_size = %d\n",
|
|
||||||
line_indices_nb, vertex_nb, colors_nb, state_size);
|
|
||||||
|
|
||||||
// g_malloc
|
|
||||||
// vertex_base = g_malloc0(vertex_nb * sizeof(GLfloat) * 2);
|
|
||||||
// color_base = g_malloc0(colors_nb * sizeof(GLfloat) * 2);
|
|
||||||
// line_ndx = g_malloc0(lines_nb * 2 * sizeof(GLubyte) * 2);
|
|
||||||
//// 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);
|
|
||||||
|
|
||||||
*(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;
|
|
||||||
|
|
||||||
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 < line_indices_nb); assert(k + 16 < line_indices_nb);
|
|
||||||
}
|
|
||||||
|
|
||||||
compute_space_3D(state_size, vertex_base, color_base, line_ndx,
|
|
||||||
0,0); // patch provisoire
|
|
||||||
// pref_mark_unit_space_zero, dgap){
|
|
||||||
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, 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, 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 < line_indices_nb); assert(igap + 5 < line_indices_nb);
|
|
||||||
|
|
||||||
|
|
||||||
compute_arrow_3D(state_size,
|
|
||||||
vertex_base, color_base,
|
|
||||||
line_ndx, 0, // plan_ndx,
|
|
||||||
vgap, igap, cgap,
|
|
||||||
1, 0, 0, 0, 0);
|
|
||||||
vgap += 15; igap += 16; cgap += 15; ++arrows_nb;
|
|
||||||
|
|
||||||
compute_arrow_3D(state_size,
|
|
||||||
vertex_base, color_base,
|
|
||||||
line_ndx, 0, // plan_ndx,
|
|
||||||
vgap, igap, cgap,
|
|
||||||
1, 1, 2, 0, 0);
|
|
||||||
vgap += 15; igap += 16; cgap += 15; ++arrows_nb;
|
|
||||||
|
|
||||||
compute_arrow_3D(state_size,
|
|
||||||
vertex_base, color_base,
|
|
||||||
line_ndx, 0, // plan_ndx,
|
|
||||||
vgap, igap, cgap,
|
|
||||||
1, 0, 3, 0, 0);
|
|
||||||
vgap += 15; igap += 16; cgap += 15; ++arrows_nb;
|
|
||||||
|
|
||||||
compute_arrow_3D(state_size,
|
|
||||||
vertex_base, color_base,
|
|
||||||
line_ndx, 0, // plan_ndx,
|
|
||||||
vgap, igap, cgap,
|
|
||||||
1, 1, 3, 0, 0);
|
|
||||||
vgap += 15; igap += 16; cgap += 15; ++arrows_nb;
|
|
||||||
|
|
||||||
return line_indices_nb;
|
|
||||||
|
|
||||||
/* compute_arrow_3D(state_size, */
|
|
||||||
/* vertex_base, color_base, */
|
|
||||||
/* line_ndx, plan_ndx, */
|
|
||||||
/* vgap, igap, cgap, */
|
|
||||||
/* 1, 0, state_size - 2, 0, 0); */
|
|
||||||
/* vgap += 15; igap += 16; cgap += 15; ++arrows_nb; */
|
|
||||||
|
|
||||||
/* compute_arrow_3D(state_size, */
|
|
||||||
/* vertex_base, color_base, */
|
|
||||||
/* line_ndx, plan_ndx, */
|
|
||||||
/* vgap, igap, cgap, */
|
|
||||||
/* 1, 1, state_size - 2, 0, 0); */
|
|
||||||
/* vgap += 15; igap += 16; cgap += 15; ++arrows_nb; */
|
|
||||||
|
|
||||||
/// glGenBuffers(1, &vertex_buffer);
|
|
||||||
/// glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer);
|
|
||||||
/// glBufferData(GL_ARRAY_BUFFER, vertex_nb * sizeof(vertex_base[0]), vertex_base, GL_STATIC_DRAW);
|
|
||||||
/// glBindBuffer(GL_ARRAY_BUFFER, 0);
|
|
||||||
|
|
||||||
|
|
||||||
// colors
|
|
||||||
/// glGenBuffers(1, &color_buffer);
|
|
||||||
/// glBindBuffer(GL_ARRAY_BUFFER, color_buffer);
|
|
||||||
/// glBufferData(GL_ARRAY_BUFFER, colors_nb * sizeof(color_base), color_base, GL_STATIC_DRAW);
|
|
||||||
/// glBindBuffer(GL_ARRAY_BUFFER, 0);
|
|
||||||
|
|
||||||
// We only use one VAO, so we always keep it bound
|
|
||||||
/// glGenVertexArrays(1, &vao);
|
|
||||||
/// glBindVertexArray(vao);
|
|
||||||
|
|
||||||
/// if(entry != NULL) {
|
|
||||||
/// entry->vao = vao;
|
|
||||||
/// entry->position_buffer = vertex_buffer;
|
|
||||||
/// entry->color_buffer = color_buffer;
|
|
||||||
/// }
|
|
||||||
}
|
|
||||||
|
|
||||||
#define A 0
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
/// int line_indices_nb = 0; // AD HOC !
|
|
||||||
/// struct gl_area_entry *entry;
|
|
||||||
/// GLuint vao, vertex_buffer, color_buffer;
|
|
||||||
int vgap = 0, igap = 0, pgap = 0, cgap = 0;
|
|
||||||
|
|
||||||
/// entry = find_entry_from_ptr(gl_area);
|
|
||||||
|
|
||||||
// {1, 1, 0, 1, 2, 1, 1, 1, 10, 1, 2, 11, 1, 1, 20, 1, 2, 21}; < from model.xml
|
|
||||||
dim = 1;
|
|
||||||
state_size = 7; // 2 < state_size < 32
|
|
||||||
arrows_nb = 4; // assert : leur emplacement doit être fonction de state_size
|
|
||||||
|
|
||||||
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); // 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
|
|
||||||
|
|
||||||
//// plan_indices_nb = plans_nb * 3;
|
|
||||||
|
|
||||||
printf("Initialization of buffers with %u plan_ndx, %u vertices and %u colors & state_size = %d\n",
|
|
||||||
plan_indices_nb, vertex_nb, colors_nb, state_size);
|
|
||||||
|
|
||||||
// g_malloc
|
|
||||||
//// vertex_base = g_malloc0(vertex_nb * sizeof(GLfloat) * 2);
|
|
||||||
//// color_base = g_malloc0(colors_nb * sizeof(GLfloat) * 2);
|
|
||||||
//// line_ndx = g_malloc0(lines_nb * 2 * sizeof(GLubyte) * 2);
|
|
||||||
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);
|
|
||||||
|
|
||||||
/* *(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; */
|
|
||||||
|
|
||||||
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 < line_indices_nb); assert(k + 16 < line_indices_nb);
|
|
||||||
|
|
||||||
compute_space_3D(state_size, vertex_base, color_base, plan_ndx,
|
|
||||||
0,0); // patch provisoire
|
|
||||||
//pref_mark_unit_space_zero, dgap){
|
|
||||||
|
|
||||||
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, 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, 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 < line_indices_nb); assert(igap + 5 < line_indices_nb);
|
|
||||||
|
|
||||||
|
|
||||||
/* compute_arrow_3D(state_size, */
|
|
||||||
/* vertex_base, color_base, */
|
|
||||||
/* line_ndx, 0, // plan_ndx, */
|
|
||||||
/* vgap, igap, cgap, */
|
|
||||||
/* 1, 0, 0, 0, 0); */
|
|
||||||
/* vgap += 15; igap += 16; cgap += 15; ++arrows_nb; */
|
|
||||||
|
|
||||||
/* compute_arrow_3D(state_size, */
|
|
||||||
/* vertex_base, color_base, */
|
|
||||||
/* line_ndx, 0, // plan_ndx, */
|
|
||||||
/* vgap, igap, cgap, */
|
|
||||||
/* 1, 1, 2, 0, 0); */
|
|
||||||
/* vgap += 15; igap += 16; cgap += 15; ++arrows_nb; */
|
|
||||||
|
|
||||||
/* compute_arrow_3D(state_size, */
|
|
||||||
/* vertex_base, color_base, */
|
|
||||||
/* line_ndx, 0, // plan_ndx, */
|
|
||||||
/* vgap, igap, cgap, */
|
|
||||||
/* 1, 0, 3, 0, 0); */
|
|
||||||
/* vgap += 15; igap += 16; cgap += 15; ++arrows_nb; */
|
|
||||||
|
|
||||||
/* compute_arrow_3D(state_size, */
|
|
||||||
/* vertex_base, color_base, */
|
|
||||||
/* line_ndx, 0, // plan_ndx, */
|
|
||||||
/* vgap, igap, cgap, */
|
|
||||||
/* 1, 1, 3, 0, 0); */
|
|
||||||
/* vgap += 15; igap += 16; cgap += 15; ++arrows_nb; */
|
|
||||||
|
|
||||||
return plan_indices_nb;
|
|
||||||
|
|
||||||
/* compute_arrow_3D(state_size, */
|
|
||||||
/* vertex_base, color_base, */
|
|
||||||
/* line_ndx, plan_ndx, */
|
|
||||||
/* vgap, igap, cgap, */
|
|
||||||
/* 1, 0, state_size - 2, 0, 0); */
|
|
||||||
/* vgap += 15; igap += 16; cgap += 15; ++arrows_nb; */
|
|
||||||
|
|
||||||
/* compute_arrow_3D(state_size, */
|
|
||||||
/* vertex_base, color_base, */
|
|
||||||
/* line_ndx, plan_ndx, */
|
|
||||||
/* vgap, igap, cgap, */
|
|
||||||
/* 1, 1, state_size - 2, 0, 0); */
|
|
||||||
/* vgap += 15; igap += 16; cgap += 15; ++arrows_nb; */
|
|
||||||
|
|
||||||
/// glGenBuffers(1, &vertex_buffer);
|
|
||||||
/// glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer);
|
|
||||||
/// glBufferData(GL_ARRAY_BUFFER, vertex_nb * sizeof(vertex_base[0]), vertex_base, GL_STATIC_DRAW);
|
|
||||||
/// glBindBuffer(GL_ARRAY_BUFFER, 0);
|
|
||||||
|
|
||||||
|
|
||||||
// colors
|
|
||||||
/// glGenBuffers(1, &color_buffer);
|
|
||||||
/// glBindBuffer(GL_ARRAY_BUFFER, color_buffer);
|
|
||||||
/// glBufferData(GL_ARRAY_BUFFER, colors_nb * sizeof(color_base), color_base, GL_STATIC_DRAW);
|
|
||||||
/// glBindBuffer(GL_ARRAY_BUFFER, 0);
|
|
||||||
|
|
||||||
// We only use one VAO, so we always keep it bound
|
|
||||||
/// glGenVertexArrays(1, &vao);
|
|
||||||
/// glBindVertexArray(vao);
|
|
||||||
|
|
||||||
/// if(entry != NULL) {
|
|
||||||
/// entry->vao = vao;
|
|
||||||
/// entry->position_buffer = vertex_buffer;
|
|
||||||
/// entry->color_buffer = color_buffer;
|
|
||||||
/// }
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -43,7 +43,6 @@
|
||||||
|
|
||||||
#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
|
|
||||||
|
|
||||||
/* ----------------- V A R I A B L E S G L O B A L E S ------------------ */
|
/* ----------------- V A R I A B L E S G L O B A L E S ------------------ */
|
||||||
|
|
||||||
|
@ -52,17 +51,20 @@ int model_space_size_x = 0;
|
||||||
int model_space_size_y = 0;
|
int model_space_size_y = 0;
|
||||||
int model_space_size_z = 0;
|
int model_space_size_z = 0;
|
||||||
int model_arrows_nb = 0;
|
int model_arrows_nb = 0;
|
||||||
|
int nombre_de_cases_contenant_des_fleches = 0;
|
||||||
|
|
||||||
GLfloat *buffer_vertex_origin = NULL;
|
GLfloat *buffer_vertex_origin = NULL;
|
||||||
GLfloat *buffer_colors_origin = NULL;
|
GLfloat *buffer_colors_origin = NULL;
|
||||||
GLubyte *buffer_lines_origin = NULL;
|
GLuint *buffer_lines_origin = NULL;
|
||||||
GLubyte *buffer_plans_origin = NULL;
|
GLuint *buffer_plans_origin = NULL;
|
||||||
|
|
||||||
int pref_3D_xor_2D_space = 0; // default view == 0 == 3D
|
//int pref_3D_xor_2D_space = 0; // default view == 0 == 3D
|
||||||
int pref_3D_xor_2D_arrows = 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_mark_unit_space = 0; // default == 0 == no marks
|
||||||
int pref_style_lines_planes = 0; // arrows as lines = 0, as planes = 1
|
//int pref_style_lines_planes = 0; // arrows as lines = 0, as planes = 1
|
||||||
int pref_style_mix_colors = 0; // ... don't know yet ...
|
//int pref_style_mix_colors = 0; // ... don't know yet ...
|
||||||
|
int pref_show_grid = 0; // 0, 1, 2, 3, 5, 6, 10, 15, 30, etc
|
||||||
|
int pref_test_diagonal = 0; // diagonal test
|
||||||
|
|
||||||
int buffer_vertex_size = 0;
|
int buffer_vertex_size = 0;
|
||||||
int buffer_colors_size = 0;
|
int buffer_colors_size = 0;
|
||||||
|
@ -425,6 +427,7 @@ bool graphics_init_shaders(const void *gl_area)
|
||||||
return false;
|
return false;
|
||||||
vertex = create_shader(GL_VERTEX_SHADER, vertex_shader);
|
vertex = create_shader(GL_VERTEX_SHADER, vertex_shader);
|
||||||
|
|
||||||
|
// ! WARNING ! l'instruction suivante (ou un autre 'free') a pu provoquer un 'double free' (Abandon)
|
||||||
if(vertex == 0) {
|
if(vertex == 0) {
|
||||||
entry->program = 0;
|
entry->program = 0;
|
||||||
g_free(vertex_shader);
|
g_free(vertex_shader);
|
||||||
|
@ -521,21 +524,61 @@ bool graphics_init_shaders(const void *gl_area)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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(){
|
||||||
|
|
||||||
model_space_size_x = 11; // 2 < model_space_size_x < 32
|
|
||||||
model_arrows_nb = 6; // assert : l'emplacement des flèches est contraint
|
model_space_size_x = 4; // 0 < model_space_size_x
|
||||||
|
model_space_size_y = 3; // 0 < model_space_size_y
|
||||||
|
model_space_size_z = 3; // 0 < model_space_size_z
|
||||||
|
|
||||||
|
// XXX ONLY space drawed, no arrows yet
|
||||||
|
|
||||||
|
model_arrows_nb = 9; // assert : l'emplacement des flèches est contraint
|
||||||
// par model_space_size_x, y, z et le nombre de sites
|
// par model_space_size_x, y, z et le nombre de sites
|
||||||
pref_3D_xor_2D_space = 0; // 0 = 3D 1 = 2D
|
|
||||||
pref_3D_xor_2D_arrows = 0; // 0 = 3D 1 = 2D
|
nombre_de_cases_contenant_des_fleches = 8; // à calculer TODO
|
||||||
pref_mark_unit_space = 3; // 0 = no marks, 1 = 1st, 2 = last, 3 = both
|
// ! WARNING ! Pour l'instant égal au nombre de flèches ! (central stars réécrites)
|
||||||
pref_style_lines_planes = 0; // 0 = arrows as lines, 1 = as planes, 2 = mix
|
nombre_de_cases_contenant_des_fleches = model_arrows_nb;
|
||||||
pref_style_mix_colors = 0; // TODO
|
|
||||||
|
// pref_mark_unit_space = 0; // 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
|
||||||
|
pref_show_grid = 0; // 0, 1, 2, 3, 5, 6, 10, 15, 30, etc
|
||||||
|
// xyz, 0, x, y, z, xy, xz, yz, xyz
|
||||||
|
pref_test_diagonal = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GLuint arrows[] = {
|
||||||
|
1, 0, 0, 0, 0,
|
||||||
|
1, 1, 1, 0, 0,
|
||||||
|
1, 2, 2, 1, 1,
|
||||||
|
1, 3, 2, 2, 1,
|
||||||
|
1, 4, 3, 0, 1,
|
||||||
|
1, 5, 3, 0, 2,
|
||||||
|
1, 1, 3, 0, 2,
|
||||||
|
1, 0, 2, 0, 2,
|
||||||
|
1, 5, 2, 1, 1,
|
||||||
|
// load, site, x, y, z
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -543,75 +586,92 @@ static void get_model_data_and_user_preferences(){
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define S 1
|
|
||||||
static void compute_buffers_sizes(int model_space_size_x,
|
static void compute_buffers_sizes(int model_space_size_x,
|
||||||
int model_space_size_y,
|
int model_space_size_y,
|
||||||
int model_space_size_z,
|
int model_space_size_z,
|
||||||
|
|
||||||
int model_arrows_nb,
|
int model_arrows_nb,
|
||||||
|
|
||||||
int pref_3D_xor_2D_space,
|
// int pref_mark_unit_space,
|
||||||
int pref_3D_xor_2D_arrows,
|
// int pref_style_lines_planes,
|
||||||
int pref_mark_unit_space,
|
// int pref_style_mix_colors,
|
||||||
int pref_style_lines_planes,
|
int pref_test_diagonal)
|
||||||
int pref_style_mix_colors)
|
|
||||||
{
|
{
|
||||||
int two_ladder_amounts = 4; // 2 parallels to connect 4 vertices
|
// XXX ONLY space and no arrows
|
||||||
|
long grids_intersections = (model_space_size_x + 1)
|
||||||
|
* (model_space_size_y + 1)
|
||||||
|
* (model_space_size_z + 1);
|
||||||
|
|
||||||
if (pref_3D_xor_2D_space) { // 2D the ladder has 2 amounts
|
long arrows_anchors = (model_space_size_x)
|
||||||
buffer_vertex_size = model_space_size_x * 6;
|
* (model_space_size_y)
|
||||||
buffer_colors_size = model_space_size_x * 6;
|
* (model_space_size_z)
|
||||||
buffer_plans_size = 0;
|
* (6 + 6); // 6 is to draw the small central star
|
||||||
buffer_lines_size = model_space_size_x * 2 + two_ladder_amounts;
|
// 6 is for the six faces centers
|
||||||
|
|
||||||
} else { // 3D the ladder has 4 amounts, now
|
long cubes_nb = model_space_size_x * model_space_size_y * model_space_size_z;
|
||||||
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 */
|
buffer_vertex_size = grids_intersections * 3; // 3 numbers per vertex
|
||||||
if (pref_mark_unit_space == 1 || pref_mark_unit_space == 3) buffer_lines_size += 4; // 2 diagonal lines
|
// + cubes_nb * (8 + 6) + 15 * model_arrows_nb;// OLD ARROWS (DEPRECATED)
|
||||||
if (pref_mark_unit_space == 2 || pref_mark_unit_space == 3) buffer_lines_size += 4; // 2 diagonal lines
|
buffer_vertex_size += arrows_anchors * 3;
|
||||||
|
|
||||||
if (pref_3D_xor_2D_arrows) { // 2D
|
buffer_vertex_size += 8 * 3; // draw a small cube
|
||||||
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 */
|
buffer_colors_size = buffer_vertex_size;
|
||||||
|
|
||||||
if (S) printf("allocated buffers sizes :%4d/3 = %3d vertices, %4d/3 = %3d colors,\
|
buffer_plans_size = 3;
|
||||||
%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,
|
long grids_lines =
|
||||||
buffer_lines_size, buffer_lines_size / 2, buffer_plans_size, buffer_plans_size / 3, model_space_size_x);
|
(pref_show_grid % 2 == 0) * (model_space_size_x + 1) * (model_space_size_y + 1)
|
||||||
|
+ (pref_show_grid % 3 == 0) * (model_space_size_x + 1) * (model_space_size_z + 1)
|
||||||
|
+ (pref_show_grid % 5 == 0) * (model_space_size_y + 1) * (model_space_size_z + 1);
|
||||||
|
|
||||||
|
if (pref_show_grid != 1) buffer_lines_size = grids_lines * 2;
|
||||||
|
if (pref_show_grid > 0) buffer_lines_size += 12 * 2; // space ridges
|
||||||
|
// sinon, les arêtes de l'espace sont tracées par les grilles
|
||||||
|
|
||||||
|
if (pref_test_diagonal) buffer_lines_size += 2; // la diagonale test [0 - max]
|
||||||
|
|
||||||
|
buffer_lines_size += 6 * nombre_de_cases_contenant_des_fleches; // test central stars
|
||||||
|
|
||||||
|
buffer_lines_size += 8 * model_arrows_nb; // flèches
|
||||||
|
|
||||||
|
// buffer_lines_size += 16 + 20; // draw a small cube with diagonals
|
||||||
|
|
||||||
|
// buffer_lines_size -= 2; TEST !
|
||||||
|
|
||||||
|
if (1) printf("allocated buffers sizes :%4d/3 = %3d vertices, %4d/3 = %3d colors,\
|
||||||
|
%4d/2 = %3d lines, %4d/3 = %3d plans.\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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* 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
|
||||||
|
@ -633,16 +693,15 @@ void graphics_init_buffers(const void *gl_area)
|
||||||
|
|
||||||
model_arrows_nb,
|
model_arrows_nb,
|
||||||
|
|
||||||
pref_3D_xor_2D_space,
|
// pref_mark_unit_space,
|
||||||
pref_3D_xor_2D_arrows,
|
// pref_style_lines_planes,
|
||||||
pref_mark_unit_space,
|
// pref_style_mix_colors,
|
||||||
pref_style_lines_planes,
|
pref_test_diagonal);
|
||||||
pref_style_mix_colors);
|
|
||||||
|
|
||||||
buffer_vertex_origin = g_malloc0(buffer_vertex_size * sizeof(GLfloat) * 2);
|
buffer_vertex_origin = g_malloc0(buffer_vertex_size * sizeof(GLfloat) * 2);
|
||||||
buffer_colors_origin = g_malloc0(buffer_colors_size * sizeof(GLfloat) * 2);
|
buffer_colors_origin = g_malloc0(buffer_colors_size * sizeof(GLfloat) * 2);
|
||||||
buffer_lines_origin = g_malloc0(buffer_lines_size * 2 * sizeof(GLubyte) * 2);
|
buffer_lines_origin = g_malloc0(buffer_lines_size * 2 * sizeof(GLuint) * 2);
|
||||||
buffer_plans_origin = g_malloc0(buffer_plans_size * 3 * sizeof(GLubyte) * 2);
|
buffer_plans_origin = g_malloc0(buffer_plans_size * 3 * sizeof(GLuint) * 2);
|
||||||
|
|
||||||
compute_space_and_arrows (model_space_size_x,
|
compute_space_and_arrows (model_space_size_x,
|
||||||
model_space_size_y,
|
model_space_size_y,
|
||||||
|
@ -651,11 +710,11 @@ void graphics_init_buffers(const void *gl_area)
|
||||||
arrows,
|
arrows,
|
||||||
model_arrows_nb,
|
model_arrows_nb,
|
||||||
|
|
||||||
pref_3D_xor_2D_space,
|
// pref_mark_unit_space,
|
||||||
pref_3D_xor_2D_arrows,
|
// pref_style_lines_planes,
|
||||||
pref_mark_unit_space,
|
// pref_style_mix_colors,
|
||||||
pref_style_lines_planes,
|
pref_show_grid,
|
||||||
pref_style_mix_colors,
|
pref_test_diagonal,
|
||||||
|
|
||||||
buffer_vertex_origin,
|
buffer_vertex_origin,
|
||||||
buffer_colors_origin,
|
buffer_colors_origin,
|
||||||
|
@ -722,7 +781,8 @@ void graphics_draw(const void *gl_area)
|
||||||
/* Use our shaders */
|
/* Use our shaders */
|
||||||
glUseProgram(entry->program);
|
glUseProgram(entry->program);
|
||||||
|
|
||||||
if (pref_style_mix_colors == 0) glClearColor(0, 0, 0, 0.4f);
|
// 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);
|
||||||
|
|
||||||
|
@ -741,10 +801,10 @@ void graphics_draw(const void *gl_area)
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, entry->color_buffer);
|
glBindBuffer(GL_ARRAY_BUFFER, entry->color_buffer);
|
||||||
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0,(void*)0);
|
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0,(void*)0);
|
||||||
|
|
||||||
glEnable(GL_DEPTH_TEST);
|
//glEnable(GL_DEPTH_TEST);
|
||||||
|
|
||||||
glDrawElements(GL_LINES, buffer_lines_size, GL_UNSIGNED_BYTE, buffer_lines_origin);
|
glDrawElements(GL_LINES, buffer_lines_size, GL_UNSIGNED_INT, buffer_lines_origin);
|
||||||
glDrawElements(GL_TRIANGLES, buffer_plans_size, GL_UNSIGNED_BYTE, buffer_plans_origin);
|
glDrawElements(GL_TRIANGLES, buffer_plans_size, GL_UNSIGNED_INT, buffer_plans_origin);
|
||||||
|
|
||||||
/* We finished using the buffers and program */
|
/* We finished using the buffers and program */
|
||||||
glDisableVertexAttribArray(0);
|
glDisableVertexAttribArray(0);
|
||||||
|
@ -755,3 +815,10 @@ void graphics_draw(const void *gl_area)
|
||||||
glFlush();
|
glFlush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,394 @@
|
||||||
|
/*
|
||||||
|
* Gem-graph OpenGL experiments
|
||||||
|
*
|
||||||
|
* Desc: OpenGL utils header
|
||||||
|
*
|
||||||
|
* Copyright (C) 2023 Jean Sirmai <jean@a-lec.org>
|
||||||
|
*
|
||||||
|
* This file was part of Gem-graph. Forget it now.
|
||||||
|
*
|
||||||
|
* 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"
|
||||||
|
|
||||||
|
static long vertex_index = 0;
|
||||||
|
static long colors_index = 0;
|
||||||
|
static long lines_index = 0;
|
||||||
|
static long plans_index = 0;
|
||||||
|
|
||||||
|
|
||||||
|
#define V 0
|
||||||
|
|
||||||
|
static bool compute_space_2D(int size_x,
|
||||||
|
int size_y,
|
||||||
|
int size_z,
|
||||||
|
|
||||||
|
int pref_mark_unit_space,
|
||||||
|
int pref_style_lines_planes,
|
||||||
|
int pref_style_mix_colors,
|
||||||
|
|
||||||
|
GLfloat *vertex_origin,
|
||||||
|
GLfloat *colors_origin,
|
||||||
|
GLuint *lines_origin,
|
||||||
|
GLuint *plans_origin)
|
||||||
|
{
|
||||||
|
|
||||||
|
float x = 0;
|
||||||
|
// for (int k = 0; k < 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 (V) printf("space_2D vertex ");
|
||||||
|
for (int k = 0; k < size_x; k++){ // barres verticales
|
||||||
|
//
|
||||||
|
x = ((size_x % 2) * (size_x / 2 - k)
|
||||||
|
+ (size_x % 2 - 1) * (k + 0.5f - size_x / 2)) / size_x * 2;
|
||||||
|
|
||||||
|
if (V) printf("[%1.1f] ", x);
|
||||||
|
|
||||||
|
*(vertex_origin + k * 6 + 0) = - x;
|
||||||
|
*(vertex_origin + k * 6 + 1) = 1.0f / size_x;
|
||||||
|
*(vertex_origin + k * 6 + 2) = 0.0f;
|
||||||
|
|
||||||
|
*(vertex_origin + k * 6 + 3) = - x;
|
||||||
|
*(vertex_origin + k * 6 + 4) = - 1.0f / size_x;
|
||||||
|
*(vertex_origin + k * 6 + 5) = 0.0f;
|
||||||
|
|
||||||
|
// fun > if (k == size_x - 1) *(vertex_origin + k * 6 + 5) = 0.1f;
|
||||||
|
|
||||||
|
vertex_index += 6; if (V) printf(" => vertex_index = %3ld space 2D\n", vertex_index);
|
||||||
|
|
||||||
|
*(colors_origin + k * 6 + 0) = 1;
|
||||||
|
*(colors_origin + k * 6 + 1) = 0;
|
||||||
|
*(colors_origin + k * 6 + 2) = 0;
|
||||||
|
|
||||||
|
*(colors_origin + k * 6 + 3) = 1;
|
||||||
|
*(colors_origin + k * 6 + 4) = 1;
|
||||||
|
*(colors_origin + k * 6 + 5) = 0;
|
||||||
|
|
||||||
|
colors_index += 6;
|
||||||
|
|
||||||
|
*(lines_origin + k * 2 + 0) = k * 2 + 0;
|
||||||
|
*(lines_origin + k * 2 + 1) = k * 2 + 1;
|
||||||
|
|
||||||
|
lines_index += 2; if (V) printf(" => lines_index = %3ld space 2D\n", lines_index);
|
||||||
|
}
|
||||||
|
|
||||||
|
*(colors_origin + 0) = 0;
|
||||||
|
*(colors_origin + 1) = 0;
|
||||||
|
*(colors_origin + 2) = 0;
|
||||||
|
|
||||||
|
*(colors_origin + 3) = 1;
|
||||||
|
*(colors_origin + 4) = 1;
|
||||||
|
*(colors_origin + 5) = 1;
|
||||||
|
|
||||||
|
*(colors_origin + (size_x - 1) * 6 + 0) = 1;
|
||||||
|
*(colors_origin + (size_x - 1) * 6 + 1) = 1;
|
||||||
|
*(colors_origin + (size_x - 1) * 6 + 2) = 1;
|
||||||
|
|
||||||
|
*(colors_origin + (size_x - 1) * 6 + 3) = 0;
|
||||||
|
*(colors_origin + (size_x - 1) * 6 + 4) = 0;
|
||||||
|
*(colors_origin + (size_x - 1) * 6 + 5) = 0;
|
||||||
|
|
||||||
|
colors_index += 12; if (V) printf(" => colors_index = %ld\n", colors_index);
|
||||||
|
|
||||||
|
*(lines_origin + lines_index + 0) = 0;
|
||||||
|
*(lines_origin + lines_index + 1) = size_x * 2 - 2; // barre horizontale du bas
|
||||||
|
|
||||||
|
*(lines_origin + lines_index + 2) = 1;
|
||||||
|
*(lines_origin + lines_index + 3) = size_x * 2 - 1; // barre horizontale du haut
|
||||||
|
|
||||||
|
lines_index += 4; if (V) printf("H=> lines_index = %3ld space 2D H\n", lines_index);
|
||||||
|
|
||||||
|
if (pref_mark_unit_space == 1 || pref_mark_unit_space == 3) // diagonales to mark first space unit
|
||||||
|
{
|
||||||
|
*(lines_origin + lines_index + 0) = 0;
|
||||||
|
*(lines_origin + lines_index + 1) = 3;
|
||||||
|
|
||||||
|
*(lines_origin + lines_index + 2) = 1;
|
||||||
|
*(lines_origin + lines_index + 3) = 2;
|
||||||
|
|
||||||
|
lines_index += 4; if (V) printf("X=> lines_index = %3ld space 2D X\n", lines_index);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pref_mark_unit_space == 2 || pref_mark_unit_space == 3) // diagonales to mark last space unit
|
||||||
|
{
|
||||||
|
*(lines_origin + lines_index + 0) = (size_x - 2) * 2 + 0;
|
||||||
|
*(lines_origin + lines_index + 1) = (size_x - 2) * 2 + 3;
|
||||||
|
|
||||||
|
*(lines_origin + lines_index + 2) = (size_x - 2) * 2 + 1;
|
||||||
|
*(lines_origin + lines_index + 3) = (size_x - 2) * 2 + 2;
|
||||||
|
|
||||||
|
lines_index +=4; if (V) printf("X=> lines_index = %3ld space 2D X\n", lines_index);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (V) printf(" n = %d x 2 côté = [%1.1f]\n", size_x + 1, 2.0f / size_x);
|
||||||
|
if (V) printf("space_2D lines_origin (%d - size_x(0)) x (%d - size_x(1)) ", 0, 1);
|
||||||
|
for (int v = 0; v < size_x + 2; v++)
|
||||||
|
if (V) printf("(%d-%d) ", *(lines_origin + v), *(lines_origin + v + 1));
|
||||||
|
if (V) printf(" n = 4 + (%d x 2)\n", size_x + 2);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int compute_arrow_2D(int size_x,
|
||||||
|
int size_y,
|
||||||
|
int 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 *colors_origin,
|
||||||
|
GLuint *lines_origin,
|
||||||
|
GLuint *plans_origin)
|
||||||
|
{
|
||||||
|
printf("compute_arrow_2D load = %d site = %d x = %d\n", weight, site, x);
|
||||||
|
float zero = 0.0f;
|
||||||
|
float center = (1.0f / size_x) * (2 * x - size_x + 2);
|
||||||
|
float tip = center + (2 * site - 1) * (1.0f / size_x - 0.01f);
|
||||||
|
float base = center + (2 * site - 1) * (0.1f / size_x);
|
||||||
|
float lat = 0.4f / size_x;
|
||||||
|
|
||||||
|
/* for (int i = 0; i < size_x; i++) */
|
||||||
|
/* for (int j = 0; j < size_y; j++) */
|
||||||
|
/* for (int k = 0; k < size_z; k++) */
|
||||||
|
/* { */
|
||||||
|
|
||||||
|
/* x = - ((size_x % 2) * (size_x / 2 - i) */
|
||||||
|
/* - (size_x % 2 - 1) * (i + 0.5f - size_x / 2)) / size_x * 2 * EDGE; */
|
||||||
|
/* y = - ((size_x % 2) * (size_x / 2 - j) */
|
||||||
|
/* - (size_x % 2 - 1) * (j + 0.5f - size_x / 2)) / size_x * 2 * EDGE; */
|
||||||
|
/* z = - ((size_x % 2) * (size_x / 2 - k) */
|
||||||
|
/* - (size_x % 2 - 1) * (k + 0.5f - size_x / 2)) / size_x * 2 * EDGE; */
|
||||||
|
/* } */
|
||||||
|
|
||||||
|
*(vertex_origin + vertex_index + 0) = tip;
|
||||||
|
*(vertex_origin + vertex_index + 1) = zero;
|
||||||
|
*(vertex_origin + vertex_index + 2) = zero;
|
||||||
|
|
||||||
|
*(vertex_origin + vertex_index + 3) = base;
|
||||||
|
*(vertex_origin + vertex_index + 4) = lat;
|
||||||
|
*(vertex_origin + vertex_index + 5) = zero;
|
||||||
|
|
||||||
|
*(vertex_origin + vertex_index + 6) = base;
|
||||||
|
*(vertex_origin + vertex_index + 7) = - lat;
|
||||||
|
*(vertex_origin + vertex_index + 8) = zero;
|
||||||
|
|
||||||
|
vertex_index += 9; if (V) printf(" => vertex_index = %3ld arrow_2D\n", vertex_index);
|
||||||
|
|
||||||
|
if (pref_style_lines_planes == 0) {
|
||||||
|
|
||||||
|
if (V) printf("0=> lines_index = %ld\n", lines_index);
|
||||||
|
|
||||||
|
*(lines_origin + lines_index + 0) = vertex_index / 3 - 3;
|
||||||
|
*(lines_origin + lines_index + 1) = vertex_index / 3 - 2;
|
||||||
|
|
||||||
|
*(lines_origin + lines_index + 2) = vertex_index / 3 - 3;
|
||||||
|
*(lines_origin + lines_index + 3) = vertex_index / 3 - 1;
|
||||||
|
|
||||||
|
*(lines_origin + lines_index + 4) = vertex_index / 3 - 2;
|
||||||
|
*(lines_origin + lines_index + 5) = vertex_index / 3 - 1;
|
||||||
|
|
||||||
|
lines_index += 6; if (V) printf("|=> lines_index = %3ld arrow_2D\n", lines_index);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (pref_style_lines_planes == 1) {
|
||||||
|
*(plans_origin + plans_index + 0) = vertex_index / 3 + 0;
|
||||||
|
*(plans_origin + plans_index + 1) = vertex_index / 3 + 1;
|
||||||
|
*(plans_origin + plans_index + 2) = vertex_index / 3 + 2;
|
||||||
|
|
||||||
|
*(plans_origin + plans_index + 3) = vertex_index / 3 + 0;
|
||||||
|
*(plans_origin + plans_index + 4) = vertex_index / 3 + 1;
|
||||||
|
*(plans_origin + plans_index + 5) = vertex_index / 3 + 2;
|
||||||
|
|
||||||
|
plans_index += 6; if (V) printf("|=> plans_index = %ld\n", plans_index);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* x = - ((size_x % 2) * (size_x / 2 - i) */
|
||||||
|
/* - (size_x % 2 - 1) * (i + 0.5f - size_x / 2)) / size_x * 2 * EDGE; */
|
||||||
|
/* y = - ((size_y % 2) * (size_y / 2 - j) */
|
||||||
|
/* - (size_y % 2 - 1) * (j + 0.5f - size_y / 2)) / size_y * 2 * EDGE; */
|
||||||
|
/* z = - ((size_z % 2) * (size_z / 2 - k) */
|
||||||
|
/* - (size_z % 2 - 1) * (k + 0.5f - size_z / 2)) / size_z * 2 * EDGE; */
|
||||||
|
|
||||||
|
static bool compute_arrow_3D(long size_x,
|
||||||
|
long size_y,
|
||||||
|
long size_z,
|
||||||
|
|
||||||
|
int weight,
|
||||||
|
int site, // North, South, East, West, Zenith, nAdir (NSEWZA)
|
||||||
|
long x,
|
||||||
|
long y,
|
||||||
|
long z,
|
||||||
|
|
||||||
|
int pref_style_lines_planes,
|
||||||
|
int pref_style_mix_colors,
|
||||||
|
|
||||||
|
GLfloat *vertex_origin,
|
||||||
|
GLfloat *colors_origin,
|
||||||
|
GLuint *lines_origin,
|
||||||
|
GLuint *plans_origin)
|
||||||
|
|
||||||
|
{
|
||||||
|
float zero = 0.0f;
|
||||||
|
float center = (1.0f / size_x) * (2 * x - size_x + 2);
|
||||||
|
float tip = center + (2 * site - 1) * (1.0f / size_x);
|
||||||
|
float base = center + (2 * site - 1) * (0.1f / size_x);
|
||||||
|
|
||||||
|
*(vertex_origin + vertex_index + 0) = center + (2 * site - 1) * (1.0f / size_x - 0.01f);
|
||||||
|
*(vertex_origin + vertex_index + 1) = zero;
|
||||||
|
*(vertex_origin + vertex_index + 2) = zero;
|
||||||
|
|
||||||
|
*(vertex_origin + vertex_index + 3) = base;
|
||||||
|
*(vertex_origin + vertex_index + 4) = 0.4f / size_x;
|
||||||
|
*(vertex_origin + vertex_index + 5) = 0.4f / size_x;
|
||||||
|
|
||||||
|
*(vertex_origin + vertex_index + 6) = base;
|
||||||
|
*(vertex_origin + vertex_index + 7) = 0.4f / size_x;
|
||||||
|
*(vertex_origin + vertex_index + 8) = - 0.4f / size_x;
|
||||||
|
|
||||||
|
*(vertex_origin + vertex_index + 9) = base;
|
||||||
|
*(vertex_origin + vertex_index + 10) = - 0.4f / size_x;
|
||||||
|
*(vertex_origin + vertex_index + 11) = - 0.4f / size_x;
|
||||||
|
|
||||||
|
*(vertex_origin + vertex_index + 12) = base;
|
||||||
|
*(vertex_origin + vertex_index + 13) = - 0.4f / size_x;
|
||||||
|
*(vertex_origin + vertex_index + 14) = 0.4f / size_x;
|
||||||
|
|
||||||
|
vertex_index += 15; if (V) printf(" => vertex_index = %3ld arrow_3D\n", vertex_index);
|
||||||
|
|
||||||
|
if (V) printf("center = %f tip = %f base = %f\n",\
|
||||||
|
center, tip, base); // size_x * 12=%d igap=%d
|
||||||
|
|
||||||
|
if (pref_style_lines_planes == 0) {
|
||||||
|
|
||||||
|
*(lines_origin + lines_index + 0) = vertex_index / 3 - 5;
|
||||||
|
*(lines_origin + lines_index + 1) = vertex_index / 3 - 4;
|
||||||
|
|
||||||
|
*(lines_origin + lines_index + 2) = vertex_index / 3 - 5;
|
||||||
|
*(lines_origin + lines_index + 3) = vertex_index / 3 - 3;
|
||||||
|
|
||||||
|
*(lines_origin + lines_index + 4) = vertex_index / 3 - 5;
|
||||||
|
*(lines_origin + lines_index + 5) = vertex_index / 3 - 2;
|
||||||
|
|
||||||
|
*(lines_origin + lines_index + 6) = vertex_index / 3 - 5;
|
||||||
|
*(lines_origin + lines_index + 7) = vertex_index / 3 - 1;
|
||||||
|
|
||||||
|
*(lines_origin + lines_index + 8) = vertex_index / 3 - 4;
|
||||||
|
*(lines_origin + lines_index + 9) = vertex_index / 3 - 3;
|
||||||
|
|
||||||
|
*(lines_origin + lines_index + 10) = vertex_index / 3 - 3;
|
||||||
|
*(lines_origin + lines_index + 11) = vertex_index / 3 - 2;
|
||||||
|
|
||||||
|
*(lines_origin + lines_index + 12) = vertex_index / 3 - 2;
|
||||||
|
*(lines_origin + lines_index + 13) = vertex_index / 3 - 1;
|
||||||
|
|
||||||
|
*(lines_origin + lines_index + 14) = vertex_index / 3 - 1;
|
||||||
|
*(lines_origin + lines_index + 15) = vertex_index / 3 - 4;
|
||||||
|
|
||||||
|
lines_index += 16; if (V) printf("|=> lines_index = %3ld arrow_3D\n", lines_index);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pref_style_lines_planes == 1) {
|
||||||
|
|
||||||
|
*(plans_origin + plans_index + 0) = size_x * 12 / 3 + 0;
|
||||||
|
*(plans_origin + plans_index + 1) = size_x * 12 / 3 + 1;
|
||||||
|
*(plans_origin + plans_index + 2) = size_x * 12 / 3 + 2;
|
||||||
|
|
||||||
|
*(plans_origin + plans_index + 3) = size_x * 12 / 3 + 0;
|
||||||
|
*(plans_origin + plans_index + 4) = size_x * 12 / 3 + 3;
|
||||||
|
*(plans_origin + plans_index + 5) = size_x * 12 / 3 + 4;
|
||||||
|
|
||||||
|
*(plans_origin + plans_index + 0) = size_x * 12 / 3 + 0;
|
||||||
|
*(plans_origin + plans_index + 1) = size_x * 12 / 3 + 1;
|
||||||
|
*(plans_origin + plans_index + 2) = size_x * 12 / 3 + 3;
|
||||||
|
|
||||||
|
*(plans_origin + plans_index + 3) = size_x * 12 / 3 + 0;
|
||||||
|
*(plans_origin + plans_index + 4) = size_x * 12 / 3 + 2;
|
||||||
|
*(plans_origin + plans_index + 5) = size_x * 12 / 3 + 4;
|
||||||
|
|
||||||
|
plans_index += 12; if (V) printf("|=> plans_index = %3ld arrow_3D\n", plans_index);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void old_arrows(int model_arrows_nb,
|
||||||
|
long model_size_x, long model_size_y, long model_size_z,
|
||||||
|
int pref_style_lines_planes, int pref_style_mix_colors,
|
||||||
|
GLuint *arrows, GLfloat *vertex_origin, GLfloat *colors_origin,
|
||||||
|
GLuint *lines_origin, GLuint *plans_origin)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < model_arrows_nb; i++)
|
||||||
|
compute_arrow_3D (model_size_x,
|
||||||
|
model_size_y,
|
||||||
|
model_size_z,
|
||||||
|
|
||||||
|
*(arrows + i * 5 + 0), // weight (load)
|
||||||
|
*(arrows + i * 5 + 1), // site
|
||||||
|
*(arrows + i * 5 + 2), // x
|
||||||
|
*(arrows + i * 5 + 3), // y
|
||||||
|
*(arrows + i * 5 + 4), // z
|
||||||
|
|
||||||
|
pref_style_lines_planes,
|
||||||
|
pref_style_mix_colors,
|
||||||
|
|
||||||
|
vertex_origin,
|
||||||
|
colors_origin,
|
||||||
|
lines_origin,
|
||||||
|
plans_origin);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// OLD ARROWS (DEPRECATED)
|
||||||
|
/* old_arrows (model_arrows_nb, model_size_x, model_size_y, model_size_z, arrows, */
|
||||||
|
/* pref_style_lines_planes, pref_style_mix_colors, */
|
||||||
|
/* vertex_origin, colors_origin, lines_origin, plans_origin); */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,8 @@ out vec4 color;
|
||||||
|
|
||||||
void main(void)
|
void main(void)
|
||||||
{
|
{
|
||||||
gl_Position = projection_matrix * view_matrix * model_matrix * vec4(in_position, 1);
|
float zoom = 1.5f, chrominance = 1, luminance = 1;
|
||||||
color = vec4(1 * in_color.rgb, 1);
|
gl_Position =
|
||||||
// color = vec4(1 * in_color.rgb, 0.2f);
|
projection_matrix * view_matrix * model_matrix * vec4(in_position, zoom);
|
||||||
|
color = vec4 (chrominance * in_color.rgb, luminance);
|
||||||
}
|
}
|
Loading…
Reference in New Issue