WIP: déminage en cours... (jusqu'ici, ça va) Mais que fait : 'graphics_init_shaders()' ?
This commit is contained in:
parent
61fe121d2d
commit
d2ad9649c7
|
@ -30,8 +30,8 @@
|
|||
#include "../../include/grid.h"
|
||||
#include "../../include/shaders_study.h"
|
||||
|
||||
#define VERTEX_SHADER_FILE "src/shaders/shader.vert"
|
||||
#define FRAG_SHADER_FILE "src/shaders/shader.frag"
|
||||
// #define VERTEX_SHADER_FILE "src/shaders/shader.vert"
|
||||
// #define FRAG_SHADER_FILE "src/shaders/shader.frag"
|
||||
|
||||
static GLfloat *buffer_vertex_origin = NULL;
|
||||
static GLfloat *buffer_colors_origin = NULL;
|
||||
|
@ -238,116 +238,14 @@ void graphics_init_buffers(const void *gl_area)
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Initializes the shaders of a gl_area and link them to a program
|
||||
*
|
||||
* @param gl_area, ptr to the gl_area widget
|
||||
*
|
||||
* @return true if initialized
|
||||
*/
|
||||
/* bool graphics_init_shaders(const void *gl_area) */
|
||||
/* { */
|
||||
/* char *vertex_shader; */
|
||||
/* char *fragment_shader; */
|
||||
/* struct gl_area_entry *entry; */
|
||||
/* int status; */
|
||||
/* GLuint vertex, fragment; */
|
||||
/* GLuint program = 0; */
|
||||
/* GLuint m = 0; */
|
||||
/* GLuint v = 0; */
|
||||
/* GLuint p = 0; */
|
||||
|
||||
/* entry = graphics_find_glarea_from_ptr(gl_area); */
|
||||
|
||||
/* if (entry == NULL) { */
|
||||
/* errno = EFAULT; */
|
||||
/* perror("gl_area_array entry not found"); */
|
||||
/* return false; */
|
||||
/* } */
|
||||
|
||||
/* // Load vertex shader file */
|
||||
/* vertex_shader = read_file(VERTEX_SHADER_FILE); */
|
||||
/* if (vertex_shader == NULL) */
|
||||
/* return false; */
|
||||
/* vertex = create_shader(GL_VERTEX_SHADER, vertex_shader); */
|
||||
/* 28-9-2023 Je déplace la fonction : "bool graphics_init_shaders(const void *gl_area)"
|
||||
* dans un nouveau fichier "shaders_study.c" pour alléger graphics.c */
|
||||
|
||||
/* // ! WARNING ! l'instruction suivante (ou un autre 'free') a pu provoquer un 'double free' (Abandon) */
|
||||
/* if(vertex == 0) { */
|
||||
/* entry->program = 0; */
|
||||
/* g_free(vertex_shader); */
|
||||
/* return false; */
|
||||
/* } */
|
||||
|
||||
/* // Load fragment shader file */
|
||||
/* fragment_shader = read_file(FRAG_SHADER_FILE); */
|
||||
/* if (fragment_shader == NULL) */
|
||||
/* return false; */
|
||||
/* fragment = create_shader(GL_FRAGMENT_SHADER, fragment_shader); */
|
||||
|
||||
/* if(fragment == 0) { */
|
||||
/* glDeleteShader(vertex); */
|
||||
/* entry->program = 0; */
|
||||
/* g_free(vertex_shader); */
|
||||
/* g_free(fragment_shader); */
|
||||
/* return false; */
|
||||
/* } */
|
||||
|
||||
/* // Link shaders to program */
|
||||
/* program = glCreateProgram(); */
|
||||
/* glAttachShader(program, vertex); */
|
||||
/* glAttachShader(program, fragment); */
|
||||
|
||||
/* glLinkProgram(program); */
|
||||
|
||||
/* glGetProgramiv(program, GL_LINK_STATUS, &status); */
|
||||
|
||||
/* if(status == GL_FALSE) { */
|
||||
/* int log_len; */
|
||||
/* char *buffer; */
|
||||
|
||||
/* glGetProgramiv(program, GL_INFO_LOG_LENGTH, &log_len); */
|
||||
|
||||
/* buffer = g_malloc(log_len + 1); */
|
||||
/* assert(buffer); */
|
||||
/* glGetProgramInfoLog(program, log_len, NULL, buffer); */
|
||||
|
||||
/* g_warning("Linking failure:\n%s", buffer); */
|
||||
|
||||
/* g_free(buffer); */
|
||||
|
||||
/* glDeleteProgram(program); */
|
||||
/* program = 0; */
|
||||
|
||||
/* glDeleteShader(vertex); */
|
||||
/* glDeleteShader(fragment); */
|
||||
|
||||
/* g_free(vertex_shader); */
|
||||
/* g_free(fragment_shader); */
|
||||
|
||||
/* return false; */
|
||||
/* } */
|
||||
|
||||
/* Get the location of the "mvp" uniform */
|
||||
/* m = glGetUniformLocation(program, "model_matrix"); */
|
||||
/* v = glGetUniformLocation(program, "view_matrix"); */
|
||||
/* p = glGetUniformLocation(program, "projection_matrix"); */
|
||||
|
||||
/* glDetachShader(program, vertex); */
|
||||
/* glDetachShader(program, fragment); */
|
||||
|
||||
/* glDeleteShader(vertex); */
|
||||
/* glDeleteShader(fragment); */
|
||||
|
||||
/* entry->program = program; */
|
||||
/* entry->m = m; */
|
||||
/* entry->v = v; */
|
||||
/* entry->p = p; */
|
||||
|
||||
/* g_free(vertex_shader); */
|
||||
/* g_free(fragment_shader); */
|
||||
|
||||
/* return true; */
|
||||
/* } */
|
||||
|
||||
/*
|
||||
* Draws the current buffer to a gl_area
|
||||
|
|
|
@ -31,6 +31,12 @@
|
|||
#define VERTEX_SHADER_FILE "src/shaders/shader.vert"
|
||||
#define FRAG_SHADER_FILE "src/shaders/shader.frag"
|
||||
|
||||
// Que fait l'instruction suivante (ligne 397 de graphics.c)
|
||||
// dans "bool graphics_init(const char *gl_area)" ?
|
||||
//
|
||||
// if (!graphics_init_shaders(gl_area)) return false;
|
||||
|
||||
|
||||
static volatile int buffer_vertex_size = 0;
|
||||
static volatile int buffer_lines_size = 0;
|
||||
static volatile int buffer_colors_size = 0;
|
||||
|
|
Loading…
Reference in New Issue