WIP: cleaning (widgets & graphics sub-dir creation II : 'graphics' > 'graph')
This commit is contained in:
parent
16f41ef343
commit
75a3b7d947
|
@ -44,7 +44,7 @@
|
||||||
* Structure describing a gl_area and its parameters, used to create a table
|
* Structure describing a gl_area and its parameters, used to create a table
|
||||||
* of Gem-graph client current gl_areas
|
* of Gem-graph client current gl_areas
|
||||||
*/
|
*/
|
||||||
struct graphic_stack_t {
|
struct graph_stack_t {
|
||||||
|
|
||||||
int id;
|
int id;
|
||||||
int mode;
|
int mode;
|
||||||
|
@ -81,15 +81,15 @@ struct graphic_stack_t {
|
||||||
/*
|
/*
|
||||||
* Dynamic array of ptrs to dynamically allocated gl_area_entry
|
* Dynamic array of ptrs to dynamically allocated gl_area_entry
|
||||||
*/
|
*/
|
||||||
extern struct graphic_stack_t *graphic_stack;
|
extern struct graph_stack_t *graph_stack;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Structure describing a gl_area and its parameters, used to create a table
|
* Structure describing a gl_area and its parameters, used to create a table
|
||||||
* of Gem-graph client current gl_areas
|
* of Gem-graph client current gl_areas
|
||||||
*/
|
*/
|
||||||
bool ui_render_stack(GtkWidget *container_widget);
|
bool graph_render_stack(GtkWidget *container_widget);
|
||||||
|
|
||||||
bool ui_setup_glarea(int target_mode, GtkWidget *target_widget);
|
bool graph_setup_glarea(int target_mode, GtkWidget *target_widget);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initializes a gl_area
|
* Initializes a gl_area
|
||||||
|
@ -98,7 +98,7 @@ bool ui_setup_glarea(int target_mode, GtkWidget *target_widget);
|
||||||
*
|
*
|
||||||
* @return true if initialized
|
* @return true if initialized
|
||||||
*/
|
*/
|
||||||
int graphics_init(void *error_buffer);
|
int graph_init(void *error_buffer);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Draws the current buffer to a gl_area
|
* Draws the current buffer to a gl_area
|
||||||
|
@ -107,7 +107,7 @@ int graphics_init(void *error_buffer);
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
void graphics_draw(const int stack_id);
|
void graph_draw(const int graph_stack_id);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Shutdowns a gl_area
|
* Shutdowns a gl_area
|
||||||
|
@ -116,7 +116,7 @@ void graphics_draw(const int stack_id);
|
||||||
*
|
*
|
||||||
* @return true if success
|
* @return true if success
|
||||||
*/
|
*/
|
||||||
bool graphics_shutdown(const int stack_id, void *error_buffer);
|
bool graph_shutdown(const int graph_stack_id, void *error_buffer);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initializes the shaders of a gl_area and link them to a program
|
* Initializes the shaders of a gl_area and link them to a program
|
||||||
|
@ -125,18 +125,18 @@ bool graphics_shutdown(const int stack_id, void *error_buffer);
|
||||||
*
|
*
|
||||||
* @return true if initialized
|
* @return true if initialized
|
||||||
*/
|
*/
|
||||||
bool graphics_init_shaders(const int stack_id);
|
bool graph_init_shaders(const int graph_stack_id);
|
||||||
|
|
||||||
bool ui_init_graphic_stack(void *container_widget, GError *error_buffer);
|
bool graph_init_graph_stack(void *container_widget, GError *error_buffer);
|
||||||
bool ui_shutdown_graphic_stack(void *container_widget, GError *error_buffer);
|
bool graph_shutdown_graph_stack(void *container_widget, GError *error_buffer);
|
||||||
bool ui_update_axis_stack(GtkWidget *container_widget, int axis, int value);
|
bool graph_update_axis_stack(GtkWidget *container_widget, int axis, int value);
|
||||||
|
|
||||||
/* Initializes the buffer of a gl_area
|
/* Initializes the buffer of a gl_area
|
||||||
* Calls according to the user preferences
|
* Calls according to the user preferences
|
||||||
* @param gl_area, ptr to the gl_area widget
|
* @param gl_area, ptr to the gl_area widget
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
void graphics_init_buffers(const int stack_id);
|
void graph_init_buffers(const int graph_stack_id);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Draws a vertex (x, y, z)
|
* Draws a vertex (x, y, z)
|
||||||
|
@ -146,7 +146,7 @@ void graphics_init_buffers(const int stack_id);
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
void graphics_draw_vertex (const int stack_id,
|
void graph_draw_vertex (const int graph_stack_id,
|
||||||
GLfloat x,
|
GLfloat x,
|
||||||
GLfloat y,
|
GLfloat y,
|
||||||
GLfloat z);
|
GLfloat z);
|
||||||
|
@ -159,7 +159,7 @@ void graphics_draw_vertex (const int stack_id,
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
void graphics_draw_color (const int stack_id, GLfloat r, GLfloat g, GLfloat b);
|
void graph_draw_color (const int graph_stack_id, GLfloat r, GLfloat g, GLfloat b);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Writes values to describe a line from a to b into the line buffer
|
* Writes values to describe a line from a to b into the line buffer
|
||||||
|
@ -168,7 +168,7 @@ void graphics_draw_color (const int stack_id, GLfloat r, GLfloat g, GLfloat b);
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
void graphics_draw_line (const int stack_id, GLuint a, GLuint b);
|
void graph_draw_line (const int graph_stack_id, GLuint a, GLuint b);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Writes values to describe an (a,b,c) plan (triangle) into the plan buffer
|
* Writes values to describe an (a,b,c) plan (triangle) into the plan buffer
|
||||||
|
@ -177,7 +177,7 @@ void graphics_draw_line (const int stack_id, GLuint a, GLuint b);
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
void graphics_draw_plan (const int stack_id, GLuint a, GLuint b, GLuint c);
|
void graph_draw_plan (const int graph_stack_id, GLuint a, GLuint b, GLuint c);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Created and compile a shader
|
* Created and compile a shader
|
||||||
|
@ -187,7 +187,7 @@ void graphics_draw_plan (const int stack_id, GLuint a, GLuint b, GLuint c);
|
||||||
*
|
*
|
||||||
* @return shader id
|
* @return shader id
|
||||||
*/
|
*/
|
||||||
static inline GLuint create_shader(const int stack_id, int type, const char *src)
|
static inline GLuint graph_create_shader(const int graph_stack_id, int type, const char *src)
|
||||||
{
|
{
|
||||||
GLuint shader;
|
GLuint shader;
|
||||||
int status;
|
int status;
|
||||||
|
@ -221,47 +221,47 @@ static inline GLuint create_shader(const int stack_id, int type, const char *src
|
||||||
return shader;
|
return shader;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void print_stack(int stack_id)
|
static inline void graph_print_stack(int graph_stack_id)
|
||||||
{
|
{
|
||||||
static int n = 0;
|
static int n = 0;
|
||||||
|
|
||||||
printf("\n[n=%d]***************", n);
|
printf("\n[n=%d]***************", n);
|
||||||
|
|
||||||
printf("id = %d\tmode = %d\n",
|
printf("id = %d\tmode = %d\n",
|
||||||
graphic_stack[stack_id].id,
|
graph_stack[graph_stack_id].id,
|
||||||
graphic_stack[stack_id].mode);
|
graph_stack[graph_stack_id].mode);
|
||||||
|
|
||||||
printf("rotation_angles = ");
|
printf("rotation_angles = ");
|
||||||
for (int i = 0; i < N_AXIS; i++) {
|
for (int i = 0; i < N_AXIS; i++) {
|
||||||
printf("%f\t", graphic_stack[stack_id].rotation_angles[i]); // Rotation angles on each axis
|
printf("%f\t", graph_stack[graph_stack_id].rotation_angles[i]); // Rotation angles on each axis
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
printf("vao = %d\n", graphic_stack[stack_id].vao);
|
printf("vao = %d\n", graph_stack[graph_stack_id].vao);
|
||||||
printf("position_buffer = %d\n", graphic_stack[stack_id].position_buffer);
|
printf("position_buffer = %d\n", graph_stack[graph_stack_id].position_buffer);
|
||||||
printf("color_buffer = %d\n", graphic_stack[stack_id].color_buffer);
|
printf("color_buffer = %d\n", graph_stack[graph_stack_id].color_buffer);
|
||||||
printf("program = %d\n", graphic_stack[stack_id].program);
|
printf("program = %d\n", graph_stack[graph_stack_id].program);
|
||||||
printf("m = %d\n", graphic_stack[stack_id].m);
|
printf("m = %d\n", graph_stack[graph_stack_id].m);
|
||||||
printf("v = %d\n", graphic_stack[stack_id].v);
|
printf("v = %d\n", graph_stack[graph_stack_id].v);
|
||||||
printf("p = %d\n", graphic_stack[stack_id].p);
|
printf("p = %d\n", graph_stack[graph_stack_id].p);
|
||||||
|
|
||||||
printf("arrows_ptr = %p\n", graphic_stack[stack_id].arrows_ptr);
|
printf("arrows_ptr = %p\n", graph_stack[graph_stack_id].arrows_ptr);
|
||||||
printf("arrows_nb = %ld\n", graphic_stack[stack_id].arrows_nb);
|
printf("arrows_nb = %ld\n", graph_stack[graph_stack_id].arrows_nb);
|
||||||
|
|
||||||
printf("buffer_vertex_origin = %p\n", graphic_stack[stack_id].buffer_vertex_origin);
|
printf("buffer_vertex_origin = %p\n", graph_stack[graph_stack_id].buffer_vertex_origin);
|
||||||
printf("buffer_colors_origin = %p\n", graphic_stack[stack_id].buffer_colors_origin);
|
printf("buffer_colors_origin = %p\n", graph_stack[graph_stack_id].buffer_colors_origin);
|
||||||
printf("buffer_lines_origin = %p\n", graphic_stack[stack_id].buffer_lines_origin);
|
printf("buffer_lines_origin = %p\n", graph_stack[graph_stack_id].buffer_lines_origin);
|
||||||
printf("buffer_plans_origin = %p\n", graphic_stack[stack_id].buffer_plans_origin);
|
printf("buffer_plans_origin = %p\n", graph_stack[graph_stack_id].buffer_plans_origin);
|
||||||
|
|
||||||
printf("buffer_vertex_size = %ld\n", graphic_stack[stack_id].buffer_vertex_size);
|
printf("buffer_vertex_size = %ld\n", graph_stack[graph_stack_id].buffer_vertex_size);
|
||||||
printf("buffer_colors_size = %ld\n", graphic_stack[stack_id].buffer_colors_size);
|
printf("buffer_colors_size = %ld\n", graph_stack[graph_stack_id].buffer_colors_size);
|
||||||
printf("buffer_lines_size = %ld\n", graphic_stack[stack_id].buffer_lines_size);
|
printf("buffer_lines_size = %ld\n", graph_stack[graph_stack_id].buffer_lines_size);
|
||||||
printf("buffer_plans_size = %ld\n", graphic_stack[stack_id].buffer_plans_size);
|
printf("buffer_plans_size = %ld\n", graph_stack[graph_stack_id].buffer_plans_size);
|
||||||
|
|
||||||
printf("buffer_vertex_0_arrow = %ld\n", graphic_stack[stack_id].buffer_vertex_0_arrow);
|
printf("buffer_vertex_0_arrow = %ld\n", graph_stack[graph_stack_id].buffer_vertex_0_arrow);
|
||||||
printf("buffer_colors_0_arrow = %ld\n", graphic_stack[stack_id].buffer_colors_0_arrow);
|
printf("buffer_colors_0_arrow = %ld\n", graph_stack[graph_stack_id].buffer_colors_0_arrow);
|
||||||
printf("buffer_lines_0_arrow = %ld\n", graphic_stack[stack_id].buffer_lines_0_arrow);
|
printf("buffer_lines_0_arrow = %ld\n", graph_stack[graph_stack_id].buffer_lines_0_arrow);
|
||||||
printf("buffer_plans_0_arrow = %ld\n", graphic_stack[stack_id].buffer_plans_0_arrow);
|
printf("buffer_plans_0_arrow = %ld\n", graph_stack[graph_stack_id].buffer_plans_0_arrow);
|
||||||
|
|
||||||
printf("********************\n");
|
printf("********************\n");
|
||||||
n++;
|
n++;
|
||||||
|
@ -275,7 +275,7 @@ static inline void print_stack(int stack_id)
|
||||||
*
|
*
|
||||||
* @return true if initialized
|
* @return true if initialized
|
||||||
*/
|
*/
|
||||||
int graphics_init(void *error_buffer);
|
int graph_init(void *error_buffer);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Draws the current buffer to a gl_area
|
* Draws the current buffer to a gl_area
|
||||||
|
@ -284,7 +284,7 @@ int graphics_init(void *error_buffer);
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
//void graphics_draw(const int stack_id);
|
//void graph_draw(const int graph_stack_id);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Shutdowns a gl_area
|
* Shutdowns a gl_area
|
||||||
|
@ -293,7 +293,7 @@ int graphics_init(void *error_buffer);
|
||||||
*
|
*
|
||||||
* @return true if success
|
* @return true if success
|
||||||
*/
|
*/
|
||||||
bool graphics_shutdown(const int stack_id, void *error_buffer);
|
bool graph_shutdown(const int graph_stack_id, void *error_buffer);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initializes the shaders of a gl_area and link them to a program
|
* Initializes the shaders of a gl_area and link them to a program
|
||||||
|
@ -302,14 +302,14 @@ bool graphics_shutdown(const int stack_id, void *error_buffer);
|
||||||
*
|
*
|
||||||
* @return true if initialized
|
* @return true if initialized
|
||||||
*/
|
*/
|
||||||
bool graphics_init_shaders(const int stack_id);
|
bool graph_init_shaders(const int graph_stack_id);
|
||||||
|
|
||||||
/* Initializes the buffer of a gl_area
|
/* Initializes the buffer of a gl_area
|
||||||
* Calls according to the user preferences
|
* Calls according to the user preferences
|
||||||
* @param gl_area, ptr to the gl_area widget
|
* @param gl_area, ptr to the gl_area widget
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
void graphics_init_buffers(const int stack_id);
|
void graph_init_buffers(const int graph_stack_id);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Draws a vertex (x, y, z)
|
* Draws a vertex (x, y, z)
|
||||||
|
@ -319,7 +319,7 @@ void graphics_init_buffers(const int stack_id);
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
void graphics_draw_vertex (const int stack_id,
|
void graph_draw_vertex (const int graph_stack_id,
|
||||||
GLfloat x,
|
GLfloat x,
|
||||||
GLfloat y,
|
GLfloat y,
|
||||||
GLfloat z);
|
GLfloat z);
|
||||||
|
@ -332,7 +332,7 @@ void graphics_draw_vertex (const int stack_id,
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
void graphics_draw_color (const int stack_id, GLfloat r, GLfloat g, GLfloat b);
|
void graph_draw_color (const int graph_stack_id, GLfloat r, GLfloat g, GLfloat b);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Writes values to describe a line from a to b into the line buffer
|
* Writes values to describe a line from a to b into the line buffer
|
||||||
|
@ -341,7 +341,7 @@ void graphics_draw_color (const int stack_id, GLfloat r, GLfloat g, GLfloat b);
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
void graphics_draw_line (const int stack_id, GLuint a, GLuint b);
|
void graph_draw_line (const int graph_stack_id, GLuint a, GLuint b);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Writes values to describe an (a,b,c) plan (triangle) into the plan buffer
|
* Writes values to describe an (a,b,c) plan (triangle) into the plan buffer
|
||||||
|
@ -350,11 +350,11 @@ void graphics_draw_line (const int stack_id, GLuint a, GLuint b);
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
void graphics_draw_plan (const int stack_id, GLuint a, GLuint b, GLuint c);
|
void graph_draw_plan (const int graph_stack_id, GLuint a, GLuint b, GLuint c);
|
||||||
|
|
||||||
void graphics_model_setup (const int stack_id);
|
void graph_model_setup (const int graph_stack_id);
|
||||||
|
|
||||||
int draw_one_arrow_vertex (const int stack_id,
|
int graph_draw_one_arrow_vertex (const int graph_stack_id,
|
||||||
int space_X,
|
int space_X,
|
||||||
int space_Y,
|
int space_Y,
|
||||||
int space_Z,
|
int space_Z,
|
||||||
|
@ -364,7 +364,7 @@ int draw_one_arrow_vertex (const int stack_id,
|
||||||
int y,
|
int y,
|
||||||
int z);
|
int z);
|
||||||
|
|
||||||
int draw_one_arrow_line(const int stack_id,
|
int graph_draw_one_arrow_line(const int graph_stack_id,
|
||||||
int offset_vertex);
|
int offset_vertex);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -374,13 +374,13 @@ int draw_one_arrow_line(const int stack_id,
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
int draw_space_ridges_vertex (const int stack_id,
|
int graph_draw_space_ridges_vertex (const int graph_stack_id,
|
||||||
long offset_vertex,
|
long offset_vertex,
|
||||||
long x,
|
long x,
|
||||||
long y,
|
long y,
|
||||||
long z);
|
long z);
|
||||||
|
|
||||||
int draw_space_ridges_lines (const int stack_id);
|
int graph_draw_space_ridges_lines (const int graph_stack_id);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Writes grid lines on space faces
|
* Writes grid lines on space faces
|
||||||
|
@ -389,18 +389,18 @@ int draw_space_ridges_lines (const int stack_id);
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
long draw_grids_on_space_faces_vertex (const int stack_id,
|
long graph_draw_grids_on_space_faces_vertex (const int graph_stack_id,
|
||||||
long x,
|
long x,
|
||||||
long y,
|
long y,
|
||||||
long z);
|
long z);
|
||||||
|
|
||||||
long draw_grids_on_space_faces_lines (const int stack_id,
|
long graph_draw_grids_on_space_faces_lines (const int graph_stack_id,
|
||||||
long offset_vertex,
|
long offset_vertex,
|
||||||
long x,
|
long x,
|
||||||
long y,
|
long y,
|
||||||
long z);
|
long z);
|
||||||
|
|
||||||
int set_arrow (int stack_id,
|
int graph_set_arrow (int graph_stack_id,
|
||||||
int arrows_nb,
|
int arrows_nb,
|
||||||
int space_X,
|
int space_X,
|
||||||
int space_Y,
|
int space_Y,
|
|
@ -28,7 +28,7 @@
|
||||||
|
|
||||||
#include "../include/callbacks.h"
|
#include "../include/callbacks.h"
|
||||||
#include "../include/widgets.h"
|
#include "../include/widgets.h"
|
||||||
#include "../include/graphics.h"
|
#include "../include/graph.h"
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
@ -135,7 +135,7 @@ gboolean on_glarea_render(GtkGLArea *area,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (graphics_render_stack(gtk_widget_get_parent(GTK_WIDGET(area))) == false) {
|
if (graph_render_stack(gtk_widget_get_parent(GTK_WIDGET(area))) == false) {
|
||||||
on_auto_notification("Failed to render corresponding graphic stack !");
|
on_auto_notification("Failed to render corresponding graphic stack !");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -159,7 +159,7 @@ void on_glarea_realize(GtkWidget *widget)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Link graphical stack to widget
|
// Link graphical stack to widget
|
||||||
if (graphics_init_graphic_stack(gtk_widget_get_parent(widget),
|
if (graph_init_graph_stack(gtk_widget_get_parent(widget),
|
||||||
internal_error) == false) {
|
internal_error) == false) {
|
||||||
on_auto_notification(
|
on_auto_notification(
|
||||||
"Failed to link the graphic stack to widgets !");
|
"Failed to link the graphic stack to widgets !");
|
||||||
|
@ -184,7 +184,7 @@ void on_glarea_unrealize(GtkWidget *widget)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destroy graphic stack
|
// Destroy graphic stack
|
||||||
if (graphics_shutdown_graphic_stack(gtk_widget_get_parent(widget),
|
if (graph_shutdown_graph_stack(gtk_widget_get_parent(widget),
|
||||||
internal_error) == false) {
|
internal_error) == false) {
|
||||||
on_auto_notification(
|
on_auto_notification(
|
||||||
"Failed to shutdown the graphic stack !");
|
"Failed to shutdown the graphic stack !");
|
||||||
|
@ -206,7 +206,7 @@ void on_axis_value_change(GtkAdjustment *adjustment, gpointer data)
|
||||||
g_assert(axis >= 0 && axis < N_AXIS);
|
g_assert(axis >= 0 && axis < N_AXIS);
|
||||||
|
|
||||||
/* Update the rotation angle */
|
/* Update the rotation angle */
|
||||||
graphics_update_axis_stack(container_widget,
|
graph_update_axis_stack(container_widget,
|
||||||
axis,
|
axis,
|
||||||
gtk_adjustment_get_value(adjustment));
|
gtk_adjustment_get_value(adjustment));
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
#include <cglm/cglm.h>
|
#include <cglm/cglm.h>
|
||||||
|
|
||||||
#include "../../include/base.h"
|
#include "../../include/base.h"
|
||||||
#include "../../include/graphics.h"
|
#include "../../include/graph.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Writes values to describe a vertex at (x,y,z) intoq the vertex buffer
|
* Writes values to describe a vertex at (x,y,z) intoq the vertex buffer
|
||||||
|
@ -38,7 +38,7 @@
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
void graphics_draw_vertex (const int stack_id,
|
void graph_draw_vertex (const int stack_id,
|
||||||
GLfloat x,
|
GLfloat x,
|
||||||
GLfloat y,
|
GLfloat y,
|
||||||
GLfloat z)
|
GLfloat z)
|
||||||
|
@ -47,22 +47,22 @@ void graphics_draw_vertex (const int stack_id,
|
||||||
//g_printerr("stack_id is %d\n", stack_id);
|
//g_printerr("stack_id is %d\n", stack_id);
|
||||||
//g_printerr("graphic_stack is at %p\n", graphic_stack);
|
//g_printerr("graphic_stack is at %p\n", graphic_stack);
|
||||||
//g_printerr("graphic_stack[stack_id] is at %p\n", graphic_stack + stack_id);
|
//g_printerr("graphic_stack[stack_id] is at %p\n", graphic_stack + stack_id);
|
||||||
volatile struct graphic_stack_t *stack = &graphic_stack[stack_id];
|
volatile struct graph_stack_t *graph_stack = &graph_stack[stack_id];
|
||||||
|
|
||||||
//g_printerr("Currently stack->buffer_vertex_origin @ %p\n", stack->buffer_vertex_origin);
|
//g_printerr("Currently stack->buffer_vertex_origin @ %p\n", stack->buffer_vertex_origin);
|
||||||
|
|
||||||
//assert (stack->buffer_vertex_origin);
|
//assert (stack->buffer_vertex_origin);
|
||||||
|
|
||||||
stack->buffer_vertex_origin =
|
graph_stack->buffer_vertex_origin =
|
||||||
g_realloc (stack->buffer_vertex_origin,
|
g_realloc (graph_stack->buffer_vertex_origin,
|
||||||
(stack->buffer_vertex_size + 3) * sizeof(GLfloat));
|
(graph_stack->buffer_vertex_size + 3) * sizeof(GLfloat));
|
||||||
//print_stack(stack_id);
|
//print_stack(stack_id);
|
||||||
|
|
||||||
stack->buffer_vertex_origin[stack->buffer_vertex_size + 0] = x;
|
graph_stack->buffer_vertex_origin[graph_stack->buffer_vertex_size + 0] = x;
|
||||||
stack->buffer_vertex_origin[stack->buffer_vertex_size + 1] = y;
|
graph_stack->buffer_vertex_origin[graph_stack->buffer_vertex_size + 1] = y;
|
||||||
stack->buffer_vertex_origin[stack->buffer_vertex_size + 2] = z;
|
graph_stack->buffer_vertex_origin[graph_stack->buffer_vertex_size + 2] = z;
|
||||||
|
|
||||||
stack->buffer_vertex_size += 3;
|
graph_stack->buffer_vertex_size += 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -72,23 +72,23 @@ void graphics_draw_vertex (const int stack_id,
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
void graphics_draw_color (const int stack_id,
|
void graph_draw_color (const int stack_id,
|
||||||
GLfloat r,
|
GLfloat r,
|
||||||
GLfloat g,
|
GLfloat g,
|
||||||
GLfloat b)
|
GLfloat b)
|
||||||
{
|
{
|
||||||
struct graphic_stack_t *stack = &graphic_stack[stack_id];
|
struct graph_stack_t *graph_stack = &graph_stack[stack_id];
|
||||||
|
|
||||||
stack->buffer_colors_origin = g_realloc (stack->buffer_colors_origin,
|
graph_stack->buffer_colors_origin = g_realloc (graph_stack->buffer_colors_origin,
|
||||||
(stack->buffer_colors_size + 3) * sizeof(GLfloat));
|
(graph_stack->buffer_colors_size + 3) * sizeof(GLfloat));
|
||||||
|
|
||||||
assert (stack->buffer_colors_origin);
|
assert (graph_stack->buffer_colors_origin);
|
||||||
|
|
||||||
stack->buffer_colors_origin[stack->buffer_colors_size + 0] = r;
|
graph_stack->buffer_colors_origin[graph_stack->buffer_colors_size + 0] = r;
|
||||||
stack->buffer_colors_origin[stack->buffer_colors_size + 1] = g;
|
graph_stack->buffer_colors_origin[graph_stack->buffer_colors_size + 1] = g;
|
||||||
stack->buffer_colors_origin[stack->buffer_colors_size + 2] = b;
|
graph_stack->buffer_colors_origin[graph_stack->buffer_colors_size + 2] = b;
|
||||||
|
|
||||||
stack->buffer_colors_size += 3;
|
graph_stack->buffer_colors_size += 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -98,21 +98,21 @@ void graphics_draw_color (const int stack_id,
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
void graphics_draw_line (const int stack_id,
|
void graph_draw_line (const int stack_id,
|
||||||
GLuint a,
|
GLuint a,
|
||||||
GLuint b)
|
GLuint b)
|
||||||
{
|
{
|
||||||
struct graphic_stack_t *stack = &graphic_stack[stack_id];
|
struct graph_stack_t *stack = &graph_stack[stack_id];
|
||||||
|
|
||||||
stack->buffer_lines_origin = g_realloc (stack->buffer_lines_origin,
|
graph_stack->buffer_lines_origin = g_realloc (graph_stack->buffer_lines_origin,
|
||||||
(stack->buffer_lines_size + 2) * sizeof(GLuint));
|
(graph_stack->buffer_lines_size + 2) * sizeof(GLuint));
|
||||||
|
|
||||||
assert (stack->buffer_lines_origin);
|
assert (graph_stack->buffer_lines_origin);
|
||||||
|
|
||||||
stack->buffer_lines_origin[stack->buffer_lines_size + 0] = a;
|
graph_stack->buffer_lines_origin[graph_stack->buffer_lines_size + 0] = a;
|
||||||
stack->buffer_lines_origin[stack->buffer_lines_size + 1] = b;
|
graph_stack->buffer_lines_origin[graph_stack->buffer_lines_size + 1] = b;
|
||||||
|
|
||||||
stack->buffer_lines_size += 2;
|
graph_stack->buffer_lines_size += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -122,23 +122,23 @@ void graphics_draw_line (const int stack_id,
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
void graphics_draw_plan (const int stack_id,
|
void graph_draw_plan (const int stack_id,
|
||||||
GLuint a,
|
GLuint a,
|
||||||
GLuint b,
|
GLuint b,
|
||||||
GLuint c)
|
GLuint c)
|
||||||
{
|
{
|
||||||
struct graphic_stack_t *stack = &graphic_stack[stack_id];
|
struct graph_stack_t *stack = &graph_stack[stack_id];
|
||||||
|
|
||||||
stack->buffer_plans_origin = g_realloc (stack->buffer_plans_origin,
|
graph_stack->buffer_plans_origin = g_realloc (graph_stack->buffer_plans_origin,
|
||||||
(stack->buffer_plans_size + 3) * sizeof(GLuint));
|
(graph_stack->buffer_plans_size + 3) * sizeof(GLuint));
|
||||||
|
|
||||||
assert (stack->buffer_plans_origin);
|
assert (stack->buffer_plans_origin);
|
||||||
|
|
||||||
stack->buffer_plans_origin[stack->buffer_plans_size + 0] = a;
|
graph_stack->buffer_plans_origin[graph_stack->buffer_plans_size + 0] = a;
|
||||||
stack->buffer_plans_origin[stack->buffer_plans_size + 1] = b;
|
graph_stack->buffer_plans_origin[graph_stack->buffer_plans_size + 1] = b;
|
||||||
stack->buffer_plans_origin[stack->buffer_plans_size + 2] = c;
|
graph_stack->buffer_plans_origin[graph_stack->buffer_plans_size + 2] = c;
|
||||||
|
|
||||||
stack->buffer_plans_size += 3;
|
graph_stack->buffer_plans_size += 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -148,13 +148,13 @@ void graphics_draw_plan (const int stack_id,
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
void graphics_draw(const int stack_id)
|
void graph_draw(const int stack_id)
|
||||||
{
|
{
|
||||||
struct graphic_stack_t *stack = &graphic_stack[stack_id];
|
struct graph_stack_t *stack = &graph_stack[stack_id];
|
||||||
|
|
||||||
g_printerr("[debug] graphics_draw() started\n");
|
g_printerr("[debug] graph_draw() started\n");
|
||||||
|
|
||||||
print_stack(stack_id);
|
graph_print_stack(stack_id);
|
||||||
|
|
||||||
GLint cur_viewport[4];
|
GLint cur_viewport[4];
|
||||||
glGetIntegerv(GL_VIEWPORT, cur_viewport);
|
glGetIntegerv(GL_VIEWPORT, cur_viewport);
|
||||||
|
@ -204,5 +204,5 @@ void graphics_draw(const int stack_id)
|
||||||
glUseProgram(0);
|
glUseProgram(0);
|
||||||
|
|
||||||
glFlush();
|
glFlush();
|
||||||
g_printerr("[debug] graphics_draw() ended\n");
|
g_printerr("[debug] graph_draw() ended\n");
|
||||||
}
|
}
|
|
@ -25,7 +25,7 @@
|
||||||
* * * * * * * * * * * * * * * * * * * * * * * * * * */
|
* * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||||
|
|
||||||
|
|
||||||
#include "../../include/graphics.h"
|
#include "../../include/graph.h"
|
||||||
#include "../../include/callbacks.h"
|
#include "../../include/callbacks.h"
|
||||||
|
|
||||||
struct stack_index_t {
|
struct stack_index_t {
|
||||||
|
@ -62,7 +62,7 @@ int set_arrow (int stack_id, // 2024-06-27 DEBUG !
|
||||||
*
|
*
|
||||||
* @returns stack_id
|
* @returns stack_id
|
||||||
*/
|
*/
|
||||||
long graphics_get_graphic_stack(void *container_widget)
|
long graph_get_graph_stack(void *container_widget)
|
||||||
{
|
{
|
||||||
// look for stack_index entry
|
// look for stack_index entry
|
||||||
for (int i = 0; i < stack_index_size; i++) {
|
for (int i = 0; i < stack_index_size; i++) {
|
||||||
|
@ -80,7 +80,7 @@ long graphics_get_graphic_stack(void *container_widget)
|
||||||
*
|
*
|
||||||
* @returns stack_id
|
* @returns stack_id
|
||||||
*/
|
*/
|
||||||
long graphics_is_graphic_stack_ready(void *container_widget)
|
long graph_is_graph_stack_ready(void *container_widget)
|
||||||
{
|
{
|
||||||
// look for stack_index entry
|
// look for stack_index entry
|
||||||
for (int i = 0; i < stack_index_size; i++) {
|
for (int i = 0; i < stack_index_size; i++) {
|
||||||
|
@ -98,20 +98,20 @@ long graphics_is_graphic_stack_ready(void *container_widget)
|
||||||
*
|
*
|
||||||
* @returns bool, true if success
|
* @returns bool, true if success
|
||||||
*/
|
*/
|
||||||
bool graphics_init_graphic_stack(void *container_widget, GError *error_buffer)
|
bool graph_init_graph_stack(void *container_widget, GError *error_buffer)
|
||||||
{
|
{
|
||||||
g_printerr("[debug] graphics_init_graphic_stack()\n");
|
g_printerr("[debug] graph_init_graph_stack()\n");
|
||||||
|
|
||||||
g_printerr("[debug] graphics_init_graphic_stack() : target is %p\n", container_widget);
|
g_printerr("[debug] graph_init_graph_stack() : target is %p\n", container_widget);
|
||||||
|
|
||||||
// look for stack_index entry
|
// look for stack_index entry
|
||||||
for (int i = 0; i < stack_index_size; i++) {
|
for (int i = 0; i < stack_index_size; i++) {
|
||||||
g_printerr("[debug] graphics_init_graphic_stack() : i is %d\n", i);
|
g_printerr("[debug] graph_init_graph_stack() : i is %d\n", i);
|
||||||
g_printerr("[debug] graphics_init_graphic_stack() : target would be %p\n",
|
g_printerr("[debug] graph_init_graph_stack() : target would be %p\n",
|
||||||
stack_index[i].container_widget);
|
stack_index[i].container_widget);
|
||||||
if (stack_index[i].container_widget == (void *)container_widget) {
|
if (stack_index[i].container_widget == (void *)container_widget) {
|
||||||
stack_index[i].stack_id = graphics_init(&error_buffer);
|
stack_index[i].stack_id = graph_init(&error_buffer);
|
||||||
g_printerr("[debug] graphics_init_graphic_stack() : stack_id is %ld\n",
|
g_printerr("[debug] graph_init_graph_stack() : stack_id is %ld\n",
|
||||||
stack_index[i].stack_id);
|
stack_index[i].stack_id);
|
||||||
if (stack_index[i].stack_id >= 0)
|
if (stack_index[i].stack_id >= 0)
|
||||||
return true;
|
return true;
|
||||||
|
@ -129,12 +129,12 @@ bool graphics_init_graphic_stack(void *container_widget, GError *error_buffer)
|
||||||
*
|
*
|
||||||
* @returns bool, true if success
|
* @returns bool, true if success
|
||||||
*/
|
*/
|
||||||
bool graphics_shutdown_graphic_stack(void *container_widget, GError *error_buffer)
|
bool graph_shutdown_graph_stack(void *container_widget, GError *error_buffer)
|
||||||
{
|
{
|
||||||
// look for stack_index entry
|
// look for stack_index entry
|
||||||
for (int i = 0; i < stack_index_size; i++) {
|
for (int i = 0; i < stack_index_size; i++) {
|
||||||
if (stack_index[i].container_widget == (void *)container_widget) {
|
if (stack_index[i].container_widget == (void *)container_widget) {
|
||||||
if (graphics_shutdown(stack_index[i].stack_id,
|
if (graph_shutdown(stack_index[i].stack_id,
|
||||||
&error_buffer) == false) {
|
&error_buffer) == false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -146,7 +146,7 @@ bool graphics_shutdown_graphic_stack(void *container_widget, GError *error_buffe
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void graphics_clean_stack_index(void)
|
void graph_clean_stack_index(void)
|
||||||
{
|
{
|
||||||
// look for stack_index entry
|
// look for stack_index entry
|
||||||
for (int i = 0; i < stack_index_size; i++) {
|
for (int i = 0; i < stack_index_size; i++) {
|
||||||
|
@ -162,19 +162,19 @@ void graphics_clean_stack_index(void)
|
||||||
*
|
*
|
||||||
* @returns bool, true if success
|
* @returns bool, true if success
|
||||||
*/
|
*/
|
||||||
bool graphics_render_stack(GtkWidget *container_widget)
|
bool graph_render_stack(GtkWidget *container_widget)
|
||||||
{
|
{
|
||||||
// look for stack_index entry
|
// look for stack_index entry
|
||||||
for (int i = 0; i < stack_index_size; i++) {
|
for (int i = 0; i < stack_index_size; i++) {
|
||||||
if (stack_index[i].container_widget == (void *)container_widget) {
|
if (stack_index[i].container_widget == (void *)container_widget) {
|
||||||
graphics_draw (stack_index[i].stack_id);
|
graph_draw (stack_index[i].stack_id);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//void graphics_draw(const int stack_id) {printf("graph_area.c > void graphics_draw(const int stack_id) (161)\n");}
|
//void graph_draw(const int stack_id) {printf("graph_area.c > void graph_draw(const int stack_id) (161)\n");}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Look for stack entry and triggers OpenGL for drawing
|
* Look for stack entry and triggers OpenGL for drawing
|
||||||
|
@ -183,12 +183,12 @@ bool graphics_render_stack(GtkWidget *container_widget)
|
||||||
*
|
*
|
||||||
* @returns bool, true if success
|
* @returns bool, true if success
|
||||||
*/
|
*/
|
||||||
bool graphics_update_axis_stack(GtkWidget *container_widget, int axis, int value)
|
bool graph_update_axis_stack(GtkWidget *container_widget, int axis, int value)
|
||||||
{
|
{
|
||||||
// look for stack_index entry
|
// look for stack_index entry
|
||||||
for (int i = 0; i < stack_index_size; i++) {
|
for (int i = 0; i < stack_index_size; i++) {
|
||||||
if (stack_index[i].container_widget == (void *)container_widget) {
|
if (stack_index[i].container_widget == (void *)container_widget) {
|
||||||
graphic_stack[stack_index[i].stack_id].rotation_angles[axis] = value;
|
graph_stack[stack_index[i].stack_id].rotation_angles[axis] = value;
|
||||||
gtk_widget_queue_draw((GtkWidget*)(stack_index[i].gl_area));
|
gtk_widget_queue_draw((GtkWidget*)(stack_index[i].gl_area));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -203,11 +203,11 @@ bool graphics_update_axis_stack(GtkWidget *container_widget, int axis, int value
|
||||||
*
|
*
|
||||||
* @returns bool, true if success
|
* @returns bool, true if success
|
||||||
*/
|
*/
|
||||||
void graphics_shutdown_all_graphic_stacks(void)
|
void graph_shutdown_all_graph_stacks(void)
|
||||||
{
|
{
|
||||||
// look for stack_index entry
|
// look for stack_index entry
|
||||||
for (int i = 0; i < stack_index_size; i++) {
|
for (int i = 0; i < stack_index_size; i++) {
|
||||||
graphics_shutdown(stack_index[i].stack_id, NULL);
|
graph_shutdown(stack_index[i].stack_id, NULL);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -263,20 +263,20 @@ GtkWidget *create_axis_slider(int axis)
|
||||||
/*
|
/*
|
||||||
* Creates GLArea and indexes it
|
* Creates GLArea and indexes it
|
||||||
*
|
*
|
||||||
* @params target_mode, meaning which graphics_stack we're on
|
* @params target_mode, meaning which graph_stack we're on
|
||||||
* target_widget, meaning the box that will host the GLArea
|
* target_widget, meaning the box that will host the GLArea
|
||||||
*
|
*
|
||||||
* @returns bool, true if success
|
* @returns bool, true if success
|
||||||
*/
|
*/
|
||||||
bool graphics_setup_glarea(int target_mode, GtkWidget *target_widget)
|
bool graph_setup_glarea(int target_mode, GtkWidget *target_widget)
|
||||||
{
|
{
|
||||||
GtkWidget *gl_area;
|
GtkWidget *gl_area;
|
||||||
|
|
||||||
g_printerr("[debug] graphics_setup_glarea()\n");
|
g_printerr("[debug] graph_setup_glarea()\n");
|
||||||
|
|
||||||
assert(target_widget);
|
assert(target_widget);
|
||||||
|
|
||||||
g_printerr("[debug] graphics_setup_glarea() : target is %p\n", target_widget);
|
g_printerr("[debug] graph_setup_glarea() : target is %p\n", target_widget);
|
||||||
|
|
||||||
if (stack_index == NULL) {
|
if (stack_index == NULL) {
|
||||||
stack_index = g_malloc(sizeof(struct stack_index_t));
|
stack_index = g_malloc(sizeof(struct stack_index_t));
|
||||||
|
@ -314,9 +314,9 @@ bool graphics_setup_glarea(int target_mode, GtkWidget *target_widget)
|
||||||
|
|
||||||
stack_index[stack_index_size-1].gl_area = (void*)gl_area;
|
stack_index[stack_index_size-1].gl_area = (void*)gl_area;
|
||||||
|
|
||||||
g_printerr("[debug] graphics_setup_glarea() : set target to %p\n", target_widget);
|
g_printerr("[debug] graph_setup_glarea() : set target to %p\n", target_widget);
|
||||||
|
|
||||||
g_printerr("[debug] graphics_setup_glarea() : stack_index (@0x%p) had %ld elements\n",
|
g_printerr("[debug] graph_setup_glarea() : stack_index (@0x%p) had %ld elements\n",
|
||||||
stack_index,
|
stack_index,
|
||||||
stack_index_size);
|
stack_index_size);
|
||||||
|
|
|
@ -26,13 +26,13 @@
|
||||||
* * * * * * * * * * * * * * * * * * * * * * * * * * */
|
* * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||||
|
|
||||||
|
|
||||||
#include "../../include/graphics.h"
|
#include "../../include/graph.h"
|
||||||
#include "../../include/parsing.h"
|
#include "../../include/parse.h"
|
||||||
|
|
||||||
#define TEST 0
|
#define TEST 0
|
||||||
|
|
||||||
struct graphic_stack_t *graphic_stack = NULL;
|
struct graph_stack_t *graph_stack = NULL;
|
||||||
size_t graphic_stack_size = 0;
|
size_t graph_stack_size = 0;
|
||||||
int *free_stack_slot = NULL;
|
int *free_stack_slot = NULL;
|
||||||
size_t free_stack_slot_size = 0;
|
size_t free_stack_slot_size = 0;
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ size_t free_stack_slot_size = 0;
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void graphics_debug_callback(GLenum source, GLenum type, GLuint id,
|
static void graph_debug_callback(GLenum source, GLenum type, GLuint id,
|
||||||
GLenum severity, GLsizei length,
|
GLenum severity, GLsizei length,
|
||||||
const GLchar *msg, const void *data)
|
const GLchar *msg, const void *data)
|
||||||
{
|
{
|
||||||
|
@ -105,17 +105,17 @@ static void graphics_debug_callback(GLenum source, GLenum type, GLuint id,
|
||||||
*
|
*
|
||||||
* @return id if initialized
|
* @return id if initialized
|
||||||
*/
|
*/
|
||||||
int graphics_init(void *error_buffer)
|
int graph_init(void *error_buffer)
|
||||||
{
|
{
|
||||||
int cur_id = 0;
|
int cur_id = 0;
|
||||||
struct graphic_stack_t *stack;
|
struct graph_stack_t *graph_stack;
|
||||||
|
|
||||||
g_printerr("[debug] graphics_init()\n");
|
g_printerr("[debug] graph_init()\n");
|
||||||
|
|
||||||
if (graphic_stack == NULL) {
|
if (graph_stack == NULL) {
|
||||||
graphic_stack = g_malloc0(sizeof(struct graphic_stack_t));
|
graph_stack = g_malloc0(sizeof(struct graph_stack_t));
|
||||||
graphic_stack_size = 1;
|
graph_stack_size = 1;
|
||||||
g_printerr("[debug] graphics_init(): init graphic_stack @ %p\n", graphic_stack);
|
g_printerr("[debug] graph_init(): init graph_stack @ %p\n", graph_stack);
|
||||||
} else {
|
} else {
|
||||||
// Check if there are free slots
|
// Check if there are free slots
|
||||||
if (free_stack_slot_size) {
|
if (free_stack_slot_size) {
|
||||||
|
@ -126,33 +126,33 @@ int graphics_init(void *error_buffer)
|
||||||
free_stack_slot_size-- *
|
free_stack_slot_size-- *
|
||||||
sizeof(int));
|
sizeof(int));
|
||||||
} else {
|
} else {
|
||||||
cur_id = graphic_stack_size;
|
cur_id = graph_stack_size;
|
||||||
graphic_stack = g_realloc(graphic_stack,
|
graph_stack = g_realloc(graph_stack,
|
||||||
++graphic_stack_size *
|
++graph_stack_size *
|
||||||
sizeof(struct graphic_stack_t));
|
sizeof(struct graph_stack_t));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(&graphic_stack[cur_id], 0, sizeof(struct graphic_stack_t));
|
memset(&graph_stack[cur_id], 0, sizeof(struct graph_stack_t));
|
||||||
|
|
||||||
g_printerr("[debug] graphics_init() : graphic_stack (@0x%p) has %ld elements\n",
|
g_printerr("[debug] graph_init() : graph_stack (@0x%p) has %ld elements\n",
|
||||||
graphic_stack,
|
graph_stack,
|
||||||
graphic_stack_size);
|
graph_stack_size);
|
||||||
|
|
||||||
stack = &graphic_stack[cur_id];
|
graph_stack = &graph_stack[cur_id];
|
||||||
stack->id = cur_id;
|
graph_stack->id = cur_id;
|
||||||
|
|
||||||
glEnable(GL_DEBUG_OUTPUT);
|
glEnable(GL_DEBUG_OUTPUT);
|
||||||
glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
|
glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
|
||||||
glEnable(GL_MULTISAMPLE);
|
glEnable(GL_MULTISAMPLE);
|
||||||
|
|
||||||
if (!graphics_init_shaders(cur_id)) return -1;
|
if (!graph_init_shaders(cur_id)) return -1;
|
||||||
|
|
||||||
print_stack(cur_id);
|
graph_print_stack(cur_id);
|
||||||
|
|
||||||
graphics_init_buffers(cur_id);
|
graph_init_buffers(cur_id);
|
||||||
|
|
||||||
glDebugMessageCallback(graphics_debug_callback, NULL);
|
glDebugMessageCallback(graph_debug_callback, NULL);
|
||||||
|
|
||||||
//print_stack(cur_id);
|
//print_stack(cur_id);
|
||||||
|
|
||||||
|
@ -166,37 +166,37 @@ int graphics_init(void *error_buffer)
|
||||||
*
|
*
|
||||||
* @return true if success
|
* @return true if success
|
||||||
*/
|
*/
|
||||||
bool graphics_shutdown(const int id, void *error_buffer)
|
bool graph_shutdown(const int id, void *error_buffer)
|
||||||
{
|
{
|
||||||
struct graphic_stack_t *stack;
|
struct graph_stack_t *graph_stack;
|
||||||
|
|
||||||
if (id >= graphic_stack_size ||
|
if (id >= graph_stack_size ||
|
||||||
graphic_stack_size == 0 ||
|
graph_stack_size == 0 ||
|
||||||
graphic_stack == NULL)
|
graph_stack == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
stack = &graphic_stack[id];
|
graph_stack = &graph_stack[id];
|
||||||
|
|
||||||
//XXX
|
//XXX
|
||||||
free(stack->arrows_ptr);
|
free(graph_stack->arrows_ptr);
|
||||||
stack->arrows_ptr = NULL;
|
graph_stack->arrows_ptr = NULL;
|
||||||
stack->arrows_nb = 0;
|
graph_stack->arrows_nb = 0;
|
||||||
|
|
||||||
glDeleteBuffers(1, &stack->position_buffer);
|
glDeleteBuffers(1, &graph_stack->position_buffer);
|
||||||
glDeleteBuffers(1, &stack->color_buffer);
|
glDeleteBuffers(1, &graph_stack->color_buffer);
|
||||||
glDeleteProgram(stack->program);
|
glDeleteProgram(graph_stack->program);
|
||||||
|
|
||||||
g_free(stack->buffer_vertex_origin);
|
g_free(graph_stack->buffer_vertex_origin);
|
||||||
g_free(stack->buffer_colors_origin);
|
g_free(graph_stack->buffer_colors_origin);
|
||||||
g_free(stack->buffer_lines_origin);
|
g_free(graph_stack->buffer_lines_origin);
|
||||||
g_free(stack->buffer_plans_origin);
|
g_free(graph_stack->buffer_plans_origin);
|
||||||
|
|
||||||
if (graphic_stack_size == 1) {
|
if (graph_stack_size == 1) {
|
||||||
free(graphic_stack);
|
free(graph_stack);
|
||||||
graphic_stack = NULL;
|
graph_stack = NULL;
|
||||||
graphic_stack_size = 0;
|
graph_stack_size = 0;
|
||||||
} else {
|
} else {
|
||||||
memset(&graphic_stack[id], 0, sizeof(struct graphic_stack_t));
|
memset(&graph_stack[id], 0, sizeof(struct graph_stack_t));
|
||||||
free_stack_slot = g_realloc(free_stack_slot,
|
free_stack_slot = g_realloc(free_stack_slot,
|
||||||
++free_stack_slot_size *
|
++free_stack_slot_size *
|
||||||
sizeof(int));
|
sizeof(int));
|
||||||
|
@ -225,7 +225,7 @@ bool graphics_shutdown(const int id, void *error_buffer)
|
||||||
* Attention, les vertex centraux de chaque unité d'espace (cube)
|
* Attention, les vertex centraux de chaque unité d'espace (cube)
|
||||||
* peuvent être redondants (max 6)
|
* peuvent être redondants (max 6)
|
||||||
*/
|
*/
|
||||||
void graphics_model_setup (const int stack_id)
|
void graph_model_setup (const int stack_id)
|
||||||
{
|
{
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
@ -233,7 +233,7 @@ void graphics_model_setup (const int stack_id)
|
||||||
|
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
|
|
||||||
struct graphic_stack_t *stack = &graphic_stack[stack_id];
|
struct graph_stack_t *graph_stack = &graph_stack[stack_id];
|
||||||
char dimension;
|
char dimension;
|
||||||
long space_X;
|
long space_X;
|
||||||
long space_Y;
|
long space_Y;
|
||||||
|
@ -274,7 +274,7 @@ void graphics_model_setup (const int stack_id)
|
||||||
g_print("[GRAPH DEBUG] z = %ld\n", space_Z);
|
g_print("[GRAPH DEBUG] z = %ld\n", space_Z);
|
||||||
|
|
||||||
density_max = space_X * space_Y * space_Z;
|
density_max = space_X * space_Y * space_Z;
|
||||||
stack->arrows_nb = 0;
|
graph_stack->arrows_nb = 0;
|
||||||
|
|
||||||
multiplicity = model_get_multiplicity();
|
multiplicity = model_get_multiplicity();
|
||||||
g_print("[GRAPH DEBUG] site_multiplicity = %d, density_max = %d\n", multiplicity, density_max);
|
g_print("[GRAPH DEBUG] site_multiplicity = %d, density_max = %d\n", multiplicity, density_max);
|
||||||
|
@ -285,14 +285,14 @@ void graphics_model_setup (const int stack_id)
|
||||||
|
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
|
|
||||||
draw_space_ridges_vertex (stack_id, stack->buffer_vertex_size, space_X, space_Y, space_Z);
|
graph_draw_space_ridges_vertex (stack_id, graph_stack->buffer_vertex_size, space_X, space_Y, space_Z);
|
||||||
draw_space_ridges_lines (stack_id);
|
graph_draw_space_ridges_lines (stack_id);
|
||||||
draw_grids_on_space_faces_vertex (stack_id, space_X, space_Y, space_Z);
|
graph_draw_grids_on_space_faces_vertex (stack_id, space_X, space_Y, space_Z);
|
||||||
draw_grids_on_space_faces_lines (stack_id, stack->buffer_lines_size, space_X, space_Y, space_Z);
|
graph_draw_grids_on_space_faces_lines (stack_id, graph_stack->buffer_lines_size, space_X, space_Y, space_Z);
|
||||||
|
|
||||||
stack->buffer_vertex_0_arrow = stack->buffer_vertex_size;
|
graph_stack->buffer_vertex_0_arrow = graph_stack->buffer_vertex_size;
|
||||||
stack->buffer_colors_0_arrow = stack->buffer_colors_size;
|
graph_stack->buffer_colors_0_arrow = graph_stack->buffer_colors_size;
|
||||||
stack->buffer_lines_0_arrow = stack->buffer_lines_size;
|
graph_stack->buffer_lines_0_arrow = graph_stack->buffer_lines_size;
|
||||||
|
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
@ -313,10 +313,10 @@ void graphics_model_setup (const int stack_id)
|
||||||
|
|
||||||
while (model_get_next_arrow(&arrow, (char *)&state_id, dimension)) {
|
while (model_get_next_arrow(&arrow, (char *)&state_id, dimension)) {
|
||||||
g_print("[GRAPH DEBUG] cur arrow has x = %d\n", arrow.x);
|
g_print("[GRAPH DEBUG] cur arrow has x = %d\n", arrow.x);
|
||||||
stack->arrows_nb = set_arrow (stack_id, stack->arrows_nb, space_X, space_Y, space_Z, arrow.load, arrow.site, arrow.x, arrow.y, arrow.z);
|
graph_stack->arrows_nb = set_arrow (stack_id, graph_stack->arrows_nb, space_X, space_Y, space_Z, arrow.load, arrow.site, arrow.x, arrow.y, arrow.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stack->arrows_nb != announced_arrows_nb)
|
if (graph_stack->arrows_nb != announced_arrows_nb)
|
||||||
g_printerr("ARGH : not all arrows have been parsed !\n");
|
g_printerr("ARGH : not all arrows have been parsed !\n");
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,162 @@
|
||||||
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
|
* *
|
||||||
|
* Gem-graph client *
|
||||||
|
* *
|
||||||
|
* Drawing empty space *
|
||||||
|
* *
|
||||||
|
* Copyright © 2021 Libre en Communs <contact@a-lec.org> *
|
||||||
|
* Copyright © 2023 Adrien Bourmault <neox@a-lec.org> *
|
||||||
|
* Copyright © 2024 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 publishedby 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 "../../include/graph.h"
|
||||||
|
|
||||||
|
int graph_draw_space_ridges_vertex (const int stack_id,
|
||||||
|
long offset_vertex,
|
||||||
|
long x,
|
||||||
|
long y,
|
||||||
|
long z)
|
||||||
|
{
|
||||||
|
GLfloat max = fmax(x, y); max = fmax(max, z);
|
||||||
|
|
||||||
|
graph_draw_vertex (stack_id, offset_vertex - x / max, offset_vertex - y / max, - z / max);
|
||||||
|
|
||||||
|
graph_draw_vertex (stack_id, offset_vertex + x / max, offset_vertex - y / max, - z / max);
|
||||||
|
graph_draw_vertex (stack_id, offset_vertex - x / max, offset_vertex + y / max, - z / max);
|
||||||
|
graph_draw_vertex (stack_id, offset_vertex - x / max, offset_vertex - y / max, + z / max);
|
||||||
|
|
||||||
|
graph_draw_vertex (stack_id, offset_vertex + x / max, offset_vertex + y / max, - z / max);
|
||||||
|
graph_draw_vertex (stack_id, offset_vertex + x / max, offset_vertex - y / max, + z / max);
|
||||||
|
graph_draw_vertex (stack_id, offset_vertex - x / max, offset_vertex + y / max, + z / max);
|
||||||
|
|
||||||
|
graph_draw_vertex (stack_id, offset_vertex + x / max, + y / max, + z / max);
|
||||||
|
|
||||||
|
graph_draw_color (stack_id, 0.8f, 0.6f, 0.5f);
|
||||||
|
graph_draw_color (stack_id, 0.8f, 0.6f, 0.5f);
|
||||||
|
graph_draw_color (stack_id, 0.8f, 0.6f, 0.5f);
|
||||||
|
graph_draw_color (stack_id, 0.8f, 0.6f, 0.5f);
|
||||||
|
graph_draw_color (stack_id, 0.8f, 0.6f, 0.5f);
|
||||||
|
graph_draw_color (stack_id, 0.8f, 0.6f, 0.5f);
|
||||||
|
graph_draw_color (stack_id, 0.8f, 0.6f, 0.5f);
|
||||||
|
graph_draw_color (stack_id, 0.8f, 0.6f, 0.5f);
|
||||||
|
|
||||||
|
return 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
int graph_draw_space_ridges_lines (const int stack_id)
|
||||||
|
{
|
||||||
|
graph_draw_line (stack_id, 0, 1); graph_draw_line (stack_id, 7, 4);
|
||||||
|
graph_draw_line (stack_id, 0, 2); graph_draw_line (stack_id, 7, 5);
|
||||||
|
graph_draw_line (stack_id, 0, 3); graph_draw_line (stack_id, 7, 6);
|
||||||
|
|
||||||
|
graph_draw_line (stack_id, 1, 4); graph_draw_line (stack_id, 2, 4);
|
||||||
|
graph_draw_line (stack_id, 1, 5); graph_draw_line (stack_id, 3, 5);
|
||||||
|
graph_draw_line (stack_id, 2, 6); graph_draw_line (stack_id, 3, 6);
|
||||||
|
|
||||||
|
return 12;
|
||||||
|
}
|
||||||
|
|
||||||
|
long graph_draw_grids_on_space_faces_vertex (const int stack_id,
|
||||||
|
long x,
|
||||||
|
long y,
|
||||||
|
long z)
|
||||||
|
{
|
||||||
|
float i, max = fmax(x, y); max = fmax(max, z);
|
||||||
|
|
||||||
|
for (i = 1; i < x; i++) {
|
||||||
|
|
||||||
|
graph_draw_vertex (stack_id, (2 * i / x - 1) * x / max, - y / max, - z / max);
|
||||||
|
graph_draw_vertex (stack_id, (2 * i / x - 1) * x / max, - y / max, z / max);
|
||||||
|
graph_draw_vertex (stack_id, (2 * i / x - 1) * x / max, y / max, z / max);
|
||||||
|
graph_draw_vertex (stack_id, (2 * i / x - 1) * x / max, y / max, - z / max);
|
||||||
|
|
||||||
|
graph_draw_color (stack_id, 0.55f, 0.55f, 0.55f);
|
||||||
|
graph_draw_color (stack_id, 0.55f, 0.55f, 0.55f);
|
||||||
|
graph_draw_color (stack_id, 0.55f, 0.55f, 0.55f);
|
||||||
|
graph_draw_color (stack_id, 0.55f, 0.55f, 0.55f);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* offset_vertex += (x - 1) * 4; */ /* offset_colors += (x - 1) * 4; */
|
||||||
|
|
||||||
|
for (i = 1; i < y; i++) {
|
||||||
|
|
||||||
|
graph_draw_vertex (stack_id, - x / max, (2 * i / y - 1) * y / max, - z / max);
|
||||||
|
graph_draw_vertex (stack_id, - x / max, (2 * i / y - 1) * y / max, z / max);
|
||||||
|
graph_draw_vertex (stack_id, x / max, (2 * i / y - 1) * y / max, z / max);
|
||||||
|
graph_draw_vertex (stack_id, x / max, (2 * i / y - 1) * y / max, - z / max);
|
||||||
|
|
||||||
|
graph_draw_color (stack_id, 0.55f, 0.55f, 0.55f);
|
||||||
|
graph_draw_color (stack_id, 0.55f, 0.55f, 0.55f);
|
||||||
|
graph_draw_color (stack_id, 0.55f, 0.55f, 0.55f);
|
||||||
|
graph_draw_color (stack_id, 0.55f, 0.55f, 0.55f);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* offset_vertex += (y - 1) * 4; */ /* offset_colors += (y - 1) * 4; */
|
||||||
|
|
||||||
|
for (i = 1; i < z; i++) {
|
||||||
|
|
||||||
|
graph_draw_vertex (stack_id, - x / max, - y / max, (2 * i / z - 1) * z / max);
|
||||||
|
graph_draw_vertex (stack_id, - x / max, y / max, (2 * i / z - 1) * z / max);
|
||||||
|
graph_draw_vertex (stack_id, x / max, y / max, (2 * i / z - 1) * z / max);
|
||||||
|
graph_draw_vertex (stack_id, x / max, - y / max, (2 * i / z - 1) * z / max);
|
||||||
|
|
||||||
|
graph_draw_color (stack_id, 0.55f, 0.55f, 0.55f);
|
||||||
|
graph_draw_color (stack_id, 0.55f, 0.55f, 0.55f);
|
||||||
|
graph_draw_color (stack_id, 0.55f, 0.55f, 0.55f);
|
||||||
|
graph_draw_color (stack_id, 0.55f, 0.55f, 0.55f);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (x + y + z - 3) * 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
long graph_draw_grids_on_space_faces_lines (const int stack_id,
|
||||||
|
long offset_vertex,
|
||||||
|
long x,
|
||||||
|
long y,
|
||||||
|
long z)
|
||||||
|
{
|
||||||
|
offset_vertex = offset_vertex / 3;
|
||||||
|
|
||||||
|
for (int i = 0; i < x - 1; i ++) {
|
||||||
|
|
||||||
|
graph_draw_line (stack_id, offset_vertex + i * 4 + 1, offset_vertex + i * 4 + 2);
|
||||||
|
graph_draw_line (stack_id, offset_vertex + i * 4 + 2, offset_vertex + i * 4 + 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
offset_vertex += (x - 1) * 4;
|
||||||
|
|
||||||
|
for (int i = 0; i < y - 1; i ++) {
|
||||||
|
|
||||||
|
graph_draw_line (stack_id, offset_vertex + i * 4 + 2, offset_vertex + i * 4 + 3);
|
||||||
|
graph_draw_line (stack_id, offset_vertex + i * 4 + 3, offset_vertex + i * 4 + 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
offset_vertex += (y - 1) * 4;
|
||||||
|
|
||||||
|
for (int i = 0; i < z - 1; i ++) {
|
||||||
|
|
||||||
|
graph_draw_line (stack_id, offset_vertex + i * 4 + 0, offset_vertex + i * 4 + 1);
|
||||||
|
graph_draw_line (stack_id, offset_vertex + i * 4 + 3, offset_vertex + i * 4 + 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (x + y + z - 3) * 4;
|
||||||
|
}
|
||||||
|
|
|
@ -28,28 +28,28 @@
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
#include "../../include/graphics.h"
|
#include "../../include/graph.h"
|
||||||
|
|
||||||
/* Initializes the buffer of a gl_area
|
/* Initializes the buffer of a gl_area
|
||||||
* Calls according to the user preferences
|
* Calls according to the user preferences
|
||||||
* @param gl_area, ptr to the gl_area widget
|
* @param gl_area, ptr to the gl_area widget
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
void graphics_init_buffers(const int stack_id)
|
void graph_init_buffers(const int stack_id)
|
||||||
{
|
{
|
||||||
struct graphic_stack_t *stack = &graphic_stack[stack_id];
|
struct graph_stack_t *graph_stack = &graph_stack[stack_id];
|
||||||
|
|
||||||
//XXX
|
//XXX
|
||||||
graphics_model_setup(stack_id);
|
graph_model_setup(stack_id);
|
||||||
|
|
||||||
GLuint vao, vertex_buffer, color_buffer;
|
GLuint vao, vertex_buffer, color_buffer;
|
||||||
|
|
||||||
glGenBuffers(1, &vertex_buffer);
|
glGenBuffers(1, &vertex_buffer);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer);
|
glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer);
|
||||||
glBufferData(GL_ARRAY_BUFFER,
|
glBufferData(GL_ARRAY_BUFFER,
|
||||||
stack->buffer_vertex_size *
|
graph_stack->buffer_vertex_size *
|
||||||
sizeof(stack->buffer_vertex_origin[0]),
|
sizeof(graph_stack->buffer_vertex_origin[0]),
|
||||||
stack->buffer_vertex_origin,
|
graph_stack->buffer_vertex_origin,
|
||||||
GL_STATIC_DRAW);
|
GL_STATIC_DRAW);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
|
|
||||||
|
@ -57,9 +57,9 @@ void graphics_init_buffers(const int stack_id)
|
||||||
// colors
|
// colors
|
||||||
glGenBuffers(1, &color_buffer);
|
glGenBuffers(1, &color_buffer);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, color_buffer);
|
glBindBuffer(GL_ARRAY_BUFFER, color_buffer);
|
||||||
glBufferData(GL_ARRAY_BUFFER, stack->buffer_colors_size *
|
glBufferData(GL_ARRAY_BUFFER, graph_stack->buffer_colors_size *
|
||||||
sizeof(stack->buffer_colors_origin[0]),
|
sizeof(graph_stack->buffer_colors_origin[0]),
|
||||||
stack->buffer_colors_origin,
|
graph_stack->buffer_colors_origin,
|
||||||
GL_STATIC_DRAW);
|
GL_STATIC_DRAW);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
|
|
||||||
|
@ -67,9 +67,9 @@ void graphics_init_buffers(const int stack_id)
|
||||||
glGenVertexArrays(1, &vao);
|
glGenVertexArrays(1, &vao);
|
||||||
glBindVertexArray(vao);
|
glBindVertexArray(vao);
|
||||||
|
|
||||||
stack->vao = vao;
|
graph_stack->vao = vao;
|
||||||
stack->position_buffer = vertex_buffer;
|
graph_stack->position_buffer = vertex_buffer;
|
||||||
stack->color_buffer = color_buffer;
|
graph_stack->color_buffer = color_buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -79,9 +79,9 @@ void graphics_init_buffers(const int stack_id)
|
||||||
*
|
*
|
||||||
* @return true if initialized
|
* @return true if initialized
|
||||||
*/
|
*/
|
||||||
bool graphics_init_shaders(const int stack_id)
|
bool graph_init_shaders(const int stack_id)
|
||||||
{
|
{
|
||||||
struct graphic_stack_t *stack = &graphic_stack[stack_id];
|
struct graph_stack_t *graph_stack = &graph_stack[stack_id];
|
||||||
char *vertex_shader;
|
char *vertex_shader;
|
||||||
char *fragment_shader;
|
char *fragment_shader;
|
||||||
int status;
|
int status;
|
||||||
|
@ -95,10 +95,10 @@ bool graphics_init_shaders(const int stack_id)
|
||||||
vertex_shader = read_file(VERTEX_SHADER_FILE);
|
vertex_shader = read_file(VERTEX_SHADER_FILE);
|
||||||
if (vertex_shader == NULL)
|
if (vertex_shader == NULL)
|
||||||
return false;
|
return false;
|
||||||
vertex = create_shader(stack_id, GL_VERTEX_SHADER, vertex_shader);
|
vertex = graph_create_shader(stack_id, GL_VERTEX_SHADER, vertex_shader);
|
||||||
|
|
||||||
if(vertex == 0) {
|
if(vertex == 0) {
|
||||||
stack->program = 0;
|
graph_stack->program = 0;
|
||||||
g_free(vertex_shader);
|
g_free(vertex_shader);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -107,11 +107,11 @@ bool graphics_init_shaders(const int stack_id)
|
||||||
fragment_shader = read_file(FRAG_SHADER_FILE);
|
fragment_shader = read_file(FRAG_SHADER_FILE);
|
||||||
if (fragment_shader == NULL)
|
if (fragment_shader == NULL)
|
||||||
return false;
|
return false;
|
||||||
fragment = create_shader(stack_id, GL_FRAGMENT_SHADER, fragment_shader);
|
fragment = graph_create_shader(stack_id, GL_FRAGMENT_SHADER, fragment_shader);
|
||||||
|
|
||||||
if(fragment == 0) {
|
if(fragment == 0) {
|
||||||
glDeleteShader(vertex);
|
glDeleteShader(vertex);
|
||||||
stack->program = 0;
|
graph_stack->program = 0;
|
||||||
g_free(vertex_shader);
|
g_free(vertex_shader);
|
||||||
g_free(fragment_shader);
|
g_free(fragment_shader);
|
||||||
return false;
|
return false;
|
||||||
|
@ -120,7 +120,7 @@ bool graphics_init_shaders(const int stack_id)
|
||||||
// Link shaders to program
|
// Link shaders to program
|
||||||
program = glCreateProgram();
|
program = glCreateProgram();
|
||||||
printf("\n------------------------------------------------------------------------------------------\n");
|
printf("\n------------------------------------------------------------------------------------------\n");
|
||||||
printf("[debug] graphics_init_shaders() : program = %d, vertex = %d, fragment = %d\n\
|
printf("[debug] graph_init_shaders() : program = %d, vertex = %d, fragment = %d\n\
|
||||||
exec > ** (myprogram:-----): WARNING ** : --:--:--:---: Linking failure: (address)\n",
|
exec > ** (myprogram:-----): WARNING ** : --:--:--:---: Linking failure: (address)\n",
|
||||||
program, vertex, fragment);
|
program, vertex, fragment);
|
||||||
|
|
||||||
|
@ -134,7 +134,7 @@ bool graphics_init_shaders(const int stack_id)
|
||||||
glAttachShader(program, vertex);
|
glAttachShader(program, vertex);
|
||||||
glAttachShader(program, fragment);
|
glAttachShader(program, fragment);
|
||||||
|
|
||||||
printf("Failed to link the graphic stack to widgets ! <> see init.c graphics_init_shaders()\n");
|
printf("Failed to link the graphic stack to widgets ! <> see init.c graph_init_shaders()\n");
|
||||||
printf("the error in not : vertex shader lacks `main' but : failed to link... (comment line 140)\n");
|
printf("the error in not : vertex shader lacks `main' but : failed to link... (comment line 140)\n");
|
||||||
// https://registry.khronos.org/OpenGL-Refpages/gl4/html/glLinkProgram.xhtml
|
// https://registry.khronos.org/OpenGL-Refpages/gl4/html/glLinkProgram.xhtml
|
||||||
// glLinkProgram(program); // Linking failure: (address)
|
// glLinkProgram(program); // Linking failure: (address)
|
||||||
|
@ -179,10 +179,10 @@ bool graphics_init_shaders(const int stack_id)
|
||||||
glDeleteShader(vertex);
|
glDeleteShader(vertex);
|
||||||
glDeleteShader(fragment);
|
glDeleteShader(fragment);
|
||||||
|
|
||||||
stack->program = program;
|
graph_stack->program = program;
|
||||||
stack->m = m;
|
graph_stack->m = m;
|
||||||
stack->v = v;
|
graph_stack->v = v;
|
||||||
stack->p = p;
|
graph_stack->p = p;
|
||||||
|
|
||||||
g_free(vertex_shader);
|
g_free(vertex_shader);
|
||||||
g_free(fragment_shader);
|
g_free(fragment_shader);
|
|
@ -1,162 +0,0 @@
|
||||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
||||||
* *
|
|
||||||
* Gem-graph client *
|
|
||||||
* *
|
|
||||||
* Drawing empty space *
|
|
||||||
* *
|
|
||||||
* Copyright © 2021 Libre en Communs <contact@a-lec.org> *
|
|
||||||
* Copyright © 2023 Adrien Bourmault <neox@a-lec.org> *
|
|
||||||
* Copyright © 2024 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 publishedby 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 "../../include/graphics.h"
|
|
||||||
|
|
||||||
int draw_space_ridges_vertex (const int stack_id,
|
|
||||||
long offset_vertex,
|
|
||||||
long x,
|
|
||||||
long y,
|
|
||||||
long z)
|
|
||||||
{
|
|
||||||
GLfloat max = fmax(x, y); max = fmax(max, z);
|
|
||||||
|
|
||||||
graphics_draw_vertex (stack_id, offset_vertex - x / max, offset_vertex - y / max, - z / max);
|
|
||||||
|
|
||||||
graphics_draw_vertex (stack_id, offset_vertex + x / max, offset_vertex - y / max, - z / max);
|
|
||||||
graphics_draw_vertex (stack_id, offset_vertex - x / max, offset_vertex + y / max, - z / max);
|
|
||||||
graphics_draw_vertex (stack_id, offset_vertex - x / max, offset_vertex - y / max, + z / max);
|
|
||||||
|
|
||||||
graphics_draw_vertex (stack_id, offset_vertex + x / max, offset_vertex + y / max, - z / max);
|
|
||||||
graphics_draw_vertex (stack_id, offset_vertex + x / max, offset_vertex - y / max, + z / max);
|
|
||||||
graphics_draw_vertex (stack_id, offset_vertex - x / max, offset_vertex + y / max, + z / max);
|
|
||||||
|
|
||||||
graphics_draw_vertex (stack_id, offset_vertex + x / max, + y / max, + z / max);
|
|
||||||
|
|
||||||
graphics_draw_color (stack_id, 0.8f, 0.6f, 0.5f);
|
|
||||||
graphics_draw_color (stack_id, 0.8f, 0.6f, 0.5f);
|
|
||||||
graphics_draw_color (stack_id, 0.8f, 0.6f, 0.5f);
|
|
||||||
graphics_draw_color (stack_id, 0.8f, 0.6f, 0.5f);
|
|
||||||
graphics_draw_color (stack_id, 0.8f, 0.6f, 0.5f);
|
|
||||||
graphics_draw_color (stack_id, 0.8f, 0.6f, 0.5f);
|
|
||||||
graphics_draw_color (stack_id, 0.8f, 0.6f, 0.5f);
|
|
||||||
graphics_draw_color (stack_id, 0.8f, 0.6f, 0.5f);
|
|
||||||
|
|
||||||
return 8;
|
|
||||||
}
|
|
||||||
|
|
||||||
int draw_space_ridges_lines (const int stack_id)
|
|
||||||
{
|
|
||||||
graphics_draw_line (stack_id, 0, 1); graphics_draw_line (stack_id, 7, 4);
|
|
||||||
graphics_draw_line (stack_id, 0, 2); graphics_draw_line (stack_id, 7, 5);
|
|
||||||
graphics_draw_line (stack_id, 0, 3); graphics_draw_line (stack_id, 7, 6);
|
|
||||||
|
|
||||||
graphics_draw_line (stack_id, 1, 4); graphics_draw_line (stack_id, 2, 4);
|
|
||||||
graphics_draw_line (stack_id, 1, 5); graphics_draw_line (stack_id, 3, 5);
|
|
||||||
graphics_draw_line (stack_id, 2, 6); graphics_draw_line (stack_id, 3, 6);
|
|
||||||
|
|
||||||
return 12;
|
|
||||||
}
|
|
||||||
|
|
||||||
long draw_grids_on_space_faces_vertex (const int stack_id,
|
|
||||||
long x,
|
|
||||||
long y,
|
|
||||||
long z)
|
|
||||||
{
|
|
||||||
float i, max = fmax(x, y); max = fmax(max, z);
|
|
||||||
|
|
||||||
for (i = 1; i < x; i++) {
|
|
||||||
|
|
||||||
graphics_draw_vertex (stack_id, (2 * i / x - 1) * x / max, - y / max, - z / max);
|
|
||||||
graphics_draw_vertex (stack_id, (2 * i / x - 1) * x / max, - y / max, z / max);
|
|
||||||
graphics_draw_vertex (stack_id, (2 * i / x - 1) * x / max, y / max, z / max);
|
|
||||||
graphics_draw_vertex (stack_id, (2 * i / x - 1) * x / max, y / max, - z / max);
|
|
||||||
|
|
||||||
graphics_draw_color (stack_id, 0.55f, 0.55f, 0.55f);
|
|
||||||
graphics_draw_color (stack_id, 0.55f, 0.55f, 0.55f);
|
|
||||||
graphics_draw_color (stack_id, 0.55f, 0.55f, 0.55f);
|
|
||||||
graphics_draw_color (stack_id, 0.55f, 0.55f, 0.55f);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* offset_vertex += (x - 1) * 4; */ /* offset_colors += (x - 1) * 4; */
|
|
||||||
|
|
||||||
for (i = 1; i < y; i++) {
|
|
||||||
|
|
||||||
graphics_draw_vertex (stack_id, - x / max, (2 * i / y - 1) * y / max, - z / max);
|
|
||||||
graphics_draw_vertex (stack_id, - x / max, (2 * i / y - 1) * y / max, z / max);
|
|
||||||
graphics_draw_vertex (stack_id, x / max, (2 * i / y - 1) * y / max, z / max);
|
|
||||||
graphics_draw_vertex (stack_id, x / max, (2 * i / y - 1) * y / max, - z / max);
|
|
||||||
|
|
||||||
graphics_draw_color (stack_id, 0.55f, 0.55f, 0.55f);
|
|
||||||
graphics_draw_color (stack_id, 0.55f, 0.55f, 0.55f);
|
|
||||||
graphics_draw_color (stack_id, 0.55f, 0.55f, 0.55f);
|
|
||||||
graphics_draw_color (stack_id, 0.55f, 0.55f, 0.55f);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* offset_vertex += (y - 1) * 4; */ /* offset_colors += (y - 1) * 4; */
|
|
||||||
|
|
||||||
for (i = 1; i < z; i++) {
|
|
||||||
|
|
||||||
graphics_draw_vertex (stack_id, - x / max, - y / max, (2 * i / z - 1) * z / max);
|
|
||||||
graphics_draw_vertex (stack_id, - x / max, y / max, (2 * i / z - 1) * z / max);
|
|
||||||
graphics_draw_vertex (stack_id, x / max, y / max, (2 * i / z - 1) * z / max);
|
|
||||||
graphics_draw_vertex (stack_id, x / max, - y / max, (2 * i / z - 1) * z / max);
|
|
||||||
|
|
||||||
graphics_draw_color (stack_id, 0.55f, 0.55f, 0.55f);
|
|
||||||
graphics_draw_color (stack_id, 0.55f, 0.55f, 0.55f);
|
|
||||||
graphics_draw_color (stack_id, 0.55f, 0.55f, 0.55f);
|
|
||||||
graphics_draw_color (stack_id, 0.55f, 0.55f, 0.55f);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (x + y + z - 3) * 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
long draw_grids_on_space_faces_lines (const int stack_id,
|
|
||||||
long offset_vertex,
|
|
||||||
long x,
|
|
||||||
long y,
|
|
||||||
long z)
|
|
||||||
{
|
|
||||||
offset_vertex = offset_vertex / 3;
|
|
||||||
|
|
||||||
for (int i = 0; i < x - 1; i ++) {
|
|
||||||
|
|
||||||
graphics_draw_line (stack_id, offset_vertex + i * 4 + 1, offset_vertex + i * 4 + 2);
|
|
||||||
graphics_draw_line (stack_id, offset_vertex + i * 4 + 2, offset_vertex + i * 4 + 3);
|
|
||||||
}
|
|
||||||
|
|
||||||
offset_vertex += (x - 1) * 4;
|
|
||||||
|
|
||||||
for (int i = 0; i < y - 1; i ++) {
|
|
||||||
|
|
||||||
graphics_draw_line (stack_id, offset_vertex + i * 4 + 2, offset_vertex + i * 4 + 3);
|
|
||||||
graphics_draw_line (stack_id, offset_vertex + i * 4 + 3, offset_vertex + i * 4 + 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
offset_vertex += (y - 1) * 4;
|
|
||||||
|
|
||||||
for (int i = 0; i < z - 1; i ++) {
|
|
||||||
|
|
||||||
graphics_draw_line (stack_id, offset_vertex + i * 4 + 0, offset_vertex + i * 4 + 1);
|
|
||||||
graphics_draw_line (stack_id, offset_vertex + i * 4 + 3, offset_vertex + i * 4 + 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (x + y + z - 3) * 4;
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue