O K P R I N T I N G + O K D R A W I N G ( + C O M M E N T S )
This commit is contained in:
parent
b8c0a57f4c
commit
74f8fc53d6
|
@ -29,93 +29,6 @@
|
||||||
#include "../../include/displays.h"
|
#include "../../include/displays.h"
|
||||||
|
|
||||||
|
|
||||||
/* TO REMEMBER : Ici, tout ce qui gène la lecture du code en cours de debugging
|
|
||||||
* #pragma omp parallel schedule(static, 12)
|
|
||||||
* void __attribute__((optimize("no-unroll-loops"))) main_test_graphics (void)
|
|
||||||
{
|
|
||||||
// assert : space dimensions (x,y,z) > 0
|
|
||||||
// assert : arrows localization within space and sites
|
|
||||||
// assert : no more than one arrow per address
|
|
||||||
// notify : weights are replaced, NOT added (could be !)
|
|
||||||
*
|
|
||||||
* Init space and arrows (= initial state)
|
|
||||||
* and allows ulterior creations, suppressions or modifications of the arrows[] array
|
|
||||||
*
|
|
||||||
* Draws space and arrows
|
|
||||||
*
|
|
||||||
* // Initialisation du générateur pseudo-aléatoire
|
|
||||||
* // Attention, à ce stade, pas de vertex redondant
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* in set_arrow() : */
|
|
||||||
/* if (console) print_vertex_and_lines_buffers (arrows_ptr, arrows_nb, address, requested_weight, current_weight, site, x, y, z); */
|
|
||||||
/* if (0) print_vertex_and_lines_buffers (arrows_ptr, arrows_nb, address, requested_weight, current_weight, site, x, y, z); */
|
|
||||||
/* if (requested_weight == 0 && console) */
|
|
||||||
/* printf(" - set_arrow() invoked with requested weight = %2d bf_vrtx = %d bf_ln = %d add: %d",\ */
|
|
||||||
/* requested_weight, buffer_vertex_size / 3, buffer_lines_size / 2, address); */
|
|
||||||
/* if (console) show_user_action(arrows_ptr, arrows_nb, address, requested_weight, current_weight, site, x, y, z); */
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Calls one of the functions create_arrow(), erase_arrow() or rewrite_arrow()
|
|
||||||
* according to requested weight and address (coord site, x, y, z)
|
|
||||||
*
|
|
||||||
* May not call any of these three functions if :
|
|
||||||
* - Current_weight of an arrow located at the requested address == requested_weight
|
|
||||||
* - No arrow was found at the requested addres AND current_weight == requested_weight
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* Removes an arrow at address (address)
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* Creates a new arrow at address (address)
|
|
||||||
* NB Weights (or loads) are NOT added
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Assigns a new load to the arrow at address (address)
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
/* I N I T I A L D A T A A R E N O W A L L S P E C I F I E D */
|
|
||||||
|
|
||||||
/* A N D C A N B E D R A W N */
|
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
/* N E W D A T A W I L L N O W B E S P E C I F I E D */
|
|
||||||
|
|
||||||
/* A N D T H E N D R A W N E D */
|
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
|
|
||||||
/* If load == 0 then erase the arrow at this address v */
|
|
||||||
/* arrows_nb = set_arrow (arrows_ptr, arrows_nb, space_X, space_Y, space_Z, 0, 0, 0, 0, 0, console); */
|
|
||||||
/* arrows_nb = set_arrow (arrows_ptr, arrows_nb, space_X, space_Y, space_Z, 0, 1, 0, 0, 0, console); */
|
|
||||||
/* arrows_nb = set_arrow (arrows_ptr, arrows_nb, space_X, space_Y, space_Z, 0, 2, 0, 0, 0, console); */
|
|
||||||
/* arrows_nb = set_arrow (arrows_ptr, arrows_nb, space_X, space_Y, space_Z, 0, 3, 0, 0, 0, console); */
|
|
||||||
/* arrows_nb = set_arrow (arrows_ptr, arrows_nb, space_X, space_Y, space_Z, 0, 4, 0, 0, 0, console); */
|
|
||||||
/* arrows_nb = set_arrow (arrows_ptr, arrows_nb, space_X, space_Y, space_Z, 0, 5, 0, 0, 0, console); */
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------------------------------------------------------------*/
|
|
||||||
/*--------------------------------------------------------------------------------------------------------------------------------*/
|
|
||||||
/*--------------------------------------------------------------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
|
|
||||||
/* Prints the arrows[] array
|
/* Prints the arrows[] array
|
||||||
*
|
*
|
||||||
|
|
|
@ -553,47 +553,11 @@ bool graphics_shutdown(const void *gl_area)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Depends on set_arrow()
|
||||||
|
* Exchanges current and required site values
|
||||||
|
* when the address of the arrow to be set is already occupied
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static int rewrite_arrow (int arrows_nb, int address, int load, int site, int x, int y, int z, int console)
|
static int rewrite_arrow (int arrows_nb, int address, int load, int site, int x, int y, int z, int console)
|
||||||
{
|
{
|
||||||
printf("WARNING in rewrite_arrow() <> address or address / 5 ? (et pourquoi ?)\n");
|
printf("WARNING in rewrite_arrow() <> address or address / 5 ? (et pourquoi ?)\n");
|
||||||
|
@ -604,6 +568,10 @@ static int rewrite_arrow (int arrows_nb, int address, int load, int site, int x,
|
||||||
return arrows_nb;
|
return arrows_nb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Depends on set_arrow()
|
||||||
|
* Creates the arrow to be set with the required load at the required address
|
||||||
|
*/
|
||||||
static inline int create_arrow (int arrows_nb,
|
static inline int create_arrow (int arrows_nb,
|
||||||
int space_X, int space_Y, int space_Z,
|
int space_X, int space_Y, int space_Z,
|
||||||
int load, int site, int x, int y, int z,
|
int load, int site, int x, int y, int z,
|
||||||
|
@ -632,6 +600,10 @@ static inline int create_arrow (int arrows_nb,
|
||||||
return arrows_nb;
|
return arrows_nb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Depends on set_arrow()
|
||||||
|
* Erases the arrow at the required address
|
||||||
|
*/
|
||||||
static inline int erase_arrow (int arrows_nb, int arrow_address_in_list,
|
static inline int erase_arrow (int arrows_nb, int arrow_address_in_list,
|
||||||
GLuint site, GLint x, GLint y, GLint z,
|
GLuint site, GLint x, GLint y, GLint z,
|
||||||
int console)
|
int console)
|
||||||
|
@ -693,6 +665,29 @@ static inline int erase_arrow (int arrows_nb, int arrow_address_in_list,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Creates or deletes an arrow or modify the load of an existing one
|
||||||
|
* Acts both by writing the list of arrows : (struct arrow_t *arrows_ptr, int arrows_nb)
|
||||||
|
* and by drawing in the global space
|
||||||
|
*
|
||||||
|
* @param arrows_ptr and arrows_nb before operation,
|
||||||
|
* required load and address (site, x, y, z)
|
||||||
|
*
|
||||||
|
* IF there is no arrow at the required address,
|
||||||
|
* AND IF the load is > 0, an arrow will be created.
|
||||||
|
*
|
||||||
|
* IF there is an arrow at the required address
|
||||||
|
* AND IF the load is = 0, the existing arrow will be deleted.
|
||||||
|
*
|
||||||
|
* IF there is an arrow at the required address
|
||||||
|
* AND IF the load is > 0, the load of the existing arrow will be modified.
|
||||||
|
*
|
||||||
|
* May not call any of these three functions IF :
|
||||||
|
* - Current_weight of an arrow located at the requested address == requested_weight
|
||||||
|
* - No arrow was found at the requested addres AND current_weight == requested_weight
|
||||||
|
*
|
||||||
|
* @return arrows_nb after operation
|
||||||
|
*/
|
||||||
static inline int set_arrow (struct arrow_t *arrows_ptr, int arrows_nb, int space_X, int space_Y, int space_Z,
|
static inline int set_arrow (struct arrow_t *arrows_ptr, int arrows_nb, int space_X, int space_Y, int space_Z,
|
||||||
int requested_weight, int site, int arrow_x, int arrow_y, int arrow_z, int console)
|
int requested_weight, int site, int arrow_x, int arrow_y, int arrow_z, int console)
|
||||||
{
|
{
|
||||||
|
@ -732,8 +727,34 @@ static inline int set_arrow (struct arrow_t *arrows_ptr, int arrows_nb, int spac
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* TODO
|
||||||
|
* #pragma omp parallel schedule(static, 12)
|
||||||
|
* void __attribute__((optimize("no-unroll-loops"))) main_test_graphics (void) {}
|
||||||
|
*
|
||||||
|
// assert : space dimensions (x,y,z) > 0
|
||||||
|
// assert : arrows localization within space and sites
|
||||||
|
// assert : no more than one arrow per address
|
||||||
|
// notify : weights are replaced, NOT added (could be !)
|
||||||
|
*
|
||||||
|
* Init space and arrows (= initial state)
|
||||||
|
* and allows ulterior creations, suppressions or modifications of the arrows[] array
|
||||||
|
*
|
||||||
|
* draws the space()
|
||||||
|
* triggers set_arrows() that modifies the list () and draws arrows
|
||||||
|
*
|
||||||
|
* Initialisation du générateur pseudo-aléatoire
|
||||||
|
* Attention, les vertex centraux de chaque unité d'espace (cube)
|
||||||
|
* peuvent être redondants (max 6)
|
||||||
|
*/
|
||||||
void main_test_graphics (void)
|
void main_test_graphics (void)
|
||||||
{
|
{
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/* I N I T I A L D A T A S P E C I F I C A T I O N */
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
||||||
srand(time(NULL)); int rand(void); void srand(unsigned int seed);
|
srand(time(NULL)); int rand(void); void srand(unsigned int seed);
|
||||||
int randomize = 5, console = 0, arrows_nb = 0, space_X = 1, space_Y = 1, space_Z = 1;
|
int randomize = 5, console = 0, arrows_nb = 0, space_X = 1, space_Y = 1, space_Z = 1;
|
||||||
if (randomize) {
|
if (randomize) {
|
||||||
|
@ -744,7 +765,13 @@ void main_test_graphics (void)
|
||||||
int density_max = space_X * space_Y * space_Z, specified_arrows_nb = rand() % density_max;
|
int density_max = space_X * space_Y * space_Z, specified_arrows_nb = rand() % density_max;
|
||||||
int max = fmax(space_X, space_Y); max = fmax(max, space_Z);
|
int max = fmax(space_X, space_Y); max = fmax(max, space_Z);
|
||||||
|
|
||||||
/* S P A C E */
|
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/* S P A C E D R A W I N G */
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
||||||
write_space_ridges_vertex (buffer_vertex_size, space_X, space_Y, space_Z);
|
write_space_ridges_vertex (buffer_vertex_size, space_X, space_Y, space_Z);
|
||||||
write_space_ridges_lines ();
|
write_space_ridges_lines ();
|
||||||
|
@ -755,7 +782,13 @@ void main_test_graphics (void)
|
||||||
buffer_colors_0_arrow = buffer_colors_size;
|
buffer_colors_0_arrow = buffer_colors_size;
|
||||||
buffer_lines_0_arrow = buffer_lines_size;
|
buffer_lines_0_arrow = buffer_lines_size;
|
||||||
|
|
||||||
/* A R R O W S */
|
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/* A R R O W S D R A W I N G */
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
||||||
if (randomize) for (int i = 0; i < specified_arrows_nb; i++)
|
if (randomize) for (int i = 0; i < specified_arrows_nb; i++)
|
||||||
arrows_nb = set_arrow (arrows_ptr, arrows_nb, space_X, space_Y, space_Z,
|
arrows_nb = set_arrow (arrows_ptr, arrows_nb, space_X, space_Y, space_Z,
|
||||||
|
@ -782,6 +815,8 @@ void main_test_graphics (void)
|
||||||
|
|
||||||
if (randomize) print_user_choices(arrows_ptr, max_arrows_nb, arrows_nb, space_X, space_Y, space_Z, 1, 0);
|
if (randomize) print_user_choices(arrows_ptr, max_arrows_nb, arrows_nb, space_X, space_Y, space_Z, 1, 0);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
/* F R E E */
|
/* F R E E */
|
||||||
|
|
Loading…
Reference in New Issue