try to change to working directory on startup so assets can be found

This commit is contained in:
Sven Balzer
2025-09-29 06:24:58 +02:00
parent c3c0f8adf7
commit 5a77a4aacb
4 changed files with 48 additions and 1 deletions
+17 -1
View File
@@ -15,12 +15,13 @@
#include "log.h"
#include "math_graphics.h"
#include "stb_image.h"
#include "change_directory.h"
#include "shaders/shaders.h"
using namespace M;
#define ASSETS_PATH "../assets/"
#define ASSETS_PATH "./assets/"
#define NEAR_PLANE (0.01f)
#define TILE_SIZE (32)
@@ -1365,8 +1366,23 @@ WGPUSurface create_wgpu_surface_for_SDL_window(SDL_Window *window) {
return NULL;
}
void setup_working_directory() {
if (SDL_GetPathInfo(ASSETS_PATH, NULL)) return;
const char *current_directory = SDL_GetCurrentDirectory();
change_directory(SDL_GetBasePath());
if (SDL_GetPathInfo(ASSETS_PATH, NULL)) return;
change_directory("..");
if (SDL_GetPathInfo(ASSETS_PATH, NULL)) return;
change_directory(current_directory);
}
int main(int argc, char **argv) {
setup_memory_functions();
setup_working_directory();
#ifdef SDL_PLATFORM_LINUX
if (getenv("ENABLE_VULKAN_RENDERDOC_CAPTURE"))