wren
Vulkan-based game engine
Loading...
Searching...
No Matches
application.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <memory>
4
5#include "context.hpp"
6#include "wren/renderer.hpp"
7
8namespace wren {
9
11
12using phase_cb_t = std::function<void()>;
14using update_phase_cb_t = std::function<void(std::chrono::duration<double>)>;
16
18 public:
19 enum class Errors {};
20
21 static auto create(const std::string& application_name)
23
24 auto context() -> const std::shared_ptr<Context>& { return ctx_; }
25 void run();
26
28 startup_phase_.emplace_back(cb);
29 }
30
32 update_phase_.emplace_back(cb);
33 }
34
36 shutdown_phase_.emplace_back(cb);
37 }
38
39 private:
40 explicit Application(const std::shared_ptr<Context>& ctx,
41 const std::shared_ptr<Renderer>& renderer);
42
43 std::shared_ptr<Context> ctx_;
44 std::shared_ptr<Renderer> renderer_;
45
46 std::vector<phase_cb_t> startup_phase_;
47 std::vector<update_phase_cb_t> update_phase_;
48 std::vector<phase_cb_t> shutdown_phase_;
49
51};
52
53} // namespace wren
Errors
Definition application.hpp:19
Application(const std::shared_ptr< Context > &ctx, const std::shared_ptr< Renderer > &renderer)
Definition application.cpp:48
bool running_
Definition application.hpp:50
std::vector< phase_cb_t > startup_phase_
Definition application.hpp:46
std::shared_ptr< Renderer > renderer_
Definition application.hpp:44
void add_callback_to_shutdown_phase(const shutdown_phase_cb_t &cb)
Definition application.hpp:35
std::shared_ptr< Context > ctx_
Definition application.hpp:43
void add_callback_to_startup_phase(const startup_phase_cb_t &cb)
Definition application.hpp:27
static auto create(const std::string &application_name) -> expected< std::shared_ptr< Application > >
Definition application.cpp:17
void run()
Definition application.cpp:54
std::vector< phase_cb_t > shutdown_phase_
Definition application.hpp:48
std::vector< update_phase_cb_t > update_phase_
Definition application.hpp:47
auto context() -> const std::shared_ptr< Context > &
Definition application.hpp:24
void add_callback_to_update_phase(const update_phase_cb_t &cb)
Definition application.hpp:31
Definition editor_scene.hpp:5
phase_cb_t shutdown_phase_cb_t
Definition application.hpp:15
std::function< void()> phase_cb_t
Definition application.hpp:12
std::function< void(std::chrono::duration< double >)> update_phase_cb_t
Definition application.hpp:14
std::expected< T, Err > expected
Definition result.hpp:43
phase_cb_t startup_phase_cb_t
Definition application.hpp:13
CallbackPhase
Definition application.hpp:10
@ Update
Definition application.hpp:10
@ Startup
Definition application.hpp:10
@ Shutdown
Definition application.hpp:10