WIP: OK space 2D 3D (pas arrow)
This commit is contained in:
parent
eaa39dc29f
commit
5d5998c5d6
|
@ -5,6 +5,7 @@
|
||||||
*
|
*
|
||||||
* Copyright (C) 2023 Arthur Menges <arthur.menges@a-lec.org>
|
* Copyright (C) 2023 Arthur Menges <arthur.menges@a-lec.org>
|
||||||
* Copyright (C) 2023 Adrien Bourmault <neox@a-lec.org>
|
* Copyright (C) 2023 Adrien Bourmault <neox@a-lec.org>
|
||||||
|
* Copyright (C) 2023 Jean Sirmai <jean@a-lec.org>
|
||||||
*
|
*
|
||||||
* This file is part of Gem-graph.
|
* This file is part of Gem-graph.
|
||||||
*
|
*
|
|
@ -29,4 +29,5 @@
|
||||||
bool compute_space_2D(int state_size,
|
bool compute_space_2D(int state_size,
|
||||||
GLfloat *vertex_base, GLfloat *color_base,
|
GLfloat *vertex_base, GLfloat *color_base,
|
||||||
GLubyte *line_ndx,
|
GLubyte *line_ndx,
|
||||||
bool pref_mark_unit_space_zero, int dgap);
|
bool pref_mark_unit_space_first,
|
||||||
|
bool pref_mark_unit_space_last);
|
||||||
|
|
|
@ -29,4 +29,5 @@
|
||||||
bool compute_space_3D(int state_size,
|
bool compute_space_3D(int state_size,
|
||||||
GLfloat *vertex_base, GLfloat *color_base,
|
GLfloat *vertex_base, GLfloat *color_base,
|
||||||
GLubyte *line_ndx,
|
GLubyte *line_ndx,
|
||||||
bool pref_mark_unit_space_zero, int dgap);
|
bool pref_mark_unit_space_first,
|
||||||
|
bool pref_mark_unit_space_last);
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
* Desc: OpenGL utils header
|
* Desc: OpenGL utils header
|
||||||
*
|
*
|
||||||
* Copyright (C) 2023 Jean Sirmai <jean@a-lec.org>
|
* Copyright (C) 2023 Jean Sirmai <jean@a-lec.org>
|
||||||
|
* Copyleft (something) ( ;- )) Isn't that fun ?! ----------------,cbF@^@ââ63-OPM,FJ&_(_((T^RQJn||lpv)=à)o -----------------------------------------------------
|
||||||
*
|
*
|
||||||
* This file is part of Gem-graph.
|
* This file is part of Gem-graph.
|
||||||
*
|
*
|
||||||
|
@ -39,8 +40,8 @@
|
||||||
|
|
||||||
#include "../../include/base.h"
|
#include "../../include/base.h"
|
||||||
#include "../../include/ui.h"
|
#include "../../include/ui.h"
|
||||||
#include "../../include/graphics_control.h"
|
#include "../../include/graphics.h"
|
||||||
#include "../../include/graphics_compute.h"
|
#include "../../include/buffers.h"
|
||||||
#include "../../include/space_2D.h"
|
#include "../../include/space_2D.h"
|
||||||
#include "../../include/space_3D.h"
|
#include "../../include/space_3D.h"
|
||||||
#include "../../include/arrow_2D.h"
|
#include "../../include/arrow_2D.h"
|
||||||
|
@ -70,7 +71,7 @@ int graphics_compute_lines(int line_indices_nb,
|
||||||
vertex_nb = (state_size + 1) * 12 + arrows_nb * 15;
|
vertex_nb = (state_size + 1) * 12 + arrows_nb * 15;
|
||||||
colors_nb = (state_size + 1) * 12 + arrows_nb * 0; // TODO
|
colors_nb = (state_size + 1) * 12 + arrows_nb * 0; // TODO
|
||||||
// lines_nb = (2 + state_size) + (arrows_nb * 3); // cas 2D
|
// lines_nb = (2 + state_size) + (arrows_nb * 3); // cas 2D
|
||||||
lines_nb = (4 + state_size * 4) + (arrows_nb * 8) + 2; // + 2; pour les 2 diagonales
|
lines_nb = (4 + state_size * 4) + (arrows_nb * 8) + 4; // + 4; pour les 4 diagonales (29/6/2023 pour voir)
|
||||||
//// plans_nb = 8; //(4 + state_size * 4) + (arrows_nb * 8) + 2; // bhuingfyunfyuguinlgi svbysbubsyu qvyqytqujtvcttcef
|
//// plans_nb = 8; //(4 + state_size * 4) + (arrows_nb * 8) + 2; // bhuingfyunfyuguinlgi svbysbubsyu qvyqytqujtvcttcef
|
||||||
|
|
||||||
line_indices_nb = lines_nb * 2;
|
line_indices_nb = lines_nb * 2;
|
||||||
|
@ -100,7 +101,7 @@ int graphics_compute_lines(int line_indices_nb,
|
||||||
}
|
}
|
||||||
|
|
||||||
compute_space_3D(state_size, vertex_base, color_base, line_ndx,
|
compute_space_3D(state_size, vertex_base, color_base, line_ndx,
|
||||||
0,4); // patch provisoire
|
0,0); // patch provisoire
|
||||||
// pref_mark_unit_space_zero, dgap){
|
// pref_mark_unit_space_zero, dgap){
|
||||||
vgap += (12 * state_size); igap += state_size * 8 + 8; cgap += (12 * state_size);
|
vgap += (12 * state_size); igap += state_size * 8 + 8; cgap += (12 * state_size);
|
||||||
|
|
||||||
|
@ -256,7 +257,7 @@ int graphics_compute_plans(int plan_indices_nb,
|
||||||
// assert(k + 8 < line_indices_nb); assert(k + 16 < line_indices_nb);
|
// assert(k + 8 < line_indices_nb); assert(k + 16 < line_indices_nb);
|
||||||
|
|
||||||
compute_space_3D(state_size, vertex_base, color_base, plan_ndx,
|
compute_space_3D(state_size, vertex_base, color_base, plan_ndx,
|
||||||
0,4); // patch provisoire
|
0,0); // patch provisoire
|
||||||
//pref_mark_unit_space_zero, dgap){
|
//pref_mark_unit_space_zero, dgap){
|
||||||
|
|
||||||
vgap += (12 * state_size); igap += state_size * 8 + 8; cgap += (12 * state_size);
|
vgap += (12 * state_size); igap += state_size * 8 + 8; cgap += (12 * state_size);
|
|
@ -38,7 +38,7 @@
|
||||||
|
|
||||||
#include "../../include/base.h"
|
#include "../../include/base.h"
|
||||||
#include "../../include/ui.h"
|
#include "../../include/ui.h"
|
||||||
#include "../../include/graphics_control.h"
|
#include "../../include/graphics.h"
|
||||||
#include "../../include/space_2D.h"
|
#include "../../include/space_2D.h"
|
||||||
#include "../../include/space_3D.h"
|
#include "../../include/space_3D.h"
|
||||||
#include "../../include/arrow_2D.h"
|
#include "../../include/arrow_2D.h"
|
||||||
|
@ -493,9 +493,12 @@ int colors_nb = 0;
|
||||||
int lines_nb = 0;
|
int lines_nb = 0;
|
||||||
int plans_nb = 0;
|
int plans_nb = 0;
|
||||||
int arrows_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_3D_xor_2D_space = 0; // default view == 0 == 3D
|
||||||
bool pref_mark_unit_space_zero = 0; // default == 0 == no mark
|
bool pref_3D_xor_2D_arrows = 0; // default view == 0 == 3D
|
||||||
|
bool pref_mark_unit_space_first = 0; // default == 0 == no mark
|
||||||
|
bool pref_mark_unit_space_last = 0; // default == 0 == no mark
|
||||||
|
bool pref_background_color = 0; // don't know yet...
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
@ -504,11 +507,13 @@ static void get_model_data_and_user_preferences(){
|
||||||
// { 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 };
|
||||||
|
|
||||||
dim = 1;
|
dim = 1;
|
||||||
state_size = 9; // 2 < state_size < 32
|
state_size = 8; // 2 < state_size < 32
|
||||||
arrows_nb = 4; // assert : leur emplacement doit être fonction de state_size
|
arrows_nb = 4; // assert : leur emplacement doit être fonction de state_size
|
||||||
pref_3D_xor_2D_space = 0; // default == 0 == 3D
|
pref_3D_xor_2D_space = 0; // default == 0 == 3D
|
||||||
pref_3D_xor_2D_arrows = 1; // default == 0 == 3D
|
pref_3D_xor_2D_arrows = 1; // default == 0 == 3D
|
||||||
pref_mark_unit_space_zero = 1; // default == 0 == no mark
|
pref_mark_unit_space_first = 1; // default == 0 == no mark
|
||||||
|
pref_mark_unit_space_last = 1; // default == 0 == no mark
|
||||||
|
pref_background_color = 0; // TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
static void compute_vertex_colors_lines_plans_nb(int dim,
|
static void compute_vertex_colors_lines_plans_nb(int dim,
|
||||||
|
@ -516,16 +521,19 @@ static void compute_vertex_colors_lines_plans_nb(int dim,
|
||||||
int arrows_nb,
|
int arrows_nb,
|
||||||
bool pref_3D_xor_2D_space,
|
bool pref_3D_xor_2D_space,
|
||||||
bool pref_3D_xor_2D_arrows,
|
bool pref_3D_xor_2D_arrows,
|
||||||
bool pref_mark_unit_space_zero,
|
bool pref_mark_unit_space_first,
|
||||||
|
bool pref_mark_unit_space_last,
|
||||||
struct gl_area_entry *entry){
|
struct gl_area_entry *entry){
|
||||||
|
|
||||||
if (pref_3D_xor_2D_space) vertex_nb = (state_size + 1) * 6 + arrows_nb * 9; // case 2D
|
if (pref_3D_xor_2D_space) vertex_nb = (state_size + 1) * 6 + arrows_nb * 9; // case 2D
|
||||||
else vertex_nb = (state_size + 1) * 12 + arrows_nb * 15; // case 3D
|
else vertex_nb = (state_size + 1) * 12 + arrows_nb * 15; // case 3D
|
||||||
|
|
||||||
if (pref_3D_xor_2D_space) lines_nb = (2 + state_size) + (arrows_nb * 3); // case 2D
|
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
|
else lines_nb = (4 + state_size * 4) + (arrows_nb * 8); // case 3D
|
||||||
|
|
||||||
if (pref_mark_unit_space_zero) lines_nb += 2; // 2 diagonal lines
|
if (pref_mark_unit_space_first) lines_nb += 2; // 2 diagonal lines
|
||||||
//
|
if (pref_mark_unit_space_last) lines_nb += 2; // 2 diagonal lines
|
||||||
|
|
||||||
plans_nb = 8; // (4 + state_size * 4) + (arrows_nb * 8) + 2;
|
plans_nb = 8; // (4 + state_size * 4) + (arrows_nb * 8) + 2;
|
||||||
|
|
||||||
entry->line_indices_nb = lines_nb * 2;
|
entry->line_indices_nb = lines_nb * 2;
|
||||||
|
@ -535,10 +543,10 @@ static void compute_vertex_colors_lines_plans_nb(int dim,
|
||||||
|
|
||||||
assert(state_size * 6 < vertex_nb); assert(state_size * 6 + 5 < vertex_nb);
|
assert(state_size * 6 < vertex_nb); assert(state_size * 6 + 5 < vertex_nb);
|
||||||
|
|
||||||
printf("Prefer : mark_unit_space_zero = %d pref_3D_xor_2D_space = %d state_size = %d\n",
|
printf("Prefer : mark_unit_space_first = %d mark_unit_space_last = %d 3D_xor_2D_space = %d\n",
|
||||||
pref_mark_unit_space_zero, pref_3D_xor_2D_space, state_size);
|
pref_mark_unit_space_first, pref_mark_unit_space_last, pref_3D_xor_2D_space);
|
||||||
|
|
||||||
printf("Initialization of buffers with %u line_ndx, %u vertices and %u colors & state_size = %d\n",
|
printf("Initialization of buffers with %u line_ndx, %u vertices, %u colors. state_size = %d\n",
|
||||||
entry->line_indices_nb, vertex_nb, colors_nb, state_size);
|
entry->line_indices_nb, vertex_nb, colors_nb, state_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -558,7 +566,8 @@ void graphics_init_buffers(const void *gl_area)
|
||||||
compute_vertex_colors_lines_plans_nb(dim, state_size, arrows_nb,
|
compute_vertex_colors_lines_plans_nb(dim, state_size, arrows_nb,
|
||||||
pref_3D_xor_2D_space,
|
pref_3D_xor_2D_space,
|
||||||
pref_3D_xor_2D_arrows,
|
pref_3D_xor_2D_arrows,
|
||||||
pref_mark_unit_space_zero,
|
pref_mark_unit_space_first,
|
||||||
|
pref_mark_unit_space_last,
|
||||||
entry);
|
entry);
|
||||||
|
|
||||||
// g_malloc
|
// g_malloc
|
||||||
|
@ -570,7 +579,8 @@ void graphics_init_buffers(const void *gl_area)
|
||||||
|
|
||||||
int vgap = 0, igap = 0, cgap = 0, dgap = 0;
|
int vgap = 0, igap = 0, cgap = 0, dgap = 0;
|
||||||
|
|
||||||
if (pref_mark_unit_space_zero) dgap = 4; // 4 vertices for 2 diagonal lines
|
if (pref_mark_unit_space_first) dgap += 4; // 4 vertices for 2 diagonal lines
|
||||||
|
if (pref_mark_unit_space_last) dgap += 4; // 4 vertices for 2 diagonal lines
|
||||||
vgap += (6 * state_size);
|
vgap += (6 * state_size);
|
||||||
igap += state_size * 2 + dgap;
|
igap += state_size * 2 + dgap;
|
||||||
cgap += (6 * state_size);
|
cgap += (6 * state_size);
|
||||||
|
@ -578,18 +588,24 @@ void graphics_init_buffers(const void *gl_area)
|
||||||
if (pref_3D_xor_2D_space) compute_space_2D(state_size,
|
if (pref_3D_xor_2D_space) compute_space_2D(state_size,
|
||||||
vertex_base, color_base,
|
vertex_base, color_base,
|
||||||
line_ndx,
|
line_ndx,
|
||||||
pref_mark_unit_space_zero, dgap);
|
pref_mark_unit_space_first,
|
||||||
|
pref_mark_unit_space_last);
|
||||||
|
|
||||||
else compute_space_3D(state_size,
|
else compute_space_3D(state_size,
|
||||||
vertex_base, color_base,
|
vertex_base, color_base,
|
||||||
line_ndx,
|
line_ndx,
|
||||||
pref_mark_unit_space_zero, dgap);
|
pref_mark_unit_space_first,
|
||||||
|
pref_mark_unit_space_last);
|
||||||
|
|
||||||
for (int k = 0; k < state_size; k++){
|
if (pref_3D_xor_2D_space) for (int k = 0; k < state_size; k++) {
|
||||||
|
assert(k * 6 < vertex_nb); assert(k * 6 + 5 < vertex_nb);
|
||||||
|
assert(k * 6 < colors_nb); assert(k * 6 + 5 < colors_nb);
|
||||||
|
assert(k + 4 < entry->line_indices_nb); assert(k + 8 < entry->line_indices_nb); // TODO check this line !
|
||||||
|
} else for (int k = 0; k < state_size; k++) {
|
||||||
assert(k * 12 < vertex_nb); assert(k * 12 + 11 < vertex_nb);
|
assert(k * 12 < vertex_nb); assert(k * 12 + 11 < vertex_nb);
|
||||||
assert(k * 12 < colors_nb); assert(k * 12 + 11 < colors_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);
|
assert(k + 8 < entry->line_indices_nb); assert(k + 16 < entry->line_indices_nb); // TODO check this line !
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(vgap < vertex_nb); assert(vgap + 9 < vertex_nb);
|
assert(vgap < vertex_nb); assert(vgap + 9 < vertex_nb);
|
||||||
assert(igap < entry->line_indices_nb); assert(igap + 5 < entry->line_indices_nb);
|
assert(igap < entry->line_indices_nb); assert(igap + 5 < entry->line_indices_nb);
|
||||||
|
@ -667,7 +683,8 @@ void graphics_draw(const void *gl_area)
|
||||||
/* Use our shaders */
|
/* Use our shaders */
|
||||||
glUseProgram(entry->program);
|
glUseProgram(entry->program);
|
||||||
|
|
||||||
glClearColor(0, 0, 0, 0.2f); // glClearColor(0.3f, 0, 0, 0.8f);
|
if (pref_background_color == 0) glClearColor(0, 0, 0, 0.4f);
|
||||||
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
/* Update the "mvp" matrix we use in the shader */
|
/* Update the "mvp" matrix we use in the shader */
|
|
@ -30,7 +30,9 @@
|
||||||
bool compute_space_2D(int state_size,
|
bool compute_space_2D(int state_size,
|
||||||
GLfloat *vertex_base, GLfloat *color_base,
|
GLfloat *vertex_base, GLfloat *color_base,
|
||||||
GLubyte *line_ndx,
|
GLubyte *line_ndx,
|
||||||
bool pref_mark_unit_space_zero, int dgap){
|
bool pref_mark_unit_space_first,
|
||||||
|
bool pref_mark_unit_space_last)
|
||||||
|
{
|
||||||
|
|
||||||
float x = 0;
|
float x = 0;
|
||||||
// for (int k = 0; k < state_size + 1; k++) <=> + 1
|
// for (int k = 0; k < state_size + 1; k++) <=> + 1
|
||||||
|
@ -52,8 +54,32 @@ bool compute_space_2D(int state_size,
|
||||||
*(vertex_base + k * 6 + 3) = - x;
|
*(vertex_base + k * 6 + 3) = - x;
|
||||||
*(vertex_base + k * 6 + 4) = - 1.0f / state_size;
|
*(vertex_base + k * 6 + 4) = - 1.0f / state_size;
|
||||||
*(vertex_base + k * 6 + 5) = 0.0f;
|
*(vertex_base + k * 6 + 5) = 0.0f;
|
||||||
|
|
||||||
|
*(color_base + k * 6 + 0) = 1;
|
||||||
|
*(color_base + k * 6 + 1) = 0;
|
||||||
|
*(color_base + k * 6 + 2) = 0;
|
||||||
|
|
||||||
|
*(color_base + k * 6 + 3) = 1;
|
||||||
|
*(color_base + k * 6 + 4) = 1;
|
||||||
|
*(color_base + k * 6 + 5) = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*(color_base + 0) = 0;
|
||||||
|
*(color_base + 1) = 0;
|
||||||
|
*(color_base + 2) = 0;
|
||||||
|
|
||||||
|
*(color_base + 3) = 1;
|
||||||
|
*(color_base + 4) = 1;
|
||||||
|
*(color_base + 5) = 1;
|
||||||
|
|
||||||
|
*(color_base + (state_size - 1) * 6 + 0) = 1;
|
||||||
|
*(color_base + (state_size - 1) * 6 + 1) = 1;
|
||||||
|
*(color_base + (state_size - 1) * 6 + 2) = 1;
|
||||||
|
|
||||||
|
*(color_base + (state_size - 1) * 6 + 3) = 0;
|
||||||
|
*(color_base + (state_size - 1) * 6 + 4) = 0;
|
||||||
|
*(color_base + (state_size - 1) * 6 + 5) = 0;
|
||||||
|
|
||||||
if (V) printf(" n = %d x 2 côté = [%1.1f]\n", state_size + 1, 2.0f / state_size);
|
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 + 0) = 0;
|
||||||
|
@ -65,16 +91,27 @@ bool compute_space_2D(int state_size,
|
||||||
for (int k = 0; k < state_size * 2; k++) *(line_ndx + k + 4) = k;
|
for (int k = 0; k < state_size * 2; k++) *(line_ndx + k + 4) = k;
|
||||||
|
|
||||||
if (I) printf("line_ndx (%d - state_size(0)) x (%d - state_size(1)) ", 0, 1);
|
if (I) printf("line_ndx (%d - state_size(0)) x (%d - state_size(1)) ", 0, 1);
|
||||||
for (int v = 0; v < state_size + 2; v++) {
|
|
||||||
if (I) printf("(%d-%d) ", *(line_ndx + v), *(line_ndx + v + 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pref_mark_unit_space_zero) { // diagonales pour marquer la case zéro
|
for (int v = 0; v < state_size + 2; v++)
|
||||||
|
if (I) printf("(%d-%d) ", *(line_ndx + v), *(line_ndx + v + 1));
|
||||||
|
|
||||||
|
int dgap = 0;
|
||||||
|
|
||||||
|
if (pref_mark_unit_space_first) { // diagonales to mark first space unit
|
||||||
|
dgap +=4;
|
||||||
*(line_ndx + state_size * 2 + 6 + dgap + 0) = 0;
|
*(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 + 1) = 3;
|
||||||
*(line_ndx + state_size * 2 + 6 + dgap + 2) = 1;
|
*(line_ndx + state_size * 2 + 6 + dgap + 2) = 1;
|
||||||
*(line_ndx + state_size * 2 + 6 + dgap + 3) = 2;
|
*(line_ndx + state_size * 2 + 6 + dgap + 3) = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pref_mark_unit_space_last) { // diagonales to mark last space unit
|
||||||
|
dgap +=4;
|
||||||
|
*(line_ndx + state_size * 2 + 6 + dgap + 0) = (state_size - 2) * 2 + 0;
|
||||||
|
*(line_ndx + state_size * 2 + 6 + dgap + 1) = (state_size - 2) * 2 + 3;
|
||||||
|
*(line_ndx + state_size * 2 + 6 + dgap + 2) = (state_size - 2) * 2 + 1;
|
||||||
|
*(line_ndx + state_size * 2 + 6 + dgap + 3) = (state_size - 2) * 2 + 2;
|
||||||
|
}
|
||||||
|
|
||||||
if (I) printf(" n = 4 + (%d x 2)\n", state_size + 2);
|
if (I) printf(" n = 4 + (%d x 2)\n", state_size + 2);
|
||||||
|
|
||||||
|
|
|
@ -25,13 +25,15 @@
|
||||||
#include <epoxy/gl.h>
|
#include <epoxy/gl.h>
|
||||||
|
|
||||||
#define V 1
|
#define V 1
|
||||||
#define I 1
|
#define I 0
|
||||||
#define EDGE 0.999999
|
#define EDGE 0.999999
|
||||||
|
|
||||||
bool compute_space_3D(int state_size,
|
bool compute_space_3D(int state_size,
|
||||||
GLfloat *vertex_base, GLfloat *color_base,
|
GLfloat *vertex_base, GLfloat *color_base,
|
||||||
GLubyte *line_ndx,
|
GLubyte *line_ndx,
|
||||||
bool pref_mark_unit_space_zero, int dgap){
|
bool pref_mark_unit_space_first,
|
||||||
|
bool pref_mark_unit_space_last)
|
||||||
|
{
|
||||||
|
|
||||||
float x = 0;
|
float x = 0;
|
||||||
// for (int k = 0; k < state_size + 1; k++) <=> + 1 car
|
// for (int k = 0; k < state_size + 1; k++) <=> + 1 car
|
||||||
|
@ -62,36 +64,56 @@ bool compute_space_3D(int state_size,
|
||||||
*(vertex_base + k * 12 + 10) = - 1.0f / state_size;
|
*(vertex_base + k * 12 + 10) = - 1.0f / state_size;
|
||||||
*(vertex_base + k * 12 + 11) = 1.0f / state_size;
|
*(vertex_base + k * 12 + 11) = 1.0f / state_size;
|
||||||
|
|
||||||
*(color_base + k * 12 + 0) = 1 - (k / state_size);
|
*(color_base + k * 12 + 0) = 1; // 1 - (k / state_size);
|
||||||
*(color_base + k * 12 + 1) = 0.2f;
|
*(color_base + k * 12 + 1) = 0;
|
||||||
*(color_base + k * 12 + 2) = (k / state_size);
|
*(color_base + k * 12 + 2) = 0;
|
||||||
|
|
||||||
*(color_base + k * 12 + 3) = 0.8f;
|
*(color_base + k * 12 + 3) = 0.2f;
|
||||||
*(color_base + k * 12 + 4) = 0.8f;
|
*(color_base + k * 12 + 4) = 1;
|
||||||
*(color_base + k * 12 + 5) = 0.2f;
|
*(color_base + k * 12 + 5) = 0;
|
||||||
|
|
||||||
*(color_base + k * 12 + 6) = 0.8f;
|
*(color_base + k * 12 + 6) = 1;
|
||||||
*(color_base + k * 12 + 7) = (k / state_size);
|
*(color_base + k * 12 + 7) = 1;
|
||||||
*(color_base + k * 12 + 8) = 0.2f;
|
*(color_base + k * 12 + 8) = 0;
|
||||||
|
|
||||||
*(color_base + k * 12 + 9) = 1 - (k / state_size);
|
|
||||||
*(color_base + k * 12 + 10) = 0.2f;
|
|
||||||
*(color_base + k * 12 + 11) = 0.9f;
|
|
||||||
|
|
||||||
// if (k == 0) for (int j = 0; j < 12; j++) *(color_base + j) = 0.2f;
|
|
||||||
|
|
||||||
/* 0.8, 0.8, 0.8, // blanc */
|
|
||||||
/* 0.8, 0.8, 0.2, // jaune */
|
|
||||||
/* 0.8, 0.2, 0.2, // rouge */
|
|
||||||
/* 0.2, 0.2, 0.2, // noir */
|
|
||||||
/* 0.2, 0.2, 0.2, // gris */
|
|
||||||
/* 0.2, 0.8, 0.8, // cyan */
|
|
||||||
/* 0.2, 0.8, 0.2, // vert */
|
|
||||||
/* 0.8, 0.2, 0.8, // magenta */
|
|
||||||
|
|
||||||
|
*(color_base + k * 12 + 9) = 0;
|
||||||
|
*(color_base + k * 12 + 10) = 0;
|
||||||
|
*(color_base + k * 12 + 11) = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (V) printf(" n = %d x 2 côté = [%1.1f]\n", state_size + 1, 2.0f / state_size);
|
*(color_base + 0) = 0;
|
||||||
|
*(color_base + 1) = 0;
|
||||||
|
*(color_base + 2) = 0;
|
||||||
|
|
||||||
|
*(color_base + 3) = 1;
|
||||||
|
*(color_base + 4) = 1;
|
||||||
|
*(color_base + 5) = 1;
|
||||||
|
|
||||||
|
*(color_base + 6) = 0;
|
||||||
|
*(color_base + 7) = 0;
|
||||||
|
*(color_base + 8) = 0;
|
||||||
|
|
||||||
|
*(color_base + 9) = 1;
|
||||||
|
*(color_base + 10) = 1;
|
||||||
|
*(color_base + 11) = 1;
|
||||||
|
|
||||||
|
*(color_base + (state_size - 1) * 12 + 0) = 1;
|
||||||
|
*(color_base + (state_size - 1) * 12 + 1) = 1;
|
||||||
|
*(color_base + (state_size - 1) * 12 + 2) = 1;
|
||||||
|
|
||||||
|
*(color_base + (state_size - 1) * 12 + 3) = 0;
|
||||||
|
*(color_base + (state_size - 1) * 12 + 4) = 0;
|
||||||
|
*(color_base + (state_size - 1) * 12 + 5) = 0;
|
||||||
|
|
||||||
|
*(color_base + (state_size - 1) * 12 + 6) = 0;
|
||||||
|
*(color_base + (state_size - 1) * 12 + 7) = 0;
|
||||||
|
*(color_base + (state_size - 1) * 12 + 8) = 0;
|
||||||
|
|
||||||
|
*(color_base + (state_size - 1) * 12 + 9) = 1;
|
||||||
|
*(color_base + (state_size - 1) * 12 + 10) = 1;
|
||||||
|
*(color_base + (state_size - 1) * 12 + 11) = 1;
|
||||||
|
|
||||||
|
if (V) printf(" n = %d x 2 côté = [%1.1f]\n", state_size + 1, 2.0f / state_size);
|
||||||
|
|
||||||
*(line_ndx + 4) = 0;
|
*(line_ndx + 4) = 0;
|
||||||
*(line_ndx + 5) = state_size * 4 - 4; // barre horizontale du bas arr
|
*(line_ndx + 5) = state_size * 4 - 4; // barre horizontale du bas arr
|
||||||
|
@ -131,7 +153,7 @@ bool compute_space_3D(int state_size,
|
||||||
*(line_ndx + k + 7) = k / 2 - 2; // + 2;
|
*(line_ndx + k + 7) = k / 2 - 2; // + 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pref_mark_unit_space_zero) {
|
if (pref_mark_unit_space_first) {
|
||||||
|
|
||||||
*(line_ndx + (2 + state_size) * 8 - 4) = 0 + 0; // diagonales pour marquer la case zéro
|
*(line_ndx + (2 + state_size) * 8 - 4) = 0 + 0; // diagonales pour marquer la case zéro
|
||||||
*(line_ndx + (2 + state_size) * 8 - 3) = 0 + 1;
|
*(line_ndx + (2 + state_size) * 8 - 3) = 0 + 1;
|
||||||
|
@ -140,13 +162,22 @@ if (pref_mark_unit_space_zero) {
|
||||||
*(line_ndx + (2 + state_size) * 8 - 1) = 0 + 3;
|
*(line_ndx + (2 + state_size) * 8 - 1) = 0 + 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pref_mark_unit_space_last) {
|
||||||
|
|
||||||
|
*(line_ndx + (2 + state_size) * 8 - 8) = (state_size - 1) * 4 + 0; // diagonales pour marquer la case finale
|
||||||
|
*(line_ndx + (2 + state_size) * 8 - 7) = (state_size - 1) * 4 + 1;
|
||||||
|
|
||||||
|
*(line_ndx + (2 + state_size) * 8 - 6) = (state_size - 1) * 4 + 2; // diagonales pour marquer la case finale
|
||||||
|
*(line_ndx + (2 + state_size) * 8 - 5) = (state_size - 1) * 4 + 3;
|
||||||
|
}
|
||||||
|
|
||||||
if (I) printf("line_ndx ");
|
if (I) printf("line_ndx ");
|
||||||
for (int v = 0; v < state_size + 2; v++) {
|
for (int v = 0; v < state_size + 2; v++) {
|
||||||
if (I) printf("(%d-%d) ", *(line_ndx + v), *(line_ndx + v + 1));
|
if (I) printf("(%d-%d) ", *(line_ndx + v), *(line_ndx + v + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (I) printf(" n = 4 + (%d x 2) dgap = %d\n", state_size + 2, dgap);
|
if (I) printf("pref_mark_unit_space_first = %d ", pref_mark_unit_space_first);
|
||||||
if (I) printf("pref_mark_unit_space_zero = %d ", pref_mark_unit_space_zero);
|
if (I) printf("pref_mark_unit_space_last = %d ", pref_mark_unit_space_last);
|
||||||
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -12,5 +12,6 @@ out vec4 color;
|
||||||
void main(void)
|
void main(void)
|
||||||
{
|
{
|
||||||
gl_Position = projection_matrix * view_matrix * model_matrix * vec4(in_position, 1);
|
gl_Position = projection_matrix * view_matrix * model_matrix * vec4(in_position, 1);
|
||||||
color = vec4(1 * in_color.rgb, 0.2f);
|
color = vec4(1 * in_color.rgb, 1);
|
||||||
|
// color = vec4(1 * in_color.rgb, 0.2f);
|
||||||
}
|
}
|
|
@ -25,7 +25,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "../../include/base.h"
|
#include "../../include/base.h"
|
||||||
#include "../../include/graphics_control.h"
|
#include "../../include/graphics.h"
|
||||||
#include "../../include/ui.h"
|
#include "../../include/ui.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue