src/sprite.c

changeset 158
f650994ec543
parent 151
42960d0c879b
--- a/src/sprite.c	Tue Jun 17 19:00:20 2025 +0200
+++ b/src/sprite.c	Tue Jun 17 20:11:53 2025 +0200
@@ -42,7 +42,7 @@
     GLint tex;
 } AscSpriteShader;
 
-static void *asc_sprite_shader_create(bool rect) {
+static AscShaderProgram *asc_sprite_shader_create(int rect) {
     AscShaderCodes codes;
     if (asc_shader_load_code_files((AscShaderCodeInfo){
         .files.vtx = "sprite_vtx.glsl",
@@ -62,23 +62,7 @@
 
     asc_error_catch_all_gl();
 
-    return shader;
-}
-
-static AscShaderProgram *asc_sprite_shader_rect_create() {
-    return asc_sprite_shader_create(true);
-}
-
-static AscShaderProgram *asc_sprite_shader_uv_create() {
-    return asc_sprite_shader_create(false);
-}
-
-static const AscSpriteShader *asc_sprite_shader_rect(void) {
-    return asc_shader_lookup_or_create(ASC_SHADER_SPRITE_RECT, asc_sprite_shader_rect_create);
-}
-
-static const AscSpriteShader *asc_sprite_shader_uv(void) {
-    return asc_shader_lookup_or_create(ASC_SHADER_SPRITE_UV, asc_sprite_shader_uv_create);
+    return (AscShaderProgram*) shader;
 }
 
 static void asc_sprite_destroy(AscSceneNode *node) {
@@ -113,8 +97,8 @@
     // TODO: scene should know which shader we are going to activate s.t. it can pre-sort nodes
     const AscSpriteShader *shader =
             sprite->texture->target == GL_TEXTURE_RECTANGLE
-                ? asc_sprite_shader_rect()
-                : asc_sprite_shader_uv();
+                ? asc_shader_lookup_or_create(ASC_SHADER_SPRITE_RECT, asc_sprite_shader_create, 1)
+                : asc_shader_lookup_or_create(ASC_SHADER_SPRITE_UV, asc_sprite_shader_create, 0);
     asc_shader_use(&shader->program, camera);
 
     // Upload model matrix

mercurial