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