try to change to working directory on startup so assets can be found
This commit is contained in:
+17
-1
@@ -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"))
|
||||
|
||||
Reference in New Issue
Block a user