From 68c5c445b402c67fe6ee3f6b58b4b21af7e871eb Mon Sep 17 00:00:00 2001 From: Jean Sirmai Date: Thu, 6 Jun 2024 09:41:08 +0200 Subject: [PATCH] WIP: cleaning, simplifying, organizing #include graph_area.h g_signal_connect (...) --- (notes) | 10 ++-------- graph_area.c | 34 ++++++++++++---------------------- 2 files changed, 14 insertions(+), 30 deletions(-) diff --git a/(notes) b/(notes) index 88aa212..ed15988 100644 --- a/(notes) +++ b/(notes) @@ -4,14 +4,6 @@ contain.c: (136) gtk_box_append (middle_box, GTK_WIDGET (get_GLArea())); graph_area.h: (177) static inline GLuint create_shader(const int stack_id, int type, const char *src) {...} -graph_area.h:////////////////////////// shader = glCreateShader(type); -graph_area.h:////////////////////////// glShaderSource(shader, 1, &src, NULL); -graph_area.h:////////////////////////// glCompileShader(shader); -graph_area.h:////////////////////////// glGetShaderiv(shader, GL_COMPILE_STATUS, &status); -graph_area.h:////////////////////////// glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &log_len); -graph_area.h:////////////////////////// glGetShaderInfoLog(shader, log_len, NULL, buffer); -graph_area.h:////////////////////////// glDeleteShader(shader); - graph_area.c:////////////////////////// stack_index[i].stack_id = graphics_init(&error_buffer); graph_area.c:////////////////////////// if (graphics_shutdown(stack_index[i].stack_id, @@ -33,6 +25,7 @@ graph_area.c:////////////////////////// G_CALLBACK(on_glarea graph_area.c:////////////////////////// g_signal_connect(gl_area, graph_area.c:////////////////////////// "unrealize", graph_area.c:////////////////////////// G_CALLBACK(on_glarea_unrealize), NULL); + graph_stack.c:////////////////////////// glEnable(GL_DEBUG_OUTPUT); graph_stack.c:////////////////////////// glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS); graph_stack.c:////////////////////////// glEnable(GL_MULTISAMPLE); @@ -64,6 +57,7 @@ graph_stack.c:////////////////////////// arrow.z); graph_stack.c:////////////////////////// } graph_stack.c:////////////////////////// if (stack->arrows_nb != announced_arrows_nb) graph_stack.c:////////////////////////// g_printerr("ARGH : all the arrows have not been parsed !\n"); + init.c.todo:////////////////////////// vertex = create_shader(stack_id, GL_VERTEX_SHADER, vertex_shader); init.c.todo:////////////////////////// fragment = create_shader(stack_id, GL_FRAGMENT_SHADER, fragment_shader); -------------------------------------------------------------------------------- diff --git a/graph_area.c b/graph_area.c index bd894c3..fb4cdc6 100644 --- a/graph_area.c +++ b/graph_area.c @@ -93,7 +93,7 @@ bool ui_init_graphic_stack(void *container_widget, GError *error_buffer) //g_printerr("[debug] ui_init_graphic_stack() : target would be %p\n", //stack_index[i].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 = graphics_init(&error_buffer); //g_printerr("[debug] ui_init_graphic_stack() : stack_id is %d\n", //stack_index[i].stack_id); if (stack_index[i].stack_id >= 0) @@ -117,10 +117,10 @@ bool ui_shutdown_graphic_stack(void *container_widget, GError *error_buffer) // look for stack_index entry for (int i = 0; i < stack_index_size; i++) { if (stack_index[i].container_widget == (void *)container_widget) { -////////////////////////// if (graphics_shutdown(stack_index[i].stack_id, -////////////////////////// &error_buffer) == false) { -////////////////////////// return false; -////////////////////////// } + if (graphics_shutdown(stack_index[i].stack_id, + &error_buffer) == false) { + return false; + } stack_index[i].stack_id = 0; return true; } @@ -150,7 +150,7 @@ bool ui_render_stack(GtkWidget *container_widget) // look for stack_index entry for (int i = 0; i < stack_index_size; i++) { if (stack_index[i].container_widget == (void *)container_widget) { -////////////////////////// graphics_draw(stack_index[i].stack_id); +////////////////////////// graphics_draw (stack_index[i].stack_id); return true; } } @@ -169,7 +169,7 @@ bool ui_update_axis_stack(GtkWidget *container_widget, int axis, int value) // look for stack_index entry for (int i = 0; i < stack_index_size; i++) { if (stack_index[i].container_widget == (void *)container_widget) { -////////////////////////// graphic_stack[stack_index[i].stack_id].rotation_angles[axis] = value; + graphic_stack[stack_index[i].stack_id].rotation_angles[axis] = value; gtk_widget_queue_draw((GtkWidget*)(stack_index[i].gl_area)); return true; } @@ -188,7 +188,7 @@ void ui_shutdown_all_graphic_stacks(void) { // look for stack_index entry for (int i = 0; i < stack_index_size; i++) { -////////////////////////// graphics_shutdown(stack_index[i].stack_id, NULL); + graphics_shutdown(stack_index[i].stack_id, NULL); } return; } @@ -230,9 +230,7 @@ GtkWidget *create_axis_slider(int axis) gtk_widget_set_visible (label, TRUE); adj = gtk_adjustment_new(0.0, 0.0, 360.0, 1.0, 12.0, 0.0); -////////////////////////// g_signal_connect(adj, "value-changed", -////////////////////////// G_CALLBACK(on_axis_value_change), -////////////////////////// (gpointer) label); +////////////////////////// g_signal_connect (adj, "value-changed", G_CALLBACK(on_axis_value_change), (gpointer) label); slider = gtk_scale_new(GTK_ORIENTATION_HORIZONTAL, adj); gtk_box_append(GTK_BOX(box), slider); gtk_widget_set_hexpand(slider, TRUE); @@ -288,17 +286,9 @@ bool ui_setup_glarea(int target_mode, GtkWidget *target_widget) //gtk_widget_set_valign(gl_area, GTK_ALIGN_CENTER); // The main "draw" call for GtkGLArea -////////////////////////// g_signal_connect(GTK_GL_AREA(gl_area), -////////////////////////// "render", -////////////////////////// G_CALLBACK(on_glarea_render), NULL); - -////////////////////////// g_signal_connect(gl_area, -////////////////////////// "realize", -////////////////////////// G_CALLBACK(on_glarea_realize), NULL); - -////////////////////////// g_signal_connect(gl_area, -////////////////////////// "unrealize", -////////////////////////// G_CALLBACK(on_glarea_unrealize), NULL); +////////////////////////// g_signal_connect(GTK_GL_AREA(gl_area), "render", G_CALLBACK(on_glarea_render), NULL); +////////////////////////// g_signal_connect(gl_area, "realize", G_CALLBACK(on_glarea_realize), NULL); +////////////////////////// g_signal_connect(gl_area, "unrealize", G_CALLBACK(on_glarea_unrealize), NULL); stack_index[stack_index_size-1].container_widget = (void*)target_widget;