WIP: cleaning, simplifying, organizing #include graph_stack : shaders readed in init.c

This commit is contained in:
Jean Sirmai 2024-06-06 10:22:15 +02:00
parent 21d76d69f4
commit b9cb86c17c
Signed by: jean
GPG Key ID: FB3115C340E057E3
4 changed files with 42 additions and 37 deletions

38
(notes)
View File

@ -13,38 +13,14 @@ graph_area.c: g_signal_connect(gl_area, "unrealize", G_CALLBACK(on_gla
init.c.todo: (98) vertex = create_shader(stack_id, GL_VERTEX_SHADER, vertex_shader); init.c.todo: (98) vertex = create_shader(stack_id, GL_VERTEX_SHADER, vertex_shader);
init.c.todo: (110) fragment = create_shader(stack_id, GL_FRAGMENT_SHADER, fragment_shader); init.c.todo: (110) fragment = create_shader(stack_id, GL_FRAGMENT_SHADER, fragment_shader);
graph_stack.c: (149) if (!graphics_init_shaders(cur_id)) return -1;
graph_stack.c: (153) graphics_init_buffers(cur_id);
graph_stack.c: (288) 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: (316) 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.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");
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
https://docs.gtk.org/gtk4/visual_index.html widgets gallery https://docs.gtk.org/gtk4/visual_index.html widgets gallery
https://forge.a-lec.org/gem-graph/gem-graph-client/src/branch/devel/Makefile https://forge.a-lec.org/gem-graph/gem-graph-client/src/branch/devel/Makefile

View File

@ -95,7 +95,7 @@ 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 = create_shader(stack_id, GL_VERTEX_SHADER, vertex_shader);
if(vertex == 0) { if(vertex == 0) {
stack->program = 0; stack->program = 0;
@ -107,7 +107,7 @@ 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 = create_shader(stack_id, GL_FRAGMENT_SHADER, fragment_shader);
if(fragment == 0) { if(fragment == 0) {
glDeleteShader(vertex); glDeleteShader(vertex);

9
shader.frag Normal file
View File

@ -0,0 +1,9 @@
#version 330 core
in vec4 color;
out vec4 out_frag_color;
void main(void)
{
out_frag_color = color;
}

20
shader.vert Normal file
View File

@ -0,0 +1,20 @@
#version 330 core
uniform mat4 projection_matrix;
uniform mat4 model_matrix;
uniform mat4 view_matrix;
layout(location=0) in vec3 in_position;
layout(location=1) in vec3 in_color;
out vec4 color;
void main(void)
{
float zoom = 1.1f, chrominance = 1, luminance = 1;
gl_Position =
projection_matrix * view_matrix * model_matrix * vec4(in_position, zoom);
color = vec4 (chrominance * in_color.rgb, luminance);
}
// https://learnopengl.com/Getting-started/Shaders