WIP: Réorganisation de graphics.c création de space_2D.c et arrow_2D.c

This commit is contained in:
Jean Sirmai 2023-06-15 19:50:49 +02:00
parent 1c5f45d505
commit a0cce217b2
Signed by: jean
GPG Key ID: FB3115C340E057E3
8 changed files with 242 additions and 218 deletions

35
include/arrow_2D.h Normal file
View File

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

View File

@ -33,15 +33,15 @@
*/
struct gl_area_entry {
char name[16];
GLuint vao;
GLuint position_buffer;
GLuint color_buffer;
GLuint program;
GLuint m;
GLuint v;
GLuint p;
GLuint line_indices_nb;
GLuint plan_indices_nb;
GLuint vao; // init_buffers
GLuint position_buffer; // shutdown, draw
GLuint color_buffer; // shutdown, draw
GLuint program; // shutdown, init_shaders, draw
GLuint m; // init_shaders, draw
GLuint v; // init_shaders, draw
GLuint p; // init_shaders, draw
GLuint line_indices_nb; // init_buffers, draw, compute_space, arrow_2D, 3D
GLuint plan_indices_nb; // init_buffers, draw, compute_space, arrow_2D, 3D
};
/*

View File

@ -28,4 +28,4 @@
#include <stdbool.h>
#include <GL/glu.h>
// bool compute_space_2D(struct gl_area_entry *entry, int state_size);
bool compute_space_2D(int state_size, GLfloat *vertex_base, GLubyte *line_ndx);

67
src/graphics/arrow_2D.c Normal file
View File

@ -0,0 +1,67 @@
/*
* Gem-graph OpenGL experiments
*
* Desc: GL functions
*
* Copyright (C) 2023 Jean Sirmai <jean@a-lec.org>
*
* This file is part of Gem-graph.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <epoxy/gl.h>
bool compute_arrow_2D(int state_size,
GLfloat *vertex_base, GLfloat *color_base,
GLubyte *line_ndx, GLubyte *plan_ndx,
int vgap, int igap, int cgap,
int weight, int site, int x, int y, int z){
float zero = 0.0f;
float center = (1.0f / state_size) * (2 * x - state_size + 2);
// float tip = center + (2 * site - 1) * (1.0f / state_size);
float base = center + (2 * site - 1) * (0.1f / state_size);
*(vertex_base + vgap + 0) = center + (2 * site - 1) * (1.0f / state_size - 0.01f);
*(vertex_base + vgap + 1) = zero;
*(vertex_base + vgap + 2) = zero;
*(vertex_base + vgap + 3) = base;
*(vertex_base + vgap + 4) = 0.4f / state_size;
*(vertex_base + vgap + 5) = zero;
*(vertex_base + vgap + 6) = base;
*(vertex_base + vgap + 7) = - 0.4f / state_size;
*(vertex_base + vgap + 8) = zero;
*(line_ndx + igap + 0) = vgap / 3 + 0;
*(line_ndx + igap + 1) = vgap / 3 + 1;
*(line_ndx + igap + 2) = vgap / 3 + 0;
*(line_ndx + igap + 3) = vgap / 3 + 2;
*(line_ndx + igap + 4) = vgap / 3 + 1;
*(line_ndx + igap + 5) = vgap / 3 + 2;
*(plan_ndx + 0) = vgap / 3 + 0;
*(plan_ndx + 1) = vgap / 3 + 1;
*(plan_ndx + 2) = vgap / 3 + 2;
*(plan_ndx + 3) = vgap / 3 + 0;
*(plan_ndx + 4) = vgap / 3 + 1;
*(plan_ndx + 5) = vgap / 3 + 2;
return 1;
}

View File

@ -5,6 +5,7 @@
*
* Copyright (C) 2023 Arthur Menges <arthur.menges@a-lec.org>
* Copyright (C) 2023 Adrien Bourmault <neox@a-lec.org>
* Copyright (C) 2023 Jean Sirmai <jean@a-lec.org>
*
* This file is part of Gem-graph.
*
@ -37,8 +38,9 @@
#include "../../include/base.h"
#include "../../include/ui.h"
#include "../../include/graphics.h"
#include "../../include/graphics_control.h"
#include "../../include/space_2D.h"
#include "../../include/arrow_2D.h"
#define VERTEX_SHADER_FILE "src/shaders/shader.vert"
#define FRAG_SHADER_FILE "src/shaders/shader.frag"
@ -544,55 +546,50 @@ bool graphics_init_shaders(const void *gl_area)
return true;
}
/* #define A 0 */
/* static bool compute_arrow_2D(int state_size, int vgap, int igap, int cgap, int weight, int site, int x, int y, int z){ */
/* float zero = 0.0f; */
/* float center = (1.0f / state_size) * (2 * x - state_size + 2); */
/* float tip = center + (2 * site - 1) * (1.0f / state_size); */
/* float base = center + (2 * site - 1) * (0.1f / state_size); */
/* printf("compute_arrow_2D vgap = %d vertex_nb = %d\n", vgap, vertex_nb); */
/* *(vertex_base + vgap + 0) = center + (2 * site - 1) * (1.0f / state_size - 0.01f); */
/* *(vertex_base + vgap + 1) = zero; */
/* *(vertex_base + vgap + 2) = zero; */
/* *(vertex_base + vgap + 3) = base; */
/* *(vertex_base + vgap + 4) = 0.4f / state_size; */
/* *(vertex_base + vgap + 5) = zero; */
/* *(vertex_base + vgap + 6) = base; */
/* *(vertex_base + vgap + 7) = - 0.4f / state_size; */
/* *(vertex_base + vgap + 8) = zero; */
/* if (A) printf("x = %d site = %d center = %f tip = %f base = %f\n",\ */
/* x, site, center, tip, base); // vgap=%d igap=%d */
/* *(line_ndx + igap + 0) = vgap / 3 + 0; */
/* *(line_ndx + igap + 1) = vgap / 3 + 1; */
/* *(line_ndx + igap + 2) = vgap / 3 + 0; */
/* *(line_ndx + igap + 3) = vgap / 3 + 2; */
/* *(line_ndx + igap + 4) = vgap / 3 + 1; */
/* *(line_ndx + igap + 5) = vgap / 3 + 2; */
/* *(plan_ndx + 0) = vgap / 3 + 0; */
/* *(plan_ndx + 1) = vgap / 3 + 1; */
/* *(plan_ndx + 2) = vgap / 3 + 2; */
/* *(plan_ndx + 3) = vgap / 3 + 0; */
/* *(plan_ndx + 4) = vgap / 3 + 1; */
/* *(plan_ndx + 5) = vgap / 3 + 2; */
/* return 1; */
/* } */
#define A 0
static bool compute_arrow_2D(struct gl_area_entry *entry, int state_size, int vgap, int igap, int weight, int site, int x, int y, int z){
float zero = 0.0f;
float center = (1.0f / state_size) * (2 * x - state_size + 2);
float tip = center + (2 * site - 1) * (1.0f / state_size);
float base = center + (2 * site - 1) * (0.1f / state_size);
printf("compute_arrow_2D vgap = %d vertex_nb = %d\n", vgap, vertex_nb);
assert(vgap < vertex_nb);
assert(vgap + 9 < vertex_nb);
*(vertex_base + vgap + 0) = center + (2 * site - 1) * (1.0f / state_size - 0.01f);
*(vertex_base + vgap + 1) = zero;
*(vertex_base + vgap + 2) = zero;
*(vertex_base + vgap + 3) = base;
*(vertex_base + vgap + 4) = 0.4f / state_size;
*(vertex_base + vgap + 5) = zero;
*(vertex_base + vgap + 6) = base;
*(vertex_base + vgap + 7) = - 0.4f / state_size;
*(vertex_base + vgap + 8) = zero;
if (A) printf("x = %d site = %d center = %f tip = %f base = %f\n",\
x, site, center, tip, base); // vgap=%d igap=%d
assert(igap < entry->line_indices_nb);
assert(igap + 5 < entry->line_indices_nb);
*(line_ndx + igap + 0) = vgap / 3 + 0;
*(line_ndx + igap + 1) = vgap / 3 + 1;
*(line_ndx + igap + 2) = vgap / 3 + 0;
*(line_ndx + igap + 3) = vgap / 3 + 2;
*(line_ndx + igap + 4) = vgap / 3 + 1;
*(line_ndx + igap + 5) = vgap / 3 + 2;
*(plan_ndx + 0) = vgap / 3 + 0;
*(plan_ndx + 1) = vgap / 3 + 1;
*(plan_ndx + 2) = vgap / 3 + 2;
*(plan_ndx + 3) = vgap / 3 + 0;
*(plan_ndx + 4) = vgap / 3 + 1;
*(plan_ndx + 5) = vgap / 3 + 2;
return 1;
}
static bool compute_arrow_3D(struct gl_area_entry *entry, int state_size, int vgap, int igap, int weight, int site, int x, int y, int z){
float zero = 0.0f;
@ -661,63 +658,6 @@ static bool compute_arrow_3D(struct gl_area_entry *entry, int state_size, int vg
#define V 1
#define I 0
#define EDGE 0.999999
static bool compute_space_2D(struct gl_area_entry *entry, int state_size){
float x = 0;
// for (int k = 0; k < state_size + 1; k++) <=> + 1 car
// on passe du nombre de cases = (n)
// au nombre de séparations entre les cases + les deux bords = (n + 1)
if (V) printf("vertices ");
for (int k = 0; k < state_size; k++){ // barres verticales
//
x = ((state_size % 2) * (state_size / 2 - k)
+ (state_size % 2 - 1) * (k + 0.5f - state_size / 2)) / state_size * 2 * EDGE;
if (V) printf("[%1.1f] ", x);
assert(k * 6 < vertex_nb);
assert(k * 6 + 5 < vertex_nb);
*(vertex_base + k * 6 + 0) = - x;
*(vertex_base + k * 6 + 1) = 1.0f / state_size;
*(vertex_base + k * 6 + 2) = 0.0f;
*(vertex_base + k * 6 + 3) = - x;
*(vertex_base + k * 6 + 4) = - 1.0f / state_size;
*(vertex_base + k * 6 + 5) = 0.0f;
}
if (V) printf(" n = %d x 2 côté = [%1.1f]\n", state_size + 1, 2.0f / state_size);
*(line_ndx + 0) = 0;
*(line_ndx + 1) = state_size * 2 - 2; // barre horizontale du bas
*(line_ndx + 2) = 1;
*(line_ndx + 3) = state_size * 2 - 1; // barre horizontale du haut
for (int k = 0; k < state_size * 2; k++){
assert(k < entry->line_indices_nb);
assert(k + 4 < entry->line_indices_nb);
*(line_ndx + k + 4) = k;
}
/* *(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; */
if (I) printf("line_ndx (%d - state_size(0)) x (%d - state_size(1)) ", 0, 1);
for (int v = 0; v < state_size + 2; v++) {
if (I) printf("(%d-%d) ", *(line_ndx + v), *(line_ndx + v + 1));
}
if (I) printf(" n = 4 + (%d x 2)\n", state_size + 2);
return 1;
}
static bool compute_space_3D(struct gl_area_entry *entry, int state_size){
@ -844,12 +784,13 @@ static bool compute_space_3D(struct gl_area_entry *entry, int 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 defined in graphics_cube.h
* 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;
@ -858,16 +799,16 @@ void graphics_init_buffers(const void *gl_area)
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};
// {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 = 13; // 2 < state_size < 32
arrows_nb = 4;
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);
lines_nb = (4 + state_size * 4) + (arrows_nb * 8) + 2; // + 2; pour les 2 diagonales
// 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;
@ -882,16 +823,43 @@ 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);
compute_space_2D(entry, state_size); vgap += (6 * state_size); igap += state_size * 2 + 4; cgap += (6 * state_size);
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_3D(entry, state_size); vgap += (12 * state_size); igap += state_size * 8 + 8; cgap += (12 * state_size);
compute_arrow_2D(entry, state_size, vgap, igap, 1, 0, 0, 0, 0); vgap += 9; igap += 6; cgap += 15; ++arrows_nb;
compute_arrow_2D(entry, state_size, vgap, igap, 1, 1, 2, 0, 0); vgap += 9; igap += 6; cgap += 15; ++arrows_nb;
compute_arrow_2D(entry, state_size, vgap, igap, 1, 0, 3, 0, 0); vgap += 9; igap += 6; cgap += 15; ++arrows_nb;
/* compute_arrow_2D(entry, state_size, vgap, igap, 1, 1, 3, 0, 0); vgap += 9; igap += 6; cgap += 15; ++arrows_nb; */
/* compute_arrow_2D(entry, state_size, vgap, igap, 1, 0, state_size - 2, 0, 0); vgap += 9; igap += 6; cgap += 15; ++arrows_nb; */
compute_arrow_2D(entry, state_size, vgap, igap, 1, 1, state_size - 2, 0, 0); vgap += 9; igap += 6; cgap += 15; ++arrows_nb;
assert(vgap < vertex_nb); assert(vgap + 9 < vertex_nb);
assert(igap < entry->line_indices_nb); assert(igap + 5 < entry->line_indices_nb);
compute_arrow_2D(state_size, vertex_base, color_base,
line_ndx, plan_ndx, vgap, igap, cgap, 1, 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;
/* compute_arrow_3D(entry, state_size, vgap, igap, 1, 0, 0, 0, 0); vgap += 15; igap += 16; cgap += 15; ++arrows_nb; */
/* compute_arrow_3D(entry, state_size, vgap, igap, 1, 1, 2, 0, 0); vgap += 15; igap += 16; cgap += 15; ++arrows_nb; */
@ -900,10 +868,6 @@ void graphics_init_buffers(const void *gl_area)
/* 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; */
// We only use one VAO, so we always keep it bound
glGenVertexArrays(1, &vao);
glBindVertexArray(vao);
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);
@ -916,6 +880,10 @@ void graphics_init_buffers(const void *gl_area)
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;
@ -945,7 +913,6 @@ void graphics_draw(const void *gl_area)
return;
}
/* Compute the model view projection matrix using the
* rotation angles specified through the GtkRange widgets
*/
@ -956,12 +923,12 @@ void graphics_draw(const void *gl_area)
compute_i(m);
compute_i(v);
glClearColor(0.3f, 0, 0, 0.8f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
/* Use our shaders */
glUseProgram(entry->program);
glClearColor(0.3f, 0, 0, 0.8f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
/* Update the "mvp" matrix we use in the shader */
glUniformMatrix4fv(entry->m, 1, GL_FALSE, &m[0]);
glUniformMatrix4fv(entry->v, 1, GL_FALSE, &v[0]);

View File

@ -3,8 +3,6 @@
*
* Desc: GL functions
*
* Copyright (C) 2023 Arthur Menges <arthur.menges@a-lec.org>
* Copyright (C) 2023 Adrien Bourmault <neox@a-lec.org>
* Copyright (C) 2023 Jean Sirmai <jean@a-lec.org>
*
* This file is part of Gem-graph.
@ -23,97 +21,54 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#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"
#define V 1
#define I 0
#define EDGE 0.999999
bool compute_space_2D(int state_size,
GLfloat *vertex_base, GLubyte *line_ndx){
#define VERTEX_SHADER_FILE "src/shaders/shader.vert"
#define FRAG_SHADER_FILE "src/shaders/shader.frag"
#define K 0
float x = 0;
// for (int k = 0; k < state_size + 1; k++) <=> + 1
// car on passe du nombre de cases = (n)
// au nombre de séparations entre les cases + les deux bords = (n + 1)
/* 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; */
if (V) printf("vertices ");
for (int k = 0; k < state_size; k++){ // barres verticales
//
x = ((state_size % 2) * (state_size / 2 - k)
+ (state_size % 2 - 1) * (k + 0.5f - state_size / 2)) / state_size * 2 * EDGE;
/* #define V 1 */
/* #define I 0 */
/* #define EDGE 0.999999 */
/* bool compute_space_2D(struct gl_area_entry *entry, int state_size){ */
if (V) printf("[%1.1f] ", x);
/* float x = 0; */
/* // for (int k = 0; k < state_size + 1; k++) <=> + 1 car */
/* // on passe du nombre de cases = (n) */
/* // au nombre de séparations entre les cases + les deux bords = (n + 1) */
*(vertex_base + k * 6 + 0) = - x;
*(vertex_base + k * 6 + 1) = 1.0f / state_size;
*(vertex_base + k * 6 + 2) = 0.0f;
/* if (V) printf("vertices "); */
/* for (int k = 0; k < state_size; k++){ // barres verticales */
/* // */
/* x = ((state_size % 2) * (state_size / 2 - k) */
/* + (state_size % 2 - 1) * (k + 0.5f - state_size / 2)) / state_size * 2 * EDGE; */
*(vertex_base + k * 6 + 3) = - x;
*(vertex_base + k * 6 + 4) = - 1.0f / state_size;
*(vertex_base + k * 6 + 5) = 0.0f;
}
/* if (V) printf("[%1.1f] ", x); */
if (V) printf(" n = %d x 2 côté = [%1.1f]\n", state_size + 1, 2.0f / state_size);
/* assert(k * 6 < vertex_nb); */
/* assert(k * 6 + 5 < vertex_nb); */
*(line_ndx + 0) = 0;
*(line_ndx + 1) = state_size * 2 - 2; // barre horizontale du bas
/* *(vertex_base + k * 6 + 0) = - x; */
/* *(vertex_base + k * 6 + 1) = 1.0f / state_size; */
/* *(vertex_base + k * 6 + 2) = 0.0f; */
*(line_ndx + 2) = 1;
*(line_ndx + 3) = state_size * 2 - 1; // barre horizontale du haut
/* *(vertex_base + k * 6 + 3) = - x; */
/* *(vertex_base + k * 6 + 4) = - 1.0f / state_size; */
/* *(vertex_base + k * 6 + 5) = 0.0f; */
/* } */
for (int k = 0; k < state_size * 2; k++) *(line_ndx + k + 4) = k;
/* if (V) printf(" n = %d x 2 côté = [%1.1f]\n", state_size + 1, 2.0f / state_size); */
if (I) printf("line_ndx (%d - state_size(0)) x (%d - state_size(1)) ", 0, 1);
for (int v = 0; v < state_size + 2; v++) {
if (I) printf("(%d-%d) ", *(line_ndx + v), *(line_ndx + v + 1));
}
/* *(line_ndx + 0) = 0; */
/* *(line_ndx + 1) = state_size * 2 - 2; // barre horizontale du bas */
if (I) printf(" n = 4 + (%d x 2)\n", state_size + 2);
/* *(line_ndx + 2) = 1; */
/* *(line_ndx + 3) = state_size * 2 - 1; // barre horizontale du haut */
/* for (int k = 0; k < state_size * 2; k++){ */
/* assert(k < entry->line_indices_nb); */
/* assert(k + 4 < entry->line_indices_nb); */
/* *(line_ndx + k + 4) = k; */
/* } */
/* *(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; */
/* if (I) printf("line_ndx (%d - state_size(0)) x (%d - state_size(1)) ", 0, 1); */
/* for (int v = 0; v < state_size + 2; v++) { */
/* if (I) printf("(%d-%d) ", *(line_ndx + v), *(line_ndx + v + 1)); */
/* } */
/* if (I) printf(" n = 4 + (%d x 2)\n", state_size + 2); */
/* return 1; */
/* } */
return 1;
}

View File

@ -25,7 +25,7 @@
#include <stdio.h>
#include "../../include/base.h"
#include "../../include/graphics.h"
#include "../../include/graphics_control.h"
#include "../../include/ui.h"