src/shader.c

changeset 86
943bf9d7c6d6
parent 83
f7ce0db6f72b
child 88
6234b7ea48f3
--- a/src/shader.c	Sat Apr 19 13:00:32 2025 +0200
+++ b/src/shader.c	Sat Apr 19 15:06:24 2025 +0200
@@ -25,8 +25,10 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include "ascension/context.h"
 #include "ascension/shader.h"
 #include "ascension/error.h"
+#include "ascension/filesystem.h"
 
 #include <GL/glew.h>
 #include <string.h>
@@ -121,8 +123,8 @@
 int asc_shader_sprite_init(AscShaderSprite *sprite) {
     AscShaderCodes codes;
     if (asc_shader_load_code_files((AscShaderCodeFiles){
-        .vtx = "./shader/sprite_vtx.glsl",
-        .frag = "./shader/sprite_frag.glsl"
+        .vtx = "sprite_vtx.glsl",
+        .frag = "sprite_frag.glsl"
     }, &codes)) {
         asc_error("Loading sprite shader failed.");
         return 1;
@@ -159,7 +161,9 @@
         *code = NULL;
         return 0;
     }
-    FILE *f = fopen(filename, "r");
+    cxmutstr fpath = asc_filesystem_combine_paths(cx_strcast(asc_context.shader_path), cx_str(filename));
+    FILE *f = fopen(fpath.ptr, "r");
+    cx_strfree(&fpath);
     if (f == NULL) return -1;
     CxBuffer buffer;
     cxBufferInit(&buffer, NULL, 1024, NULL, CX_BUFFER_AUTO_EXTEND);

mercurial