src/shader.c

changeset 16
c5dde81b6fb2
parent 15
362b7659dc76
child 40
6c438be1a1fd
--- a/src/shader.c	Wed Nov 08 23:17:07 2023 +0100
+++ b/src/shader.c	Wed Nov 15 22:51:40 2023 +0100
@@ -30,8 +30,9 @@
 #include "ascension/error.h"
 
 #include <GL/glew.h>
+#include <string.h>
 
-AscShaderProgram ASC_SHADER_FONT;
+AscShaderFont ASC_SHADER_FONT;
 
 
 AscShader asc_shader_compile(unsigned int type,
@@ -93,7 +94,12 @@
     glDetachShader(id, fragment.id);
     if (success) {
         asc_dprintf("Shader Program %u linked (vtf: %u, frag: %u)", id, vertex.id, fragment.id);
-        return (AscShaderProgram) {id};
+        AscShaderProgram prog;
+        prog.id = id;
+        prog.model = glGetUniformLocation(id, "model");
+        prog.view = glGetUniformLocation(id, "view");
+        prog.projection = glGetUniformLocation(id, "projection");
+        return prog;
     } else {
         char *log = malloc(1024);
         glGetProgramInfoLog(id, 1024, NULL, log);
@@ -131,9 +137,10 @@
 }
 
 void asc_shader_initialize_predefined(void) {
-    ASC_SHADER_FONT = asc_shader_compile_link_discard("shader/font_vtx.glsl", "shader/font_frag.glsl");
+    ASC_SHADER_FONT.base = asc_shader_compile_link_discard("shader/font_vtx.glsl", "shader/font_frag.glsl");
+    ASC_SHADER_FONT.surface = glGetUniformLocation(ASC_SHADER_FONT.base.id, "surface");
 }
 
 void asc_shader_destroy_predefined(void) {
-    asc_shader_program_destroy(ASC_SHADER_FONT);
+    asc_shader_program_destroy(ASC_SHADER_FONT.base);
 }
\ No newline at end of file

mercurial