Line data Source code
1 : #include <filesystem>
2 : #include <memory>
3 : #include <ranges>
4 : #include <tracy/Tracy.hpp>
5 : #include <wren/application.hpp>
6 : #include <wren/context.hpp>
7 : #include <wren/graph.hpp>
8 : #include <wren/logging/log.hpp>
9 : #include <wren/shaders/mesh.hpp>
10 : #include <wren/utils/format.hpp>
11 :
12 : #include "editor.hpp"
13 :
14 0 : auto main(int argc, char** argv) -> int {
15 : // log::set_level(log::level::debug);
16 :
17 : // Fix this warning
18 :
19 0 : auto args = std::span(argv, argc) | std::views::drop(1) |
20 0 : std::ranges::to<std::vector>();
21 :
22 0 : wren::log::debug("launching editor");
23 0 : wren::log::debug("args:");
24 0 : for (const auto arg : args) {
25 0 : wren::log::debug("\t{}", arg);
26 : }
27 :
28 0 : std::optional<std::filesystem::path> project_path;
29 0 : if (!args.empty()) {
30 0 : std::filesystem::path p(args.front());
31 0 : if (std::filesystem::exists(p)) {
32 0 : wren::log::info("Loading project {}", args.front());
33 0 : project_path = p;
34 0 : } else {
35 0 : wren::log::error("Project ({}) doesn't exist", args.front());
36 0 : return EXIT_FAILURE;
37 : }
38 0 : }
39 :
40 0 : const auto& err = wren::Application::create("Editor");
41 0 : if (!err.has_value()) {
42 0 : wren::log::error("failed to create application: {}", err.error().message());
43 0 : return EXIT_FAILURE;
44 : }
45 :
46 0 : const auto& app = err.value();
47 :
48 : // TODO Build 3D rendergraph, be able to check resources if non
49 : // match the output framebuffer add a pass specifically for
50 : // transitioning into the presentable layout
51 :
52 0 : const auto res = editor::Editor::create(app, project_path.value());
53 0 : if (!res.has_value()) {
54 0 : wren::log::error("{}", res.error());
55 0 : return EXIT_FAILURE;
56 : }
57 0 : const auto editor = res.value();
58 :
59 0 : app->run();
60 :
61 0 : return EXIT_SUCCESS;
62 0 : }
|