Toast Engine
Loading...
Searching...
No Matches
engine.hpp
1
4
5#pragma once
6#include <cstdint>
7#include <glm/vec3.hpp>
8#include <toast/uid.hpp>
9
10namespace assets {
11class Prefab;
12}
13
14namespace renderer {
15class VulkanCore;
16class VulkanRenderer;
19}
20
21namespace toast {
22
23struct EnginePimpl;
24
25class Engine final {
26public:
27 Engine() noexcept;
28 ~Engine() noexcept;
29 static auto get() noexcept -> Engine*;
30
31 Engine(Engine&) = delete;
32 Engine(Engine&&) = delete;
33 auto operator=(const Engine&) -> Engine& = delete;
34 auto operator=(const Engine&&) -> Engine& = delete;
35
36 void init();
37 void tick();
38 auto shouldClose() -> bool;
39 void test();
40
41 void reloadSettings();
42
43 // window
44 void createSDLWindow(const char*);
45 void createAvaloniaWindow();
46
47 auto shootVoxel(
48 const glm::vec3& origin, const glm::vec3& direction, float max_distance, float energy_density, float fracture_radius
49 ) -> bool;
50
51 // nodes
52 auto createWorkspace(std::string_view type) -> std::pair<UID, std::string>;
53 auto openWorkspace(UID uid) -> std::pair<UID, std::string>;
55 auto openWorkspace(UID uid, std::string_view source_uri) -> std::pair<UID, std::string>;
57 auto playWorkspace(UID source_handle) -> std::pair<UID, std::string>;
58 void destroyWorkspace(UID handle);
59
60 void requireTickThread(std::string_view what) const;
62 [[nodiscard]]
63 auto onTickThread() const -> bool;
64
65 auto activeWorkspace() -> UID;
66 void publishPrefab(UID uid, const assets::Prefab& prefab);
67
69 void refreshNodeInfos();
70
73 auto getViewportFrame(void* dst, uint32_t dst_capacity, renderer::ViewportFrameDesc* out) -> int;
74
76 [[nodiscard]]
78
80 void beginApplication();
81
83 void popApplication();
84
87 void startGame();
88
89private:
90 void syncOwnerListeners();
91
92 EnginePimpl* m;
93 static Engine* instance;
94};
95
96/*
97 * The order to call and initialize the engine on the Editor and the Player should be:
98 * - Create an engine -> toast_create()
99 * - Create a game -> game_create()
100 * - Set the working directories -> toast_set_working_directory()
101 * - Call Init() -> toast_init()
102 * - Create window -> toast_create_[...]_window()
103 */
104
105}
Definition prefab.hpp:54
Definition shared_texture_output_target.hpp:44
Definition vulkan_core.hpp:48
Definition vulkan_renderer.hpp:88
void popApplication()
Destroys the active application layer and nulls the pointer.
Definition engine.cpp:948
void beginApplication()
Calls begin() on the currently registered application layer (if any).
Definition engine.cpp:956
void startGame()
Creates the World, then loads and activates the init_scene from project settings.
Definition engine.cpp:962
void refreshNodeInfos()
Re-resolves NodeInfo after a project reload.
Definition engine.cpp:906
auto playWorkspace(UID source_handle) -> std::pair< UID, std::string >
Clones the given workspace's into a new ticking PlayWorkspace.
Definition engine.cpp:850
auto onTickThread() const -> bool
Before the first tick the thread that created the engine counts.
Definition engine.cpp:418
auto viewportTarget() -> renderer::SharedTextureOutputTarget *
Editor viewport.
Definition engine.cpp:920
auto getViewportFrame(void *dst, uint32_t dst_capacity, renderer::ViewportFrameDesc *out) -> int
Copies the latest viewport frame into dst.
Definition engine.cpp:913
Definition shared_texture_output_target.hpp:21
Definition engine.cpp:115
Definition uid.hpp:20
Unique identifier for everything that exists in our engine.