1.1 --- a/src/shader.c Wed Nov 08 23:17:07 2023 +0100 1.2 +++ b/src/shader.c Wed Nov 15 22:51:40 2023 +0100 1.3 @@ -30,8 +30,9 @@ 1.4 #include "ascension/error.h" 1.5 1.6 #include <GL/glew.h> 1.7 +#include <string.h> 1.8 1.9 -AscShaderProgram ASC_SHADER_FONT; 1.10 +AscShaderFont ASC_SHADER_FONT; 1.11 1.12 1.13 AscShader asc_shader_compile(unsigned int type, 1.14 @@ -93,7 +94,12 @@ 1.15 glDetachShader(id, fragment.id); 1.16 if (success) { 1.17 asc_dprintf("Shader Program %u linked (vtf: %u, frag: %u)", id, vertex.id, fragment.id); 1.18 - return (AscShaderProgram) {id}; 1.19 + AscShaderProgram prog; 1.20 + prog.id = id; 1.21 + prog.model = glGetUniformLocation(id, "model"); 1.22 + prog.view = glGetUniformLocation(id, "view"); 1.23 + prog.projection = glGetUniformLocation(id, "projection"); 1.24 + return prog; 1.25 } else { 1.26 char *log = malloc(1024); 1.27 glGetProgramInfoLog(id, 1024, NULL, log); 1.28 @@ -131,9 +137,10 @@ 1.29 } 1.30 1.31 void asc_shader_initialize_predefined(void) { 1.32 - ASC_SHADER_FONT = asc_shader_compile_link_discard("shader/font_vtx.glsl", "shader/font_frag.glsl"); 1.33 + ASC_SHADER_FONT.base = asc_shader_compile_link_discard("shader/font_vtx.glsl", "shader/font_frag.glsl"); 1.34 + ASC_SHADER_FONT.surface = glGetUniformLocation(ASC_SHADER_FONT.base.id, "surface"); 1.35 } 1.36 1.37 void asc_shader_destroy_predefined(void) { 1.38 - asc_shader_program_destroy(ASC_SHADER_FONT); 1.39 + asc_shader_program_destroy(ASC_SHADER_FONT.base); 1.40 } 1.41 \ No newline at end of file