src/context.c

changeset 86
943bf9d7c6d6
parent 81
84a546e282b7
child 88
6234b7ea48f3
--- a/src/context.c	Sat Apr 19 13:00:32 2025 +0200
+++ b/src/context.c	Sat Apr 19 15:06:24 2025 +0200
@@ -51,6 +51,11 @@
         return;
     memset(&asc_context, 0, sizeof(AscContext));
 
+    // initialize default paths
+    asc_context.font_path = cx_strdup(CX_STR("./fonts"));
+    asc_context.shader_path = cx_strdup(CX_STR("./shader"));
+    asc_context.texture_path = cx_strdup(CX_STR("./textures"));
+
     // initialize the font cache
     asc_font_cache_init();
 
@@ -102,6 +107,11 @@
     cxBufferDestroy(&asc_context.error_buffer);
     asc_context.flags = 0;
     asc_dprintf("Ascension context destroyed.");
+
+    // destroy the path information
+    cx_strfree(&asc_context.font_path);
+    cx_strfree(&asc_context.shader_path);
+    cx_strfree(&asc_context.texture_path);
 }
 
 void asc_context_quit(void) {
@@ -191,3 +201,15 @@
 
     return !asc_test_flag(asc_context.flags, ASC_FLAG_QUIT);
 }
+
+void asc_set_font_path(const char *path) {
+    cx_strcpy(&asc_context.font_path, cx_str(path));
+}
+
+void asc_set_shader_path(const char *path) {
+    cx_strcpy(&asc_context.shader_path, cx_str(path));
+}
+
+void asc_set_texture_path(const char *path) {
+    cx_strcpy(&asc_context.texture_path, cx_str(path));
+}

mercurial