WIP: Restructuration graphics/graphics in progress. Is OK.

This commit is contained in:
Jean Sirmai 2023-06-23 12:52:44 +02:00
parent 4d5aa2c993
commit 28c45295c6
Signed by: jean
GPG Key ID: FB3115C340E057E3
3 changed files with 499 additions and 45 deletions

View File

@ -0,0 +1,44 @@
/*
* Gem-graph OpenGL experiments
*
* Desc: OpenGL utils header
*
* Copyright (C) 2023 Jean Sirmai <jean@a-lec.org>
*
* This file is part of Gem-graph.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <unistd.h>
#include <stdbool.h>
#include <GL/glu.h>
int graphics_compute_lines(int line_indices_nb,
GLfloat *vertex_base, GLfloat *color_base,
GLubyte *line_ndx, int lines_nb,
int dim, int state_size,
int vertex_nb,
int colors_nb,
int arrows_nb);
int graphics_compute_plans(int plan_indices_nb,
GLfloat *vertex_base, GLfloat *color_base,
GLubyte *plan_ndx, int plans_nb,
int dim, int state_size,
int vertex_nb,
int colors_nb,
int arrows_nb);

View File

@ -0,0 +1,365 @@
/*
* Gem-graph OpenGL experiments
*
* Desc: OpenGL utils header
*
* Copyright (C) 2023 Jean Sirmai <jean@a-lec.org>
*
* This file is part of Gem-graph.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
//#pragma once
#include <unistd.h>
#include <stdbool.h>
#include <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_control.h"
#include "../../include/graphics_compute.h"
#include "../../include/space_2D.h"
#include "../../include/space_3D.h"
#include "../../include/arrow_2D.h"
#include "../../include/arrow_3D.h"
/* int dim = 0; */
/* int state_size = 0; */
/* int vertex_nb = 0; */
/* int colors_nb = 0; */
/* int lines_nb = 0; */
/* int plans_nb = 0; */
/* int arrows_nb = 0; */
#define 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) + 2; // + 2; pour les 2 diagonales
//// 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, line_indices_nb);
vgap += (12 * state_size); igap += state_size * 8 + 8; cgap += (12 * state_size);
/* assert(vgap < vertex_nb); assert(vgap + 9 < vertex_nb); */
/* assert(igap < entry->line_indices_nb); assert(igap + 5 < entry->line_indices_nb); */
/* compute_arrow_2D(state_size, vertex_base, color_base, */
/* line_ndx, plan_ndx, vgap, igap, cgap, 1, 0, 0, 0, 0); */
/* // if (A) printf("compute_arrow_2D vgap = %d vertex_nb = %d\n", vgap, vertex_nb); */
/* // if (A) printf("x = %d site = %d center = %f tip = %f base = %f\n",\ */
/* // x, site, center, tip, base); // vgap=%d igap=%d */
/* vgap += 9; igap += 6; cgap += 15; ++arrows_nb; */
/* assert(vgap < vertex_nb); assert(vgap + 9 < vertex_nb); */
/* assert(igap < entry->line_indices_nb); assert(igap + 5 < entry->line_indices_nb); */
/* compute_arrow_2D(state_size, vertex_base, color_base, */
/* line_ndx, plan_ndx, vgap, igap, cgap, 1, 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, plan_indices_nb);
vgap += (12 * state_size); igap += state_size * 8 + 8; cgap += (12 * state_size);
/* assert(vgap < vertex_nb); assert(vgap + 9 < vertex_nb); */
/* assert(igap < entry->line_indices_nb); assert(igap + 5 < entry->line_indices_nb); */
/* compute_arrow_2D(state_size, vertex_base, color_base, */
/* line_ndx, plan_ndx, vgap, igap, cgap, 1, 0, 0, 0, 0); */
/* // if (A) printf("compute_arrow_2D vgap = %d vertex_nb = %d\n", vgap, vertex_nb); */
/* // if (A) printf("x = %d site = %d center = %f tip = %f base = %f\n",\ */
/* // x, site, center, tip, base); // vgap=%d igap=%d */
/* vgap += 9; igap += 6; cgap += 15; ++arrows_nb; */
/* assert(vgap < vertex_nb); assert(vgap + 9 < vertex_nb); */
/* assert(igap < entry->line_indices_nb); assert(igap + 5 < entry->line_indices_nb); */
/* compute_arrow_2D(state_size, vertex_base, color_base, */
/* line_ndx, plan_ndx, vgap, igap, cgap, 1, 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;
/// }
}
}

View File

@ -52,15 +52,6 @@ GLfloat *vertex_base = NULL;
GLfloat *color_base = NULL;
GLubyte *line_ndx = NULL;
GLubyte *plan_ndx = NULL;
int dim = 0;
int state_size = 0;
int vertex_nb = 0;
int colors_nb = 0;
int lines_nb = 0;
int plans_nb = 0;
int arrows_nb = 0;
/* -------------------------------------------------------------------------- */
/*
* Prints verbose human-readable debug messages
@ -548,39 +539,82 @@ bool graphics_init_shaders(const void *gl_area)
return true;
}
/* -------------------------------------------------------------------------- */
int dim = 0;
int state_size = 0;
int vertex_nb = 0;
int colors_nb = 0;
int lines_nb = 0;
int plans_nb = 0;
int arrows_nb = 0;
bool pref_3D_xor_2D_space = 0; // default view == 0 == 3D
bool pref_3D_xor_2D_arrows = 0; // default view == 0 == 3D
bool pref_mark_unit_space_zero = 0; // default == no mark
/* -------------------------------------------------------------------------- */
static void get_model_data_and_user_preferences(){
// The model data to read
// {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 = 8; // 2 < state_size < 32
arrows_nb = 4; // assert : leur emplacement doit être fonction de state_size
pref_3D_xor_2D_space = 1; // default view == 0 == 3D
pref_3D_xor_2D_arrows = 1; // default view == 0 == 3D
pref_mark_unit_space_zero = 1; // default == 0 == no mark
}
static void compute_vertex_colors_lines_plans_nb(int dim,
int state_size,
int arrows_nb,
bool pref_3D_xor_2D_space,
bool pref_3D_xor_2D_arrows,
bool pref_mark_unit_space_zero,
struct gl_area_entry *entry){
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
printf("Prefer : mark_unit_space_zero = %d ", pref_mark_unit_space_zero);
if (pref_3D_xor_2D_space) lines_nb = (2 + state_size) + (arrows_nb * 3); // case 2D
else lines_nb = (4 + state_size * 4) + (arrows_nb * 8); // case 3D
if (pref_mark_unit_space_zero) lines_nb += 2; // 2 diagonal lines
//
plans_nb = 8; // (4 + state_size * 4) + (arrows_nb * 8) + 2;
entry->line_indices_nb = lines_nb * 2;
entry->plan_indices_nb = plans_nb * 3;
assert(state_size * 6 < vertex_nb); assert(state_size * 6 + 5 < vertex_nb);
printf("Initialization of buffers with %u line_ndx, %u vertices and %u colors & state_size = %d\n",
entry->line_indices_nb, vertex_nb, colors_nb, state_size);
}
/* Initializes the buffer of a gl_area
* Calls according to the user preferences
* @param gl_area, ptr to the gl_area widget
* Note : line_ndx[] is no more defined in graphics_cube.h
* @return void
*/
#define A 0
void graphics_init_buffers(const void *gl_area)
{
struct gl_area_entry *entry;
GLuint vao, vertex_buffer, color_buffer;
int vgap = 0, igap = 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 = 8; // 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
entry->line_indices_nb = lines_nb * 2;
entry->plan_indices_nb = plans_nb * 3;
printf("Initialization of buffers with %u line_ndx, %u vertices and %u colors & state_size = %d\n",
entry->line_indices_nb, vertex_nb, colors_nb, state_size);
get_model_data_and_user_preferences();
compute_vertex_colors_lines_plans_nb(dim, state_size, arrows_nb,
pref_3D_xor_2D_space,
pref_3D_xor_2D_arrows,
pref_mark_unit_space_zero,
entry);
// g_malloc
vertex_base = g_malloc0(vertex_nb * sizeof(GLfloat) * 2);
@ -588,22 +622,31 @@ void graphics_init_buffers(const void *gl_area)
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;
compute_space_2D(state_size, vertex_base, line_ndx);
int vgap = 0, igap = 0, cgap = 0, dgap = 0;
if (pref_mark_unit_space_zero) dgap = 4; // 4 vertices for 2 diagonal lines
//
vgap += (6 * state_size);
igap += state_size * 2 + dgap;
cgap += (6 * state_size);
if (pref_mark_unit_space_zero) { // diagonales pour marquer la case zéro
*(line_ndx + state_size * 2 + 6 + dgap + 0) = 0;
*(line_ndx + state_size * 2 + 6 + dgap + 1) = 3;
*(line_ndx + state_size * 2 + 6 + dgap + 2) = 1;
*(line_ndx + state_size * 2 + 6 + dgap + 3) = 2;
}
for (int k = 0; k < state_size; k++){
assert(k * 12 < vertex_nb); assert(k * 12 + 11 < vertex_nb);
assert(k * 12 < colors_nb); assert(k * 12 + 11 < colors_nb);
assert(k + 8 < entry->line_indices_nb); assert(k + 16 < entry->line_indices_nb);
}
compute_space_3D(state_size, vertex_base, color_base, line_ndx, entry->line_indices_nb);
vgap += (12 * state_size); igap += state_size * 8 + 8; cgap += (12 * state_size);
// compute_space_3D(state_size, vertex_base, color_base, line_ndx, entry->line_indices_nb);
// vgap += (12 * state_size); igap += state_size * 8 + 8; cgap += (12 * state_size);
/* assert(vgap < vertex_nb); assert(vgap + 9 < vertex_nb); */
/* assert(igap < entry->line_indices_nb); assert(igap + 5 < entry->line_indices_nb); */
@ -636,18 +679,20 @@ void graphics_init_buffers(const void *gl_area)
assert(igap < entry->line_indices_nb); assert(igap + 5 < entry->line_indices_nb);
compute_arrow_3D(state_size,
vertex_base, color_base,
line_ndx, plan_ndx,
vgap, igap, cgap,
1, 0, 0, 0, 0);
vgap += 15; igap += 16; cgap += 15; ++arrows_nb;
/* compute_arrow_3D(state_size, */
/* vertex_base, color_base, */
/* line_ndx, plan_ndx, */
/* vgap, igap, cgap, */
/* 1, 0, 0, 0, 0); */
/* vgap += 15; igap += 16; cgap += 15; ++arrows_nb; */
/* compute_arrow_3D(entry, state_size, vgap, igap, 1, 1, 2, 0, 0); vgap += 15; igap += 16; cgap += 15; ++arrows_nb; */
/* compute_arrow_3D(entry, state_size, vgap, igap, 1, 0, 3, 0, 0); vgap += 15; igap += 16; cgap += 15; ++arrows_nb; */
/* compute_arrow_3D(entry, state_size, vgap, igap, 1, 1, 3, 0, 0); vgap += 15; igap += 16; cgap += 15; ++arrows_nb; */
/* compute_arrow_3D(entry, state_size, vgap, igap, 1, 0, state_size - 2, 0, 0); vgap += 15; igap += 16; cgap += 15; ++arrows_nb; */
/* compute_arrow_3D(entry, state_size, vgap, igap, 1, 1, state_size - 2, 0, 0); vgap += 15; igap += 16; cgap += 15; ++arrows_nb; */
GLuint vao, vertex_buffer, color_buffer;
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);