WIP: Pause ! Erase est OK mais l'ajout des flèches est zarbi+++ sleep(??) lignes 849 et 864
This commit is contained in:
parent
7942e69f5e
commit
e2e60dfb37
|
@ -34,6 +34,7 @@
|
|||
#include <GL/glext.h>
|
||||
#include <glib-2.0/glib.h>
|
||||
#include <math.h>
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
|
||||
//#include "../../include/base.h"
|
||||
|
@ -671,15 +672,14 @@ static bool create_arrow (GLuint *arrows, long weight, long site, long x, long y
|
|||
weight, site, x, y, z);
|
||||
|
||||
arrows_nb ++;
|
||||
buffer_lines_size += 14;
|
||||
buffer_lines_origin = g_realloc(buffer_lines_origin, buffer_lines_size * 2 * sizeof(GLuint) * 2);
|
||||
|
||||
*(arrows + buffer_lines_size + 0) = weight;
|
||||
*(arrows + buffer_lines_size + 1) = site;
|
||||
*(arrows + buffer_lines_size + 2) = x;
|
||||
*(arrows + buffer_lines_size + 3) = y;
|
||||
*(arrows + buffer_lines_size + 4) = z;
|
||||
|
||||
buffer_lines_size += 14;
|
||||
*(arrows + arrows_nb + 0) = weight;
|
||||
*(arrows + arrows_nb + 1) = site;
|
||||
*(arrows + arrows_nb + 2) = x;
|
||||
*(arrows + arrows_nb + 3) = y;
|
||||
*(arrows + arrows_nb + 4) = z;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -711,6 +711,8 @@ static bool erase_arrow (GLuint *arrows, long address,
|
|||
|
||||
static long check_for_arrow (GLuint *arrows, long site, long x, long y, long z)
|
||||
{
|
||||
if (arrows_nb == 0) return -1;
|
||||
|
||||
long address = -1, f_weight = -1, f_site = -1, f_x = -1, f_y = -1, f_z = -1;
|
||||
for (int i = 0; i < arrows_nb; i++)
|
||||
{
|
||||
|
@ -725,7 +727,7 @@ static long check_for_arrow (GLuint *arrows, long site, long x, long y, long z)
|
|||
if (DETAIL) printf("arrows_nb = %ld checked arrow (%ld,%ld,%ld,%ld) found at address %ld (line %ld)",\
|
||||
arrows_nb, site, x, y, z, address, address / 5);
|
||||
if (DETAIL && f_weight > 1) printf(" weight = %ld", f_weight);
|
||||
printf("\n");
|
||||
if (DETAIL) printf("\n");
|
||||
}
|
||||
}
|
||||
return address; /* returns the address of the arrow if there is one
|
||||
|
@ -733,16 +735,17 @@ static long check_for_arrow (GLuint *arrows, long site, long x, long y, long z)
|
|||
}
|
||||
|
||||
|
||||
static void show_arrows_array (GLuint *arrows, long arrows_nb, long address, long weight, long site, long x, long y, long z)
|
||||
static void show_arrows_array (GLuint *arrows, long address, long weight, long site, long x, long y, long z)
|
||||
{
|
||||
printf("\n\n[ n] load | site x y z ----- < arrows_nb = %ld > -------", arrows_nb);
|
||||
if (arrows_nb == address) printf(" graphic state ----------------\n");
|
||||
else printf("------------------------------------------\n");
|
||||
printf("\n[ n] load | site x y z ----- < arrows_nb = %ld > ------", arrows_nb);
|
||||
if (arrows_nb == 0) printf("--------------------------- no arrows\n");
|
||||
else if (address == -1) printf("--------------------------- create new arrow\n");
|
||||
else printf("--------------------------- erase arrow at address = %ld / 5\n", address);
|
||||
|
||||
for (int i = 0; i < arrows_nb; i++)
|
||||
{
|
||||
printf("[%2d] = %2d | %2d, %2d, %2d, %2d ",\
|
||||
i, *(arrows + i * 5 + 0), *(arrows + i * 5 + 1), *(arrows + i * 5 + 2),\
|
||||
i, *(arrows + i * 5 + 0), *(arrows + i * 5 + 1), *(arrows + i * 5 + 2),\
|
||||
*(arrows + i * 5 + 3), *(arrows + i * 5 + 4));
|
||||
if (weight == 0 && i == address / 5) printf(" <<<| < - > (%d, %d, %d, %d) @ [%ld]",\
|
||||
*(arrows + i * 5 + 1), *(arrows + i * 5 + 2),\
|
||||
|
@ -751,7 +754,7 @@ static void show_arrows_array (GLuint *arrows, long arrows_nb, long address, lon
|
|||
*(arrows + i * 5 + 1), *(arrows + i * 5 + 2),\
|
||||
*(arrows + i * 5 + 3), *(arrows + i * 5 + 4), address / 5);
|
||||
if (weight == 0 && i > address / 5 && i < arrows_nb - 1) printf(" |");
|
||||
if (weight == 0 && i == arrows_nb - 1) printf(" >>>|");
|
||||
if (weight == 0 && i == arrows_nb - 1 && i != address / 5) printf(" >>>|");
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
|
@ -759,9 +762,8 @@ static void show_arrows_array (GLuint *arrows, long arrows_nb, long address, lon
|
|||
|
||||
static bool set_arrow (GLuint *arrows, long weight, long site, long x, long y, long z)
|
||||
{
|
||||
|
||||
long address = (check_for_arrow (arrows, site, x, y, z));
|
||||
if (1) show_arrows_array(arrows, arrows_nb, address, weight, site, x, y, z);
|
||||
show_arrows_array(arrows, address, weight, site, x, y, z);
|
||||
|
||||
if (address == -1 && weight == 0) return 0;
|
||||
if (address == -1 && weight > 0) return create_arrow (arrows, weight, site, x, y, z);
|
||||
|
@ -785,8 +787,6 @@ static bool set_arrow (GLuint *arrows, long weight, long site, long x, long y, l
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
/* Initializes the buffer of a gl_area
|
||||
* Calls according to the user preferences
|
||||
* @param gl_area, ptr to the gl_area widget
|
||||
|
@ -846,13 +846,14 @@ void graphics_init_buffers(const void *gl_area)
|
|||
model_space_size_z * model_space_size_y, model_space_size_z,
|
||||
arrows, arrows_nb);
|
||||
|
||||
sleep(0);
|
||||
|
||||
set_arrow(arrows, 0, 4, 3, 0, 0);
|
||||
set_arrow(arrows, 0, 5, 3, 0, 1);
|
||||
set_arrow(arrows, 0, 5, 2, 1, 1);
|
||||
set_arrow(arrows, 0, 4, 2, 1, 0);
|
||||
set_arrow(arrows, 0, 2, 2, 1, 1);
|
||||
set_arrow(arrows, 0, 3, 2, 2, 1);
|
||||
|
||||
set_arrow(arrows, 0, 0, 0, 0, 0);
|
||||
set_arrow(arrows, 0, 1, 1, 0, 0);
|
||||
set_arrow(arrows, 0, 1, 3, 0, 0);
|
||||
|
@ -860,14 +861,20 @@ void graphics_init_buffers(const void *gl_area)
|
|||
set_arrow(arrows, 0, 4, 0, 1, 0);
|
||||
set_arrow(arrows, 0, 5, 0, 1, 1);
|
||||
|
||||
// set_arrow(arrows, 1, 0, 0, 0, 2);
|
||||
// set_arrow(arrows, 1, 1, 1, 0, 2);
|
||||
/* set_arrow(arrows, 1, 2, 0, 0, 2); */
|
||||
/* set_arrow(arrows, 1, 3, 0, 1, 2); */
|
||||
sleep(0);
|
||||
|
||||
// set_arrow(arrows, 2, 1, 1, 0, 2);
|
||||
set_arrow(arrows, 1, 0, 0, 0, 2);
|
||||
set_arrow(arrows, 1, 1, 1, 0, 2);
|
||||
|
||||
if (1) show_arrows_array(arrows, arrows_nb, arrows_nb, -1, -1, -1, -1, -1);
|
||||
// set_arrow(arrows, 0, 0, 0, 0, 2);
|
||||
// set_arrow(arrows, 0, 1, 1, 0, 2);
|
||||
set_arrow(arrows, 1, 2, 0, 0, 2);
|
||||
set_arrow(arrows, 1, 3, 0, 1, 2);
|
||||
|
||||
set_arrow(arrows, 3, 1, 1, 0, 2);
|
||||
|
||||
if (1) set_arrow(arrows, -1, -1, -1, -1, -1); // I use this to see the variables state
|
||||
// before "drawing_some_arrows
|
||||
|
||||
draw_some_arrows (buffer_lines_origin, s,
|
||||
model_space_size_z * model_space_size_y, model_space_size_z,
|
||||
|
|
Loading…
Reference in New Issue