diff --git a/assets/config.cfg b/assets/config.cfg index c9dbf22..4cf5e9d 100644 --- a/assets/config.cfg +++ b/assets/config.cfg @@ -1,6 +1,6 @@ msaa_levels: 4 debug_draw_color : 1.000, 0.000, 0.000, 1.000 -render_width : 800 +render_width : 1024 fog_density : 0.0020 render_height : 600 fog_mode : 2 diff --git a/assets/keybindings.cfg b/assets/keybindings.cfg index 43afc5c..603c2e1 100644 --- a/assets/keybindings.cfg +++ b/assets/keybindings.cfg @@ -1,7 +1,14 @@ -# This is a comment, this should be ignored Move_Forward : Left Ctrl-E, W, Left Alt-Left Shift-Up Move_Backward : S, Down, S, Down Move_Left : A, Left Move_Right : D, Right +Move_Up : Q +Move_Down : E Sprint : Left Shift - +Turn_Left : J +Turn_Right : L +Turn_Up : I +Turn_Down : K +Editor_Toggle : F1 +Window_Fullscreen : F11 +Window_Maximize : F12 diff --git a/orgfile.org b/orgfile.org index 332f4de..afcfd47 100644 --- a/orgfile.org +++ b/orgfile.org @@ -207,9 +207,11 @@ x Keybindings in config ** TODO Do input maps really need to be queried by their string names? ** TODO Reloading all the things! (textures/shaders/models/settings/entities etc) ** TODO Separate Debug/Editor camera from the active camera in the scene that can be switched to at any time -** TODO Add option to specify where to read/write files from instead of being hard-coded assets dir +** DONE Add option to specify where to read/write files from instead of being hard-coded assets dir +- State "DONE" from "TODO" [2017-05-24 Wed 17:12] ** TODO Add default keybindings ** TODO Write default config/keybindings etc to file if none are found in preferences dir +** TODO Fix input map bugs ** TODO Use hashmap for debugvar slots in editor ** TODO Use hashmap to store input maps ** DONE Live data views in editor diff --git a/src/config_vars.c b/src/config_vars.c index 2f209e4..00b7482 100644 --- a/src/config_vars.c +++ b/src/config_vars.c @@ -44,7 +44,7 @@ struct Hashmap* config_vars_get(void) int config_vars_load(const char* filename) { int success = 0; - FILE* config_file = io_file_open(filename, "r"); + FILE* config_file = io_file_open(DT_USER, filename, "r"); if(!config_file) { log_error("config:vars_load", "Could not open %s", filename); @@ -97,7 +97,7 @@ int config_vars_load(const char* filename) int config_vars_save(const char* filename) { int success = 0; - FILE* config_file = io_file_open(filename, "w"); + FILE* config_file = io_file_open(DT_USER, filename, "w"); if(!config_file) { log_error("config:vars_save", "Failed to open config file %s for writing"); diff --git a/src/editor.c b/src/editor.c index 99e2742..d9daf4a 100644 --- a/src/editor.c +++ b/src/editor.c @@ -219,7 +219,7 @@ void editor_update(float dt) nk_slider_float(context, 0.f, &render_settings->fog.density, 1.f, 0.005); if(nk_input_is_mouse_hovering_rect(&context->input, bounds)) { - static char float_str[7]; + static char float_str[10] = {'\0'}; snprintf(float_str, 6, "%.4f", render_settings->fog.density); float_str[6] = '\0'; nk_tooltip(context, float_str); diff --git a/src/file_io.c b/src/file_io.c index 0f8de36..5c4e707 100644 --- a/src/file_io.c +++ b/src/file_io.c @@ -5,21 +5,24 @@ #include "log.h" #include "string_utils.h" -static char* base_assets_path; +static char* install_directory = NULL; +static char* user_directory = NULL; -void io_file_init(const char* assets_path) +void io_file_init(const char* install_dir, const char* user_dir) { - base_assets_path = str_new("%s/assets/", assets_path); + install_directory = str_new("%s/assets/", install_dir); + user_directory = str_new("%s/", user_dir); } void io_file_cleanup(void) { - if(base_assets_path) free(base_assets_path); + if(install_directory) free(install_directory); + if(user_directory) free(user_directory); } -char* io_file_read(const char* path, const char* mode, long* file_size) +char* io_file_read(const int directory_type, const char* path, const char* mode, long* file_size) { - FILE* file = io_file_open(path, mode); + FILE* file = io_file_open(directory_type, path, mode); char* data = NULL; if(!file) return data; int rc = fseek(file, 0, SEEK_END); @@ -54,9 +57,11 @@ char* io_file_read(const char* path, const char* mode, long* file_size) return data; } -FILE* io_file_open(const char* path, const char* mode) +FILE* io_file_open(int directory_type, const char* path, const char* mode) { - char* relative_path = str_new(base_assets_path); + assert(directory_type >= 0 && directory_type <= DT_INSTALL); + + char* relative_path = str_new(directory_type == DT_INSTALL ? install_directory : user_directory); relative_path = str_concat(relative_path, path); FILE* file = fopen(relative_path, mode); if(!file) log_error("io:file", "Failed to open file '%s'", relative_path); diff --git a/src/file_io.h b/src/file_io.h index 30d2c4b..b18fef1 100644 --- a/src/file_io.h +++ b/src/file_io.h @@ -1,11 +1,17 @@ -#ifndef file_io_H -#define file_io_H +#ifndef FILE_IO_H +#define FILE_IO_H #include -void io_file_init(const char* assets_path); -char* io_file_read(const char* path, const char* mode, long* file_size); -FILE* io_file_open(const char* path, const char* mode); +enum Directory_Type +{ + DT_USER, /* User directory or preferences directory */ + DT_INSTALL /* Directory where the game's executable is, usually where the game is installed */ +}; + +void io_file_init(const char* install_dir, const char* user_dir); +char* io_file_read(const int directory_type, const char* path, const char* mode, long* file_size); +FILE* io_file_open(const int directory_type, const char* path, const char* mode); void io_file_cleanup(void); #endif diff --git a/src/game.c b/src/game.c index c9f10bd..ccc23b5 100644 --- a/src/game.c +++ b/src/game.c @@ -88,38 +88,7 @@ int game_init(struct Window* window) } void scene_setup(void) -{ - /* struct Key_Combination forward_keys[2] = {{KEY_W, KMD_NONE}, {KEY_UP, KMD_ALT | KMD_SHIFT}}; */ - /* struct Key_Combination backward_keys[2] = {{KEY_S, KMD_NONE}, {KEY_DOWN, KMD_NONE}}; */ - /* struct Key_Combination up_keys[2] = {KEY_Q}; */ - /* struct Key_Combination down_keys[2] = {KEY_E}; */ - /* struct Key_Combination left_keys[2] = {KEY_A, KEY_LEFT}; */ - /* struct Key_Combination right_keys[2] = {KEY_D, KEY_RIGHT}; */ - /* struct Key_Combination turn_right_keys[1] = {KEY_L}; */ - /* struct Key_Combination turn_left_keys[1] = {KEY_J}; */ - /* struct Key_Combination turn_up_keys[1] = {KEY_I}; */ - /* struct Key_Combination turn_down_keys[1] = {KEY_K}; */ - /* struct Key_Combination sprint_keys[2] = {KEY_LSHIFT, KEY_RSHIFT}; */ - /* struct Key_Combination recompute_keys[2] = {KEY_F5, KEY_H}; */ - /* struct Key_Combination ed_toggle_keys[1] = {KEY_F1}; */ - /* struct Key_Combination win_fullscr_keys[1] = {KEY_F11}; */ - /* struct Key_Combination win_max_keys[1] = {KEY_F12}; */ - /* input_map_create("Move_Forward", forward_keys, 2); */ - /* input_map_create("Move_Backward", backward_keys, 2); */ - /* input_map_create("Move_Up", up_keys, 1); */ - /* input_map_create("Move_Down", down_keys, 1); */ - /* input_map_create("Move_Left", left_keys, 2); */ - /* input_map_create("Move_Right", right_keys, 2); */ - /* input_map_create("Turn_Right", turn_right_keys, 1); */ - /* input_map_create("Turn_Left", turn_left_keys, 1); */ - /* input_map_create("Turn_Up", turn_up_keys, 1); */ - /* input_map_create("Turn_Down", turn_down_keys, 1); */ - /* input_map_create("Sprint", sprint_keys, 2); */ - /* input_map_create("Recompute", recompute_keys, 2); */ - /* input_map_create("Editor_Toggle", ed_toggle_keys, 1); */ - /* input_map_create("Window_Fullscreen", win_fullscr_keys, 1); */ - /* input_map_create("Window_Maximize", win_max_keys, 1); */ - +{ struct Entity* player = scene_add_new("player", "None"); game_state->player_node = player->node; vec3 viewer_pos = {10, 5, 100}; @@ -225,34 +194,6 @@ void scene_setup(void) /* struct Entity* sun = scene_add_new("Sun", NULL); */ /* struct Light* sun_light = entity_component_add(sun, C_LIGHT, LT_DIR); */ /* sun_light->intensity = 0.8f; */ - - /* struct Hashmap* cvars = config_vars_get(); */ - /* hashmap_int_set(cvars, "My_Int", 20); */ - /* hashmap_str_set(cvars, "My_String", "This is my string"); */ - /* hashmap_float_set(cvars, "Some_FLOAT", 42.222f); */ - /* hashmap_double_set(cvars, "Some_Double", 99.999); */ - /* hashmap_bool_set(cvars, "The_Truth", 0); */ - - /* char* key = NULL; */ - /* struct Variant* value = NULL; */ - /* char variant_str[256]; */ - /* HASHMAP_FOREACH(cvars, key, value) */ - /* { */ - /* variant_to_str(value, variant_str, 256); */ - /* log_message("VAL :(%s) : (%s)", key, variant_str); */ - /* memset(variant_str, '\0', 256); */ - /* } */ - -/* hashmap_float_set(cvars, "Some_FLOAT", 99.3f); */ - /* hashmap_debug_print(cvars); */ -/* log_message("The value of Some_FLOAT is : %f", hashmap_float_get(cvars, "Some_FLOAT")); */ -/* } */ - - /* struct Variant variant; */ - /* variant_from_str(&variant, "3.333333333333333333333", VT_DOUBLE); */ - /* log_message("Variant val : %lf", variant.val_double); */ - /* log_message("Variant type : %s", variant.type == VT_DOUBLE ? "expected" : "not what's expected"); */ - } void debug(float dt) @@ -272,18 +213,10 @@ void debug(float dt) vec3 rot_axis_left_right = {0, 1, 0}; /* Look around */ - /* if(input_map_state_get("Turn_Up", KS_PRESSED)) turn_up_down += turn_speed; */ - /* if(input_map_state_get("Turn_Down", KS_PRESSED)) turn_up_down -= turn_speed; */ - /* if(input_map_state_get("Turn_Right", KS_PRESSED)) turn_left_right += turn_speed; */ - /* if(input_map_state_get("Turn_Left", KS_PRESSED)) turn_left_right -= turn_speed; */ - - /* if(input_map_state_get("Recompute", KS_PRESSED)) */ - /* { */ - /* log_message("Regenerating Bounding Volumes"); */ - /* geom_bounding_volume_generate_all(); */ - /* } */ - /* if(input_is_key_pressed(KEY_TAB, KS_PRESSED)) */ - /* if(input_is_key_pressed(KEY_TAB, KS_PRESSED) && input_is_key_pressed(KEY_LSHIFT, KS_PRESSED)) input_mouse_mode_set(MM_NORMAL); */ + if(input_map_state_get("Turn_Up", KS_PRESSED)) turn_up_down += turn_speed; + if(input_map_state_get("Turn_Down", KS_PRESSED)) turn_up_down -= turn_speed; + if(input_map_state_get("Turn_Right", KS_PRESSED)) turn_left_right += turn_speed; + if(input_map_state_get("Turn_Left", KS_PRESSED)) turn_left_right -= turn_speed; if(input_mousebutton_state_get(MSB_RIGHT, KS_PRESSED)) { @@ -340,13 +273,13 @@ void debug(float dt) } /* Movement */ - /* if(input_map_state_get("Sprint", KS_PRESSED)) move_speed *= move_scale; */ + if(input_map_state_get("Sprint", KS_PRESSED)) move_speed *= move_scale; if(input_map_state_get("Move_Forward", KS_PRESSED)) offset.z -= move_speed; if(input_map_state_get("Move_Backward", KS_PRESSED)) offset.z += move_speed; - /* if(input_map_state_get("Move_Left", KS_PRESSED)) offset.x -= move_speed; */ - /* if(input_map_state_get("Move_Right", KS_PRESSED)) offset.x += move_speed; */ - /* if(input_map_state_get("Move_Up", KS_PRESSED)) offset.y += move_speed; */ - /* if(input_map_state_get("Move_Down", KS_PRESSED)) offset.y -= move_speed; */ + if(input_map_state_get("Move_Left", KS_PRESSED)) offset.x -= move_speed; + if(input_map_state_get("Move_Right", KS_PRESSED)) offset.x += move_speed; + if(input_map_state_get("Move_Up", KS_PRESSED)) offset.y += move_speed; + if(input_map_state_get("Move_Down", KS_PRESSED)) offset.y -= move_speed; vec3_scale(&offset, &offset, dt); if(offset.x != 0 || offset.y != 0 || offset.z != 0) @@ -381,20 +314,7 @@ void debug(float dt) /* transform_rotate(mod_tran, &y_axis, 25.f * dt, TS_WORLD); */ vec3 amount = {0, 0, 5 * dt}; transform_translate(mod_tran, &amount, TS_LOCAL); - } - - /* if(input_is_key_pressed(GLFW_KEY_C, KS_PRESSED)) */ - /* { */ - /* struct Entity* cam_ent = scene_find("Screen_Camera"); */ - /* struct Camera* cam = entity_component_get(cam_ent, C_CAMERA); */ - /* camera_set_primary_viewer(cam); */ - /* } */ - - /* if(input_is_key_pressed(GLFW_KEY_V, KS_PRESSED)) */ - /* { */ - /* struct Camera* cam = entity_component_get(entity, C_CAMERA); */ - /* camera_set_priimary_viewer(cam); */ - /* } */ + } } int run(void) @@ -422,12 +342,12 @@ int run(void) void update(float dt, int* window_should_close) { if(input_is_key_pressed(KEY_ESCAPE)) *window_should_close = 1; - /* if(input_map_state_get("Editor_Toggle", KS_RELEASED)) editor_toggle(); */ - /* if(input_map_state_get("Window_Fullscreen", KS_RELEASED)) window_fullscreen_set(game_state->window, 1); */ - /* if(input_map_state_get("Window_Maximize", KS_RELEASED)) window_fullscreen_set(game_state->window, 0); */ + if(input_map_state_get("Editor_Toggle", KS_RELEASED)) editor_toggle(); + if(input_map_state_get("Window_Fullscreen", KS_RELEASED)) window_fullscreen_set(game_state->window, 1); + if(input_map_state_get("Window_Maximize", KS_RELEASED)) window_fullscreen_set(game_state->window, 0); debug(dt); - debug_gui(dt); + //debug_gui(dt); editor_update(dt); input_update(); /* This should always be the last thing. Probably * put this in post update? */ diff --git a/src/geometry.c b/src/geometry.c index eecc034..2245af5 100644 --- a/src/geometry.c +++ b/src/geometry.c @@ -236,7 +236,7 @@ static int load_from_file(struct Geometry* geometry, const char* filename) int success = 1; char* full_path = str_new("models/%s", filename); - FILE* file = io_file_open(full_path, "rb"); + FILE* file = io_file_open(DT_INSTALL, full_path, "rb"); free(full_path); if(file) { diff --git a/src/gui.c b/src/gui.c index cfc3932..cdadf3c 100644 --- a/src/gui.c +++ b/src/gui.c @@ -369,7 +369,7 @@ void gui_font_set(const char* font_name, float font_size) struct nk_font_atlas* atlas = &gui_state->atlas; long size = 0; char* font_file_name = str_new("fonts/%s", font_name); - char* font_data = io_file_read(font_file_name, "rb", &size); + char* font_data = io_file_read(DT_INSTALL, font_file_name, "rb", &size); free(font_file_name); if(!font_data) { diff --git a/src/input.c b/src/input.c index 0589191..b1be0e0 100644 --- a/src/input.c +++ b/src/input.c @@ -32,12 +32,44 @@ void input_init(void) platform_mousewheel_callback_set(&input_on_mousewheel); input_map_list = array_new(struct Input_Map); - input_keybinds_load("keybindings.cfg"); + if(!input_keybinds_load("keybindings.cfg")) + log_error("input:init", "Failed to load keybindings"); + + /* struct Key_Combination forward_keys[2] = {{KEY_W, KMD_NONE}, {KEY_UP, KMD_ALT | KMD_SHIFT}}; */ + /* struct Key_Combination backward_keys[2] = {{KEY_S, KMD_NONE}, {KEY_DOWN, KMD_NONE}}; */ + /* struct Key_Combination up_keys[2] = {KEY_Q}; */ + /* struct Key_Combination down_keys[2] = {KEY_E}; */ + /* struct Key_Combination left_keys[2] = {KEY_A, KEY_LEFT}; */ + /* struct Key_Combination right_keys[2] = {KEY_D, KEY_RIGHT}; */ + /* struct Key_Combination turn_right_keys[1] = {KEY_L}; */ + /* struct Key_Combination turn_left_keys[1] = {KEY_J}; */ + /* struct Key_Combination turn_up_keys[1] = {KEY_I}; */ + /* struct Key_Combination turn_down_keys[1] = {KEY_K}; */ + /* struct Key_Combination sprint_keys[2] = {KEY_LSHIFT, KEY_RSHIFT}; */ + /* struct Key_Combination recompute_keys[2] = {KEY_F5, KEY_H}; */ + /* struct Key_Combination ed_toggle_keys[1] = {KEY_F1}; */ + /* struct Key_Combination win_fullscr_keys[1] = {KEY_F11}; */ + /* struct Key_Combination win_max_keys[1] = {KEY_F12}; */ + /* input_map_create("Move_Forward", forward_keys, 2); */ + /* input_map_create("Move_Backward", backward_keys, 2); */ + /* input_map_create("Move_Up", up_keys, 1); */ + /* input_map_create("Move_Down", down_keys, 1); */ + /* input_map_create("Move_Left", left_keys, 2); */ + /* input_map_create("Move_Right", right_keys, 2); */ + /* input_map_create("Turn_Right", turn_right_keys, 1); */ + /* input_map_create("Turn_Left", turn_left_keys, 1); */ + /* input_map_create("Turn_Up", turn_up_keys, 1); */ + /* input_map_create("Turn_Down", turn_down_keys, 1); */ + /* input_map_create("Sprint", sprint_keys, 2); */ + /* input_map_create("Recompute", recompute_keys, 2); */ + /* input_map_create("Editor_Toggle", ed_toggle_keys, 1); */ + /* input_map_create("Window_Fullscreen", win_fullscr_keys, 1); */ + /* input_map_create("Window_Maximize", win_max_keys, 1); */ } void input_cleanup(void) { - input_keybinds_save("keybindings.cfg"); + //input_keybinds_save("keybindings.cfg"); for(int i = 0; i < array_len(input_map_list); i++) { struct Input_Map* map = &input_map_list[i]; @@ -53,7 +85,7 @@ int input_keybinds_load(const char* filename) int success = 0; const int MAX_KEYBIND_LEN = 128; const int MAX_LINE_LEN = 512; - FILE* config_file = io_file_open(filename, "r"); + FILE* config_file = io_file_open(DT_USER, filename, "r"); if(!config_file) { log_error("input:keybinds_load", "Could not open %s", filename); @@ -167,7 +199,7 @@ int input_keybinds_save(const char* filename) { int success = 0; - FILE* config_file = io_file_open(filename, "w"); + FILE* config_file = io_file_open(DT_USER, filename, "w"); if(!config_file) { log_error("input:keybinds_save", "Could not open %s", filename); @@ -379,7 +411,7 @@ int input_map_name_set(const char* name, const char* new_name) if(index > -1) { struct Input_Map* map = &input_map_list[index]; - map->name = new_name; + map->name = str_new(new_name); success = 1; } if(!success) log_error("input:map_name_set", "Map %s not found", name); @@ -392,7 +424,6 @@ int map_find(const char* name) for(int i = 0; i < array_len(input_map_list); i++) { struct Input_Map* map = &input_map_list[i]; - log_message("Len : %d, Comparing %s and %s", array_len(input_map_list), name, map->name); if(strcmp(name, map->name) == 0) { index = i; @@ -409,7 +440,6 @@ int input_mouse_mode_get(void) return mouse_mode; } - void input_mouse_delta_get(int* xpos, int* ypos) { platform_mouse_delta_get(xpos, ypos); diff --git a/src/main.c b/src/main.c index 5499348..37e9817 100644 --- a/src/main.c +++ b/src/main.c @@ -44,11 +44,16 @@ int init(void) } else { - char* base_path = platform_base_path_get(); - io_file_init(base_path); - free(base_path); + char* install_path = platform_install_directory_get(); + char* user_path = platform_user_directory_get("SS_Games", "Symmetry"); + io_file_init(install_path, user_path); + free(install_path); + free(user_path); if(!config_vars_load("config.cfg")) + { log_error("main:init", "Could not load config, reverting to defaults"); + config_vars_save("config.cfg"); + } struct Hashmap* cvars = config_vars_get(); int width = hashmap_int_get(cvars, "render_width"); diff --git a/src/platform.c b/src/platform.c index 3c473e0..f36616b 100644 --- a/src/platform.c +++ b/src/platform.c @@ -355,7 +355,7 @@ void platform_mouse_delta_get(int* x, int* y) SDL_GetRelativeMouseState(x, y); } -char* platform_base_path_get(void) +char* platform_install_directory_get(void) { char* returned_path = SDL_GetBasePath(); char* path = NULL; @@ -399,7 +399,6 @@ int platform_key_from_name(const char* key_name) while(isspace(end_ptr[0])) end_ptr--; strncpy(trimmed_key_name, start_ptr, (end_ptr - start_ptr)); - log_message("trimmed : %s", trimmed_key_name); return SDL_GetKeyFromName(trimmed_key_name); } @@ -408,3 +407,19 @@ const char* platform_key_name_get(int key) if(key < 0) return "SDLK_UNKNOWN"; return SDL_GetKeyName(key); } + +char* platform_user_directory_get(const char* organization, const char* application) +{ + char* user_directory = NULL; + char* temp_path = SDL_GetPrefPath(organization, application); + if(temp_path) + { + user_directory = str_new(temp_path); + SDL_free(temp_path); + } + else + { + log_error("platform:user_directory_get", "Error getting user directory, %s", SDL_GetError()); + } + return user_directory; +} diff --git a/src/platform.h b/src/platform.h index 5381b9d..16fcdf8 100644 --- a/src/platform.h +++ b/src/platform.h @@ -46,7 +46,8 @@ void platform_mouse_global_position_set(int x, int y); void platform_mouse_relative_mode_set(int relative_mode); int platform_mouse_relative_mode_get(void); uint32 platform_ticks_get(void); -char* platform_base_path_get(void); +char* platform_install_directory_get(void); +char* platform_user_directory_get(const char* organization, const char* application); void platform_clipboard_text_set(const char* text); char* platform_clipboard_text_get(void); int platform_key_from_name(const char* key_name); diff --git a/src/shader.c b/src/shader.c index 8834f22..4a9d5b0 100644 --- a/src/shader.c +++ b/src/shader.c @@ -56,7 +56,7 @@ char* run_preprocessor(char* shader_text) { char* path = str_new("shaders/"); path = str_concat(path, filename); - char* file = io_file_read(path, "r", NULL); + char* file = io_file_read(DT_INSTALL, path, "r", NULL); char* shader_copy = str_new(shader_text); char* temp = realloc(shader_text, (strlen(shader_text) + strlen(file) + 2)); if(temp) @@ -96,8 +96,8 @@ int shader_create(const char* vert_shader_name, const char* frag_shader_name) GLuint vert_shader = glCreateShader(GL_VERTEX_SHADER); GLuint frag_shader = glCreateShader(GL_FRAGMENT_SHADER); - char* vert_source = io_file_read(vs_path, "r", NULL); - char* frag_source = io_file_read(fs_path, "r", NULL); + char* vert_source = io_file_read(DT_INSTALL, vs_path, "r", NULL); + char* frag_source = io_file_read(DT_INSTALL, fs_path, "r", NULL); assert(vert_source != NULL); assert(frag_source != NULL); diff --git a/src/sound.c b/src/sound.c index 4edf2f1..4a8f27e 100644 --- a/src/sound.c +++ b/src/sound.c @@ -244,7 +244,7 @@ void sound_source_load_wav(struct Sound_Source* source, const char* file_name) } char* full_path = str_new("sounds/%s", file_name); - FILE* wav_file = io_file_open(full_path, "rb"); + FILE* wav_file = io_file_open(DT_INSTALL, full_path, "rb"); free(full_path); if(!wav_file) { diff --git a/src/texture.c b/src/texture.c index d299662..62cdf6b 100644 --- a/src/texture.c +++ b/src/texture.c @@ -68,7 +68,7 @@ int texture_create_from_file(const char* filename, int texture_unit) } /* If texture not already loaded then try to load it */ char* full_path = str_new("textures/%s", filename); - FILE* file = io_file_open(full_path, "rb"); + FILE* file = io_file_open(DT_INSTALL, full_path, "rb"); int img_load_success = -1; if(file)