fixed paths
This commit is contained in:
10
src/main.cpp
10
src/main.cpp
@ -682,12 +682,11 @@ int main(int, char **)
|
||||
}
|
||||
SDL_SetRenderVSync(renderer, 1);
|
||||
|
||||
// Ensure our working directory matches the executable location so
|
||||
// relative asset paths (assets/, FreeSans.ttf, etc.) resolve even
|
||||
// when launching from a macOS .app bundle via Finder.
|
||||
if (char* basePathRaw = SDL_GetBasePath()) {
|
||||
#if defined(__APPLE__)
|
||||
// On macOS bundles launched from Finder start in /, so re-root relative paths.
|
||||
if (const char* basePathRaw = SDL_GetBasePath()) {
|
||||
std::filesystem::path exeDir(basePathRaw);
|
||||
SDL_free(basePathRaw);
|
||||
SDL_free(const_cast<char*>(basePathRaw));
|
||||
std::error_code ec;
|
||||
std::filesystem::current_path(exeDir, ec);
|
||||
if (ec) {
|
||||
@ -700,6 +699,7 @@ int main(int, char **)
|
||||
"SDL_GetBasePath() failed; asset lookups rely on current directory: %s",
|
||||
SDL_GetError());
|
||||
}
|
||||
#endif
|
||||
|
||||
FontAtlas font;
|
||||
font.init("FreeSans.ttf", 24);
|
||||
|
||||
Reference in New Issue
Block a user