Nebula
Loading...
Searching...
No Matches
view.h
Go to the documentation of this file.
1#pragma once
2//------------------------------------------------------------------------------
12//------------------------------------------------------------------------------
13#include "core/refcounted.h"
14#include "frame/framescript.h"
15#include "timing/time.h"
16#include "graphicsentity.h"
17namespace Graphics
18{
19class Camera;
20class View : public Core::RefCounted
21{
23public:
25 View();
27 virtual ~View();
28
30 void UpdateConstants();
32 bool Render(const IndexT frameIndex, const Timing::Time time, const IndexT bufferIndex);
33
35 void SetFrameScript(bool(*func)(const Math::rectangle<int>& viewport, IndexT frameIndex, IndexT bufferIndex));
37 void SetViewport(const Math::rectangle<int>& rect);
40
45
47 void SetStageMask(const uint16_t stage);
49 const uint16_t GetStageMask() const;
50
52 bool IsEnabled() const;
53
55 void Enable();
56
58 void Disable();
59private:
60 friend class GraphicsServer;
61
63 uint16_t stageMask;
64 bool (*func)(const Math::rectangle<int>& viewport, IndexT frameIndex, IndexT bufferIndex);
66 bool enabled;
67};
68
69//------------------------------------------------------------------------------
72inline void
74{
75 this->camera = camera;
76}
77
78//------------------------------------------------------------------------------
81inline const GraphicsEntityId&
83{
84 return this->camera;
85}
86
87//------------------------------------------------------------------------------
90inline void
92{
93 this->stageMask = stageMask;
94}
95
96//------------------------------------------------------------------------------
99inline const uint16_t
101{
102 return this->stageMask;
103}
104
105//------------------------------------------------------------------------------
108inline bool
110{
111 return this->enabled;
112}
113
114//------------------------------------------------------------------------------
117inline void
119{
120 this->enabled = true;
121}
122
123//------------------------------------------------------------------------------
126inline void
128{
129 this->enabled = false;
130}
131
132//------------------------------------------------------------------------------
135inline void
136View::SetFrameScript(bool(*func)(const Math::rectangle<int>& viewport, IndexT frameIndex, IndexT bufferIndex))
137{
138 this->func = func;
139}
140
141//------------------------------------------------------------------------------
144inline void
146{
147 this->viewport = rect;
148}
149
150//------------------------------------------------------------------------------
153inline const
155{
156 return this->viewport;
157}
158
159} // namespace Graphics
The common base class of Nebula.
Definition refcounted.h:38
bool(* func)(const Math::rectangle< int > &viewport, IndexT frameIndex, IndexT bufferIndex)
Definition view.h:64
const GraphicsEntityId & GetCamera()
get camera
Definition view.h:82
bool IsEnabled() const
returns whether view is enabled
Definition view.h:109
void SetStageMask(const uint16_t stage)
set stage
Definition view.h:91
virtual ~View()
destructor
Definition view.cc:35
friend class GraphicsServer
Definition view.h:60
GraphicsEntityId camera
Definition view.h:65
void SetFrameScript(bool(*func)(const Math::rectangle< int > &viewport, IndexT frameIndex, IndexT bufferIndex))
Set run function.
Definition view.h:136
const uint16_t GetStageMask() const
get stage
Definition view.h:100
const Math::rectangle< int > & GetViewport()
Get viewport.
Definition view.h:154
void SetViewport(const Math::rectangle< int > &rect)
Set viewport.
Definition view.h:145
Math::rectangle< int > viewport
Definition view.h:62
void Disable()
disable this view
Definition view.h:127
bool enabled
Definition view.h:66
void SetCamera(const GraphicsEntityId &camera)
set camera
Definition view.h:73
void UpdateConstants()
Update constants.
Definition view.cc:44
void Enable()
enable this view
Definition view.h:118
View()
constructor
Definition view.cc:23
__DeclareClass(View)
uint16_t stageMask
Definition view.h:63
bool Render(const IndexT frameIndex, const Timing::Time time, const IndexT bufferIndex)
render through view, returns true if framescript needs resizing
Definition view.cc:85
A 2d rectangle class.
Definition rectangle.h:20
Implements the shader server used by Vulkan.
Definition cameramanager.h:21
double Time
the time datatype
Definition time.h:18
@ Camera
Definition visibility.h:39
The graphics entity is only an Id, to which we can attach GraphicsContexts.
Definition graphicsentity.h:16
Typedefs for the Timing subsystem.
int IndexT
Definition types.h:41