WIP: Bon. C'est sympa tout ça mais il va falloir joeur avec les flèches, maintenant...
This commit is contained in:
parent
4bfe14ac48
commit
b9f51e1ab9
|
@ -49,7 +49,6 @@ static long colors_buffer_size = 0;
|
|||
static long lines_buffer_size = 0;
|
||||
static long plans_buffer_size = 0;
|
||||
|
||||
#define EDGE 0.999999
|
||||
|
||||
#define S 0
|
||||
#define S3 0
|
||||
|
@ -84,7 +83,7 @@ static bool compute_space_2D(int size_x,
|
|||
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 * EDGE;
|
||||
+ (size_x % 2 - 1) * (k + 0.5f - size_x / 2)) / size_x * 2;
|
||||
|
||||
if (S) printf("[%1.1f] ", x);
|
||||
|
||||
|
@ -268,8 +267,67 @@ static int compute_arrow_2D(int size_x,
|
|||
|
||||
/*****************************************************************************************************/
|
||||
|
||||
#define CORRC 1.5
|
||||
#define P 0
|
||||
static void draw_a_cube_at(long u, long v, long w,
|
||||
GLuint *lines_origin,
|
||||
long size_x,
|
||||
long size_y,
|
||||
long size_z,
|
||||
bool diagonals){
|
||||
|
||||
long step_z = 1, step_y = size_z, step_x = size_y * size_z, x = u + 1, y = v + 1, z = w + 1;
|
||||
|
||||
*(lines_origin + lines_buffer_size) = step_z * w + step_y * v + step_x * u; lines_buffer_size ++;
|
||||
*(lines_origin + lines_buffer_size) = step_z * w + step_y * v + step_x * x; lines_buffer_size ++;
|
||||
|
||||
*(lines_origin + lines_buffer_size) = step_z * w + step_y * v + step_x * u; lines_buffer_size ++;
|
||||
*(lines_origin + lines_buffer_size) = step_z * w + step_y * y + step_x * u; lines_buffer_size ++;
|
||||
|
||||
*(lines_origin + lines_buffer_size) = step_z * w + step_y * v + step_x * u; lines_buffer_size ++;
|
||||
*(lines_origin + lines_buffer_size) = step_z * z + step_y * v + step_x * u; lines_buffer_size ++;
|
||||
|
||||
*(lines_origin + lines_buffer_size) = step_z * z + step_y * y + step_x * x; lines_buffer_size ++;
|
||||
*(lines_origin + lines_buffer_size) = step_z * z + step_y * y + step_x * u; lines_buffer_size ++;
|
||||
|
||||
*(lines_origin + lines_buffer_size) = step_z * z + step_y * y + step_x * x; lines_buffer_size ++;
|
||||
*(lines_origin + lines_buffer_size) = step_z * z + step_y * v + step_x * x; lines_buffer_size ++;
|
||||
|
||||
*(lines_origin + lines_buffer_size) = step_z * z + step_y * y + step_x * x; lines_buffer_size ++;
|
||||
*(lines_origin + lines_buffer_size) = step_z * w + step_y * y + step_x * x; lines_buffer_size ++;
|
||||
|
||||
|
||||
*(lines_origin + lines_buffer_size) = step_z * w + step_y * v + step_x * x; lines_buffer_size ++;
|
||||
*(lines_origin + lines_buffer_size) = step_z * z + step_y * v + step_x * x; lines_buffer_size ++;
|
||||
|
||||
*(lines_origin + lines_buffer_size) = step_z * w + step_y * v + step_x * x; lines_buffer_size ++;
|
||||
*(lines_origin + lines_buffer_size) = step_z * w + step_y * y + step_x * x; lines_buffer_size ++;
|
||||
|
||||
*(lines_origin + lines_buffer_size) = step_z * w + step_y * y + step_x * u; lines_buffer_size ++;
|
||||
*(lines_origin + lines_buffer_size) = step_z * w + step_y * y + step_x * x; lines_buffer_size ++;
|
||||
|
||||
*(lines_origin + lines_buffer_size) = step_z * z + step_y * v + step_x * u; lines_buffer_size ++;
|
||||
*(lines_origin + lines_buffer_size) = step_z * z + step_y * y + step_x * u; lines_buffer_size ++;
|
||||
|
||||
*(lines_origin + lines_buffer_size) = step_z * z + step_y * v + step_x * u; lines_buffer_size ++;
|
||||
*(lines_origin + lines_buffer_size) = step_z * z + step_y * v + step_x * x; lines_buffer_size ++;
|
||||
|
||||
*(lines_origin + lines_buffer_size) = step_z * z + step_y * y + step_x * u; lines_buffer_size ++;
|
||||
*(lines_origin + lines_buffer_size) = step_z * w + step_y * y + step_x * u; lines_buffer_size ++;
|
||||
|
||||
if (diagonals){
|
||||
*(lines_origin + lines_buffer_size) = step_z * w + step_y * v + step_x * u; lines_buffer_size ++;
|
||||
*(lines_origin + lines_buffer_size) = step_z * z + step_y * y + step_x * x; lines_buffer_size ++;
|
||||
|
||||
*(lines_origin + lines_buffer_size) = step_z * w + step_y * v + step_x * x; lines_buffer_size ++;
|
||||
*(lines_origin + lines_buffer_size) = step_z * z + step_y * y + step_x * u; lines_buffer_size ++;
|
||||
|
||||
*(lines_origin + lines_buffer_size) = step_z * z + step_y * v + step_x * u; lines_buffer_size ++;
|
||||
*(lines_origin + lines_buffer_size) = step_z * w + step_y * y + step_x * x; lines_buffer_size ++;
|
||||
|
||||
*(lines_origin + lines_buffer_size) = step_z * w + step_y * y + step_x * u; lines_buffer_size ++;
|
||||
*(lines_origin + lines_buffer_size) = step_z * z + step_y * v + step_x * x; lines_buffer_size ++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static bool compute_space_3D (long x,
|
||||
long y,
|
||||
|
@ -288,7 +346,7 @@ static bool compute_space_3D (long x,
|
|||
long maximum = fmax(x, y);
|
||||
maximum = fmax(maximum, z);
|
||||
|
||||
float i, j, k, vx, vy, vz, max = maximum * CORRC;
|
||||
float i, j, k, vx, vy, vz, max = maximum;
|
||||
|
||||
if (P) printf("max(%ld,%ld,%ld) = %ld; size_x / max = %6.3f; size_y / max = %6.3f; size_z / max = %6.3f\n",\
|
||||
x, y, z, maximum, x / max, y / max, z / max);
|
||||
|
@ -393,6 +451,21 @@ static bool compute_space_3D (long x,
|
|||
*(lines_origin + lines_buffer_size) = step_z * (z - 1) + step_y * 0 + step_x * 0; lines_buffer_size ++;
|
||||
*(lines_origin + lines_buffer_size) = step_z * (z - 1) + step_y * 0 + step_x * (x - 1); lines_buffer_size ++;
|
||||
|
||||
// a diagonal test:
|
||||
*(lines_origin + lines_buffer_size) = step_z * 0 + step_y * 0 + step_x * 0; lines_buffer_size ++;
|
||||
*(lines_origin + lines_buffer_size) = step_z * (z - 1) + step_y * (y - 1) + step_x * (x - 1); lines_buffer_size ++;
|
||||
|
||||
if (0) draw_a_cube_at (
|
||||
1, 1, 1, lines_origin,
|
||||
x + 1, y + 1, z + 1,
|
||||
1); // shows the diagonals of each small cube
|
||||
|
||||
if (0) draw_a_cube_at (
|
||||
x - 2, y - 2, z - 2, lines_origin,
|
||||
x - 1, y - 1, z - 1,
|
||||
1); // shows the diagonals of each small cube
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -463,42 +536,41 @@ static void draw_an_arrow_3D_at(long load, long site, long x, long y, long z,
|
|||
float base = center + (2 * site - 1) * cote;
|
||||
float decalage = (2 * site - 1) * 1.0f / cote - 0.01f;
|
||||
|
||||
*(vertex_origin + vertex_buffer_size + 0) = center + decalage;
|
||||
*(vertex_origin + vertex_buffer_size + 1) = zero;
|
||||
*(vertex_origin + vertex_buffer_size + 2) = zero;
|
||||
/* *(vertex_origin + vertex_buffer_size + 0) = center + decalage; */
|
||||
/* *(vertex_origin + vertex_buffer_size + 1) = zero; */
|
||||
/* *(vertex_origin + vertex_buffer_size + 2) = zero; */
|
||||
|
||||
*(vertex_origin + vertex_buffer_size + 3) = base;
|
||||
*(vertex_origin + vertex_buffer_size + 4) = 0.4f / cote;
|
||||
*(vertex_origin + vertex_buffer_size + 5) = 0.4f / cote;
|
||||
/* *(vertex_origin + vertex_buffer_size + 3) = base; */
|
||||
/* *(vertex_origin + vertex_buffer_size + 4) = 0.4f / cote; */
|
||||
/* *(vertex_origin + vertex_buffer_size + 5) = 0.4f / cote; */
|
||||
|
||||
*(vertex_origin + vertex_buffer_size + 6) = base;
|
||||
*(vertex_origin + vertex_buffer_size + 7) = 0.4f / cote;
|
||||
*(vertex_origin + vertex_buffer_size + 8) = - 0.4f / cote;
|
||||
/* *(vertex_origin + vertex_buffer_size + 6) = base; */
|
||||
/* *(vertex_origin + vertex_buffer_size + 7) = 0.4f / cote; */
|
||||
/* *(vertex_origin + vertex_buffer_size + 8) = - 0.4f / cote; */
|
||||
|
||||
*(vertex_origin + vertex_buffer_size + 9) = base;
|
||||
*(vertex_origin + vertex_buffer_size + 10) = - 0.4f / cote;
|
||||
*(vertex_origin + vertex_buffer_size + 11) = - 0.4f / cote;
|
||||
/* *(vertex_origin + vertex_buffer_size + 9) = base; */
|
||||
/* *(vertex_origin + vertex_buffer_size + 10) = - 0.4f / cote; */
|
||||
/* *(vertex_origin + vertex_buffer_size + 11) = - 0.4f / cote; */
|
||||
|
||||
*(vertex_origin + vertex_buffer_size + 12) = base;
|
||||
*(vertex_origin + vertex_buffer_size + 13) = - 0.4f / cote;
|
||||
*(vertex_origin + vertex_buffer_size + 14) = 0.4f / cote;
|
||||
/* *(vertex_origin + vertex_buffer_size + 12) = base; */
|
||||
/* *(vertex_origin + vertex_buffer_size + 13) = - 0.4f / cote; */
|
||||
/* *(vertex_origin + vertex_buffer_size + 14) = 0.4f / cote; */
|
||||
|
||||
vertex_buffer_size += 15;
|
||||
/* vertex_buffer_size += 15; */
|
||||
|
||||
*(colors_origin + colors_buffer_size + 0) = 3 * x / 2;
|
||||
*(colors_origin + colors_buffer_size + 1) = 3 * y / 2;
|
||||
*(colors_origin + colors_buffer_size + 2) = 3 * z / 2;
|
||||
/* *(colors_origin + colors_buffer_size + 0) = 3 * x / 2; */
|
||||
/* *(colors_origin + colors_buffer_size + 1) = 3 * y / 2; */
|
||||
/* *(colors_origin + colors_buffer_size + 2) = 3 * z / 2; */
|
||||
|
||||
colors_buffer_size += 3;
|
||||
/* colors_buffer_size += 3; */
|
||||
|
||||
// if (C) printf(" => colors_buffer_size = %3d\n", colors_buffer_size);23.
|
||||
if (P) printf("[%6.3f %6.3f %6.3f] ", x, y, z);
|
||||
if (A3) printf("center = %f tip = %f base = %f\n",\
|
||||
center, tip, base); // size_x * 12=%d igap=%d
|
||||
if (V) printf(" => vertex_buffer_size = %3ld arrow_3D\n", vertex_buffer_size);
|
||||
// printf(" => colors_buffer_size = %3d\n", colors_buffer_size);
|
||||
printf("\n[%6.3f %6.3f %6.3f ] ", x, y, z);
|
||||
// printf("center = %f tip = %f base = %f ", center, tip, base);
|
||||
printf("vertex_buffer_size = %3ld ", vertex_buffer_size);
|
||||
|
||||
|
||||
long step_z = 1, step_y = z + 1, step_x = (y + 1) * (z + 1);
|
||||
long step_z = 1, step_y = z, step_x = y * z;
|
||||
|
||||
*(lines_origin + lines_buffer_size) = step_z * 0 + step_y * 0 + step_x * 0; lines_buffer_size ++;
|
||||
*(lines_origin + lines_buffer_size) = step_z * (z - 1) + step_y * (y - 1) + step_x * (x - 1); lines_buffer_size ++;
|
||||
|
@ -531,7 +603,7 @@ static void draw_an_arrow_3D_at(long load, long site, long x, long y, long z,
|
|||
/* *(lines_origin + lines_buffer_size + 15) = vertex_buffer_size / 3 - 4; */
|
||||
|
||||
/* lines_buffer_size += 16; */
|
||||
if (L) printf("|=> lines_buffer_size = %3ld arrow_3D\n", lines_buffer_size);
|
||||
printf("lines_buffer_size = %3ld\n", lines_buffer_size);
|
||||
}
|
||||
|
||||
|
||||
|
@ -588,68 +660,6 @@ static void draw_an_arrow_3D_at(long load, long site, long x, long y, long z,
|
|||
|
||||
|
||||
|
||||
static void draw_a_cube_at(long u, long v, long w,
|
||||
GLuint *lines_origin,
|
||||
long size_x,
|
||||
long size_y,
|
||||
long size_z,
|
||||
bool diagonals){
|
||||
|
||||
long step_z = 1, step_y = size_z, step_x = size_y * size_z, x = u + 1, y = v + 1, z = w + 1;
|
||||
|
||||
*(lines_origin + lines_buffer_size) = step_z * w + step_y * v + step_x * u; lines_buffer_size ++;
|
||||
*(lines_origin + lines_buffer_size) = step_z * w + step_y * v + step_x * x; lines_buffer_size ++;
|
||||
|
||||
*(lines_origin + lines_buffer_size) = step_z * w + step_y * v + step_x * u; lines_buffer_size ++;
|
||||
*(lines_origin + lines_buffer_size) = step_z * w + step_y * y + step_x * u; lines_buffer_size ++;
|
||||
|
||||
*(lines_origin + lines_buffer_size) = step_z * w + step_y * v + step_x * u; lines_buffer_size ++;
|
||||
*(lines_origin + lines_buffer_size) = step_z * z + step_y * v + step_x * u; lines_buffer_size ++;
|
||||
|
||||
*(lines_origin + lines_buffer_size) = step_z * z + step_y * y + step_x * x; lines_buffer_size ++;
|
||||
*(lines_origin + lines_buffer_size) = step_z * z + step_y * y + step_x * u; lines_buffer_size ++;
|
||||
|
||||
*(lines_origin + lines_buffer_size) = step_z * z + step_y * y + step_x * x; lines_buffer_size ++;
|
||||
*(lines_origin + lines_buffer_size) = step_z * z + step_y * v + step_x * x; lines_buffer_size ++;
|
||||
|
||||
*(lines_origin + lines_buffer_size) = step_z * z + step_y * y + step_x * x; lines_buffer_size ++;
|
||||
*(lines_origin + lines_buffer_size) = step_z * w + step_y * y + step_x * x; lines_buffer_size ++;
|
||||
|
||||
|
||||
*(lines_origin + lines_buffer_size) = step_z * w + step_y * v + step_x * x; lines_buffer_size ++;
|
||||
*(lines_origin + lines_buffer_size) = step_z * z + step_y * v + step_x * x; lines_buffer_size ++;
|
||||
|
||||
*(lines_origin + lines_buffer_size) = step_z * w + step_y * v + step_x * x; lines_buffer_size ++;
|
||||
*(lines_origin + lines_buffer_size) = step_z * w + step_y * y + step_x * x; lines_buffer_size ++;
|
||||
|
||||
*(lines_origin + lines_buffer_size) = step_z * w + step_y * y + step_x * u; lines_buffer_size ++;
|
||||
*(lines_origin + lines_buffer_size) = step_z * w + step_y * y + step_x * x; lines_buffer_size ++;
|
||||
|
||||
*(lines_origin + lines_buffer_size) = step_z * z + step_y * v + step_x * u; lines_buffer_size ++;
|
||||
*(lines_origin + lines_buffer_size) = step_z * z + step_y * y + step_x * u; lines_buffer_size ++;
|
||||
|
||||
*(lines_origin + lines_buffer_size) = step_z * z + step_y * v + step_x * u; lines_buffer_size ++;
|
||||
*(lines_origin + lines_buffer_size) = step_z * z + step_y * v + step_x * x; lines_buffer_size ++;
|
||||
|
||||
*(lines_origin + lines_buffer_size) = step_z * z + step_y * y + step_x * u; lines_buffer_size ++;
|
||||
*(lines_origin + lines_buffer_size) = step_z * w + step_y * y + step_x * u; lines_buffer_size ++;
|
||||
|
||||
if (diagonals){
|
||||
*(lines_origin + lines_buffer_size) = step_z * w + step_y * v + step_x * u; lines_buffer_size ++;
|
||||
*(lines_origin + lines_buffer_size) = step_z * z + step_y * y + step_x * x; lines_buffer_size ++;
|
||||
|
||||
*(lines_origin + lines_buffer_size) = step_z * w + step_y * v + step_x * x; lines_buffer_size ++;
|
||||
*(lines_origin + lines_buffer_size) = step_z * z + step_y * y + step_x * u; lines_buffer_size ++;
|
||||
|
||||
*(lines_origin + lines_buffer_size) = step_z * z + step_y * v + step_x * u; lines_buffer_size ++;
|
||||
*(lines_origin + lines_buffer_size) = step_z * w + step_y * y + step_x * x; lines_buffer_size ++;
|
||||
|
||||
*(lines_origin + lines_buffer_size) = step_z * w + step_y * y + step_x * u; lines_buffer_size ++;
|
||||
*(lines_origin + lines_buffer_size) = step_z * z + step_y * v + step_x * x; lines_buffer_size ++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -799,14 +809,14 @@ static void show_user_choices(long model_size_x,
|
|||
if (pref_style_lines_planes > 0)printf("style_lines_planes = %d ", pref_style_lines_planes);
|
||||
if (! pref_style_mix_colors) printf("no style_mix_colors ");
|
||||
if (pref_style_mix_colors > 0) printf("style_mix_colors = %d ", pref_style_mix_colors);
|
||||
if (pref_show_grid == 1) printf("pref_show_grid = %d show none ", pref_show_grid);
|
||||
if (pref_show_grid == 0) printf("pref_show_grid = %d <> show all ", pref_show_grid);
|
||||
if (pref_show_grid == 2) printf("pref_show_grid = %d <> show xy ", pref_show_grid);
|
||||
if (pref_show_grid == 3) printf("pref_show_grid = %d <> show xz ", pref_show_grid);
|
||||
if (pref_show_grid == 5) printf("pref_show_grid = %d <> show yz ", pref_show_grid);
|
||||
if (pref_show_grid == 6) printf("pref_show_grid = %d <> show xy & xz ", pref_show_grid);
|
||||
if (pref_show_grid == 10) printf("pref_show_grid = %d <> show xy & yz ", pref_show_grid);
|
||||
if (pref_show_grid == 15) printf("pref_show_grid = %d <> show xz & yz ", pref_show_grid);
|
||||
if (pref_show_grid == 1) printf("pref_show_grid = %d <> show no grid ", pref_show_grid);
|
||||
if (pref_show_grid == 0) printf("pref_show_grid = %d <> show all grids ", pref_show_grid);
|
||||
if (pref_show_grid == 2) printf("pref_show_grid = %d <> show grid xy ", pref_show_grid);
|
||||
if (pref_show_grid == 3) printf("pref_show_grid = %d <> show grid xz ", pref_show_grid);
|
||||
if (pref_show_grid == 5) printf("pref_show_grid = %d <> show grid yz ", pref_show_grid);
|
||||
if (pref_show_grid == 6) printf("pref_show_grid = %d <> show grids xy & xz ", pref_show_grid);
|
||||
if (pref_show_grid == 10) printf("pref_show_grid = %d <> show grids xy & yz ", pref_show_grid);
|
||||
if (pref_show_grid == 15) printf("pref_show_grid = %d <> show grids xz & yz ", pref_show_grid);
|
||||
if (model_arrows_nb > 0) printf("\n[n] load site x y z ---- < arrows array >\
|
||||
------------------------------------------------------------\n");
|
||||
// arrows = { 1, 1, 0, 1, 2, 1, 1, 1, 10, 1, 2, 11, 1, 1, 20, 1, 2, 21 }
|
||||
|
@ -870,12 +880,12 @@ bool compute_space_and_arrows(long model_size_x,
|
|||
/* model_size_x + 1, model_size_y + 1, model_size_z + 1, */
|
||||
/* pref_mark_unit_space); // shows the diagonals of each small cube */
|
||||
|
||||
draw_a_cube_at (
|
||||
if (1) draw_a_cube_at (
|
||||
1, 1, 1, lines_origin,
|
||||
model_size_x + 1, model_size_y + 1, model_size_z + 1,
|
||||
0); // shows the diagonals of each small cube
|
||||
|
||||
draw_a_cube_at (
|
||||
if (1) draw_a_cube_at (
|
||||
model_size_x - 2, model_size_y - 2, model_size_z - 2, lines_origin,
|
||||
model_size_x + 1, model_size_y + 1, model_size_z + 1,
|
||||
0); // shows the diagonals of each small cube
|
||||
|
|
|
@ -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;
|
||||
/// }
|
||||
}
|
||||
}
|
|
@ -62,7 +62,7 @@ GLuint *buffer_plans_origin = NULL;
|
|||
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 pref_show_grid = 0; // 0, 2, 3, 5, 6, 10, 15, 30
|
||||
int pref_show_grid = 0; // 0, 1, 2, 3, 5, 6, 10, 15, 30, etc
|
||||
|
||||
int buffer_vertex_size = 0;
|
||||
int buffer_colors_size = 0;
|
||||
|
@ -563,9 +563,10 @@ GLuint arrows[] = {
|
|||
|
||||
static void get_model_data_and_user_preferences(){
|
||||
|
||||
model_space_size_x = 4; // 0 < model_space_size_x
|
||||
model_space_size_y = 5; // 0 < model_space_size_y
|
||||
model_space_size_z = 6; // 0 < model_space_size_z
|
||||
|
||||
model_space_size_x = 6; // 0 < model_space_size_x
|
||||
model_space_size_y = 7; // 0 < model_space_size_y
|
||||
model_space_size_z = 5; // 0 < model_space_size_z
|
||||
|
||||
// XXX ONLY space drawed, no arrows
|
||||
model_arrows_nb = 0; // assert : l'emplacement des flèches est contraint
|
||||
|
@ -576,7 +577,7 @@ static void get_model_data_and_user_preferences(){
|
|||
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 = 1; // 0, 2, 3, 5, 6, 10, 15, 30
|
||||
pref_show_grid = 2; // 0, 2, 3, 5, 6, 10, 15, 30
|
||||
// 0, x, y, z, xy, xz, yz, xyz
|
||||
}
|
||||
|
||||
|
@ -585,23 +586,6 @@ static void get_model_data_and_user_preferences(){
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#define S 1
|
||||
static void compute_buffers_sizes(int model_space_size_x,
|
||||
int model_space_size_y,
|
||||
int model_space_size_z,
|
||||
|
@ -633,7 +617,7 @@ static void compute_buffers_sizes(int model_space_size_x,
|
|||
if ((i + j + k) % 2 == 0) small_cubes_nb ++;
|
||||
small_cubes_nb = small_cubes_nb * 2;
|
||||
|
||||
small_cubes_nb = 2;
|
||||
small_cubes_nb = 2; // Et les diagonales ?!
|
||||
|
||||
buffer_lines_size = small_cubes_nb * 24 // small cubes in space
|
||||
+ 24 // les arêtes de l'espace
|
||||
|
@ -649,12 +633,13 @@ static void compute_buffers_sizes(int model_space_size_x,
|
|||
* (model_space_size_y + 1)
|
||||
* (model_space_size_z + 1)
|
||||
* 2
|
||||
+ model_arrows_nb * 16;
|
||||
+ model_arrows_nb * 16
|
||||
+ 2;
|
||||
|
||||
if (pref_mark_unit_space)
|
||||
buffer_lines_size += small_cubes_nb * 8; // small cubes diagonals (if...)
|
||||
|
||||
if (S) printf("allocated buffers sizes :%4d/3 = %3d vertices, %4d/3 = %3d colors,\
|
||||
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,
|
||||
|
|
|
@ -11,7 +11,8 @@ out vec4 color;
|
|||
|
||||
void main(void)
|
||||
{
|
||||
gl_Position = projection_matrix * view_matrix * model_matrix * vec4(in_position, 1);
|
||||
color = vec4(1 * in_color.rgb, 1);
|
||||
// color = vec4(1 * in_color.rgb, 0.2f);
|
||||
float zoom = 1.5f, chrominance = 1, luminance = 1;
|
||||
gl_Position =
|
||||
projection_matrix * view_matrix * model_matrix * vec4(in_position, zoom);
|
||||
color = vec4 (chrominance * in_color.rgb, luminance);
|
||||
}
|
Loading…
Reference in New Issue