src/text.c

changeset 222
2cb9a71df7a6
parent 221
14eddd43b3f7
child 223
4f32c7755138
--- a/src/text.c	Wed Jul 23 00:27:46 2025 +0200
+++ b/src/text.c	Thu Jul 24 20:58:00 2025 +0200
@@ -39,30 +39,16 @@
     asc_uniform_loc tex;
 } AscTextShader;
 
-AscShaderProgram *asc_text_shader_create(cx_attr_unused int unused) {
-    AscShaderCodes codes;
-    if (asc_shader_load_code_files((AscShaderCodeInfo){
+static void asc_text_shader_init(AscShaderProgram *p, cx_attr_unused int flags) {
+    asc_shader_init_uniform_loc_nice(p, AscTextShader, tex);
+}
+
+static AscShaderProgram *asc_text_shader_create(int flags) {
+    return asc_shader_create((AscShaderCodeInfo){
         .files.vtx = "sprite_vtx.glsl",
         .files.frag = "sprite_frag.glsl",
         .defines.frag = "#define USE_RECT",
-    }, &codes)) {
-        asc_error("Loading text shader failed.");
-        return NULL;
-    }
-    AscShaderProgram *shader = asc_shader_create(codes, sizeof(AscTextShader));
-    if (asc_shader_invalid(shader)) {
-        asc_shader_free_codes(codes);
-        return shader;
-    }
-    asc_ptr_cast(AscTextShader, text_shader, shader);
-    text_shader->tex = asc_shader_get_uniform_loc(shader, "tex");
-    asc_shader_free_codes(codes);
-
-    if (asc_error_catch_gl("Creating text shader")) {
-        // TODO: error handling
-    }
-
-    return shader;
+    }, sizeof(AscTextShader), asc_text_shader_init, flags);
 }
 
 static void asc_text_update(AscSceneNode *node) {

mercurial