Foray Library
rapid prototyping framework for crossplatform development of vulkan hardware ray tracing applications
Loading...
Searching...
No Matches
foray_component.hpp
Go to the documentation of this file.
1#pragma once
2#include "../base/foray_framerenderinfo.hpp"
3#include "../core/foray_core_declares.hpp"
4#include "../foray_basics.hpp"
5#include "../osi/foray_osi_declares.hpp"
8
9namespace foray::scene {
10
12 class Component : public NoMoveDefaults, public Polymorphic
13 {
14 public:
15 friend Registry;
16
19 {
20 public:
21 static const bool ORDERED_EXECUTION = true;
23
25 inline virtual void Update(TArg updateInfo) = 0;
26 inline void Invoke(TArg updateInfo) { Update(updateInfo); }
27
28 static const int32_t ORDER_TRANSFORM = 100;
29 static const int32_t ORDER_DEVICEUPLOAD = 200;
30
31 virtual inline int32_t GetOrder() const { return 0; }
32 };
33
36 {
37 public:
38 static const bool ORDERED_EXECUTION = false;
41 inline virtual void Draw(TArg drawInfo) = 0;
42 inline void Invoke(TArg drawInfo) { Draw(drawInfo); }
43 };
44
47 {
48 public:
49 static const bool ORDERED_EXECUTION = false;
50 using TArg = const osi::Event*;
52 inline virtual void OnEvent(TArg event) = 0;
53 inline void Invoke(TArg event) { OnEvent(event); }
54 };
55
57 {
58 public:
59 static const bool ORDERED_EXECUTION = false;
60 using TArg = VkExtent2D;
62 inline virtual void OnResized(TArg extent) = 0;
63 inline void Invoke(TArg event) { OnResized(event); }
64 };
65
67 inline virtual ~Component() {}
68
71
72 virtual Scene* GetScene() = 0;
73 virtual Registry* GetGlobals() = 0;
74 virtual core::Context* GetContext() = 0;
75
76 protected:
77 Registry* mRegistry = nullptr;
78 std::string mName = "";
79 };
80
81 class NodeComponent : public Component
82 {
83 public:
87 virtual Scene* GetScene() override;
89 virtual Registry* GetGlobals() override;
91 virtual core::Context* GetContext() override;
92 };
93
95 {
96 public:
98 virtual Scene* GetScene() override;
100 virtual Registry* GetGlobals() override;
102 virtual core::Context* GetContext() override;
103 };
104} // namespace foray::scene
Simple types for supressing automatic definition of duplicating move constructors & operator.
Definition foray_basics.hpp:19
Simple type for forcing a type to be polymorphic.
Definition foray_basics.hpp:29
Base class for operating system events.
Definition foray_event.hpp:13
Base class for implementing the draw callback.
Definition foray_component.hpp:36
void Invoke(TArg drawInfo)
Definition foray_component.hpp:42
static const bool ORDERED_EXECUTION
Definition foray_component.hpp:38
virtual void Draw(TArg drawInfo)=0
Invoked last each frame. Use to submit draw calls (and related)
Base class for implementing the onevent callback.
Definition foray_component.hpp:47
void Invoke(TArg event)
Definition foray_component.hpp:53
virtual void OnEvent(TArg event)=0
Invoked with every event received by the application.
static const bool ORDERED_EXECUTION
Definition foray_component.hpp:49
Definition foray_component.hpp:57
static const bool ORDERED_EXECUTION
Definition foray_component.hpp:59
virtual void OnResized(TArg extent)=0
Invoked when the primary render resolution changes.
VkExtent2D TArg
Definition foray_component.hpp:60
void Invoke(TArg event)
Definition foray_component.hpp:63
Base class for implementing the update callback.
Definition foray_component.hpp:19
static const int32_t ORDER_DEVICEUPLOAD
Definition foray_component.hpp:29
virtual int32_t GetOrder() const
Definition foray_component.hpp:31
static const bool ORDERED_EXECUTION
Definition foray_component.hpp:21
virtual void Update(TArg updateInfo)=0
Invoked first each frame. Use for changes to the node hierarchy and transforms.
void Invoke(TArg updateInfo)
Definition foray_component.hpp:26
static const int32_t ORDER_TRANSFORM
Definition foray_component.hpp:28
Base class for all types manageable by registry.
Definition foray_component.hpp:13
Registry * mRegistry
Definition foray_component.hpp:77
virtual ~Component()
Destructor. Provide virtual constructors in inheriting classes, to make sure they get finalized corre...
Definition foray_component.hpp:67
friend Registry
Definition foray_component.hpp:15
virtual core::Context * GetContext()=0
virtual Scene * GetScene()=0
virtual Registry * GetGlobals()=0
std::string mName
Definition foray_component.hpp:78
Definition foray_component.hpp:95
virtual Scene * GetScene() override
Scene this component is a part of. Casts mRegistry to Scene.
virtual core::Context * GetContext() override
Vulkan Context. Casts mRegistry to Scene and returns Scene->GetContext()
virtual Registry * GetGlobals() override
Global component registry. Returns mRegistry.
Definition foray_component.hpp:82
Node * GetNode()
Node this component is attached to. Casts mRegistry to Node.
virtual Registry * GetGlobals() override
Global component registry. Casts mRegistry->mCallbackDispatcher to Scene and returns Scene->GetGlobal...
virtual core::Context * GetContext() override
Vulkan Context. Casts mRegistry->mCallbackDispatcher to Scene and returns Scene->GetContext()
virtual Scene * GetScene() override
Scene this component is a part of. Casts mRegistry->mCallbackDispatcher to Scene.
A scene node. Extends the registry with hierarchical information.
Definition foray_node.hpp:8
Manages a type identified list of components.
Definition foray_registry.hpp:12
Provides registries and methods as the anchor of a component based scene.
Definition foray_scene.hpp:17
#define FORAY_GETTER_V(member)
Return value.
Definition foray_basics.hpp:39
#define FORAY_PROPERTY_R(member)
Getter+Setter shorthand for reference types.
Definition foray_basics.hpp:86
Definition foray_animation.hpp:8
Definition foray_env.hpp:92
Non owning context object.
Definition foray_context.hpp:16
Temporary type passed to components when drawing the scene.
Definition foray_scenedrawing.hpp:63
Temporary type passed to components when updating the scene.
Definition foray_scenedrawing.hpp:49