blob: 3d5b685aaff0aef04fb8b4c02f06aabe3059eb86 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
#include "core/application.h"
#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;
}
|