From bd1c1a2817b103b623754a73dc0c37020fa16e24 Mon Sep 17 00:00:00 2001 From: Jean Sirmai Date: Thu, 6 Jun 2024 09:30:23 +0200 Subject: [PATCH] WIP: cleaning, simplifying, organizing #include graph_area.h (176) static inline GLuint create_shader() --- (notes) | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++ graph_area.h | 17 +++++++------ 2 files changed, 76 insertions(+), 9 deletions(-) diff --git a/(notes) b/(notes) index 1b6c86f..88aa212 100644 --- a/(notes) +++ b/(notes) @@ -1,3 +1,71 @@ +jean@Project:~/01/Gtk4/Getting_Started_with_GTK [env] $ grep -r "//////////////////////////" + +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, +graph_area.c:////////////////////////// &error_buffer) == false) { +graph_area.c:////////////////////////// return false; +graph_area.c:////////////////////////// } +graph_area.c:////////////////////////// graphics_draw(stack_index[i].stack_id); +graph_area.c:////////////////////////// graphic_stack[stack_index[i].stack_id].rotation_angles[axis] = value; +graph_area.c:////////////////////////// graphics_shutdown(stack_index[i].stack_id, NULL); +graph_area.c:////////////////////////// g_signal_connect(adj, "value-changed", +graph_area.c:////////////////////////// G_CALLBACK(on_axis_value_change), +graph_area.c:////////////////////////// (gpointer) label); +graph_area.c:////////////////////////// g_signal_connect(GTK_GL_AREA(gl_area), +graph_area.c:////////////////////////// "render", +graph_area.c:////////////////////////// G_CALLBACK(on_glarea_render), NULL); +graph_area.c:////////////////////////// g_signal_connect(gl_area, +graph_area.c:////////////////////////// "realize", +graph_area.c:////////////////////////// G_CALLBACK(on_glarea_realize), NULL); +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); +graph_stack.c:////////////////////////// if (!graphics_init_shaders(cur_id)) return -1; +graph_stack.c:////////////////////////// graphics_init_buffers(cur_id); +graph_stack.c:////////////////////////// glDebugMessageCallback(graphics_debug_callback, NULL); +graph_stack.c:////////////////////////// dimension = model_get_dim(); +graph_stack.c:////////////////////////// space_Z = model_get_dim_value("z"); +graph_stack.c:////////////////////////// space_Y = model_get_dim_value("y"); +graph_stack.c:////////////////////////// space_X = model_get_dim_value("x"); +graph_stack.c:////////////////////////// multiplicity = model_get_multiplicity(); +graph_stack.c:////////////////////////// g_print("[GRAPH DEBUG] site_multiplicity = %ld\n", multiplicity); +graph_stack.c:////////////////////////// draw_space_ridges_vertex (stack_id, stack->buffer_vertex_size, space_X, space_Y, space_Z); +graph_stack.c:////////////////////////// draw_space_ridges_lines (stack_id); +graph_stack.c:////////////////////////// draw_grids_on_space_faces_vertex (stack_id, space_X, space_Y, space_Z); +graph_stack.c:////////////////////////// draw_grids_on_space_faces_lines (stack_id, stack->buffer_lines_size, space_X, space_Y, space_Z); +graph_stack.c:////////////////////////// assert(model_get_next_state(&state_id)); +graph_stack.c:////////////////////////// announced_arrows_nb = model_get_state_arrows_count(state_id); +graph_stack.c:////////////////////////// g_print("[GRAPH DEBUG] announced_arrows_nb is = %ld\n", announced_arrows_nb); +graph_stack.c:////////////////////////// while (model_get_next_arrow(&arrow, &state_id, dimension)) { +graph_stack.c:////////////////////////// g_print("[GRAPH DEBUG] cur arrow has x = %d\n", arrow.x); +graph_stack.c:////////////////////////// stack->arrows_nb = +graph_stack.c:////////////////////////// set_arrow (stack_id, stack->arrows_nb, space_X, space_Y, space_Z, +graph_stack.c:////////////////////////// arrow.load, // load +graph_stack.c:////////////////////////// arrow.site, // site +graph_stack.c:////////////////////////// arrow.x, // x +graph_stack.c:////////////////////////// arrow.y, // y +graph_stack.c:////////////////////////// arrow.z); // 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); -------------------------------------------------------------------------------- https://docs.gtk.org/gtk4/visual_index.html widgets gallery https://forge.a-lec.org/gem-graph/gem-graph-client/src/branch/devel/Makefile diff --git a/graph_area.h b/graph_area.h index 5ae983e..2181922 100644 --- a/graph_area.h +++ b/graph_area.h @@ -173,26 +173,25 @@ void graphics_draw_plan (const int stack_id, GLuint a, GLuint b, GLuint c); * * @return shader id */ -/* static inline GLuint create_shader(const int stack_id, int type, const char *src) { GLuint shader; int status; -////////////////////////// shader = glCreateShader(type); -////////////////////////// glShaderSource(shader, 1, &src, NULL); -////////////////////////// glCompileShader(shader); + shader = glCreateShader(type); + glShaderSource(shader, 1, &src, NULL); + glCompileShader(shader); -////////////////////////// glGetShaderiv(shader, GL_COMPILE_STATUS, &status); + glGetShaderiv(shader, GL_COMPILE_STATUS, &status); if(status == GL_FALSE) { int log_len; char *buffer; -////////////////////////// glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &log_len); + glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &log_len); buffer = g_malloc(log_len + 1); assert (buffer); -////////////////////////// glGetShaderInfoLog(shader, log_len, NULL, buffer); + glGetShaderInfoLog(shader, log_len, NULL, buffer); g_warning("Compile failure in %s shader:\n%s", type == GL_VERTEX_SHADER ? "vertex" : "fragment", @@ -200,14 +199,14 @@ static inline GLuint create_shader(const int stack_id, int type, const char *src g_free(buffer); -////////////////////////// glDeleteShader(shader); + glDeleteShader(shader); return 0; } return shader; } -*/ + static inline void print_stack(int stack_id) { static int n = 0;