hachem.wtf
aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorhachem <im@hachem.wtf>2026-09-22 06:45:33 +0200
committerhachem <im@hachem.wtf>2026-09-22 06:45:33 +0200
commit32ee3d9f57b37723ee97c3b798be6968f98df1b1 (patch)
tree10838a06f522a48f64645e2d31c3d72eb1a58643 /src/main.cpp
parente321beb543311dcb591942ec42464e38cbeae0f0 (diff)
fix: windows support
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 323d141..3d5b685 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1,7 +1,24 @@
#include "core/application.h"
-int main()
+#include <filesystem>
+
+static auto chdir_to_project_root(std::filesystem::path start) -> bool
+{
+ namespace fs = std::filesystem;
+ std::error_code ec;
+ for (fs::path p = start; !p.empty(); p = p.parent_path())
+ {
+ if (fs::exists(p / "assets" / "shaders", ec)) { fs::current_path(p, ec); return !ec; }
+ if (p == p.root_path()) break;
+ }
+ return false;
+}
+
+int main(int, char** argv)
{
+ std::error_code ec;
+ if (!chdir_to_project_root(std::filesystem::current_path(ec)) && argv && argv[0])
+ chdir_to_project_root(std::filesystem::absolute(argv[0], ec).parent_path());
Donut::Application* app = new Donut::Application("Donut Engine - Black Hole Simulation", 1280, 720);
app->run();
delete app;