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"
17#include "stage.h"
18namespace Graphics
19{
20class Stage;
21class Camera;
22class View : public Core::RefCounted
23{
25public:
27 View();
29 virtual ~View();
30
32 void UpdateConstants();
34 void Render(const IndexT frameIndex, const Timing::Time time, const IndexT bufferIndex);
35
37 void SetFrameScript(void(*func)(const Math::rectangle<int>& viewport, IndexT frameIndex, IndexT bufferIndex));
39 void SetViewport(const Math::rectangle<int>& rect);
42
47
49 void SetStage(const Ptr<Stage>& stage);
51 const Ptr<Stage>& GetStage() const;
52
54 bool IsEnabled() const;
55
57 void Enable();
58
60 void Disable();
61private:
62 friend class GraphicsServer;
63
65 void (*func)(const Math::rectangle<int>& viewport, IndexT frameIndex, IndexT bufferIndex);
68 bool enabled;
69};
70
71//------------------------------------------------------------------------------
74inline void
76{
77 this->camera = camera;
78}
79
80//------------------------------------------------------------------------------
83inline const GraphicsEntityId&
85{
86 return this->camera;
87}
88
89//------------------------------------------------------------------------------
92inline void
94{
95 this->stage = stage;
96}
97
98//------------------------------------------------------------------------------
101inline const Ptr<Stage>&
103{
104 return this->stage;
105}
106
107//------------------------------------------------------------------------------
110inline bool
112{
113 return this->enabled;
114}
115
116//------------------------------------------------------------------------------
119inline void
121{
122 this->enabled = true;
123}
124
125//------------------------------------------------------------------------------
128inline void
130{
131 this->enabled = false;
132}
133
134//------------------------------------------------------------------------------
137inline void
138View::SetFrameScript(void(*func)(const Math::rectangle<int>& viewport, IndexT frameIndex, IndexT bufferIndex))
139{
140 this->func = func;
141}
142
143//------------------------------------------------------------------------------
146inline void
148{
149 this->viewport = rect;
150}
151
152//------------------------------------------------------------------------------
155inline const
157{
158 return this->viewport;
159}
160
161} // namespace Graphics
The common base class of Nebula.
Definition refcounted.h:38
The graphics server is the main singleton for the Graphics subsystem.
Definition graphicsserver.h:47
A view describes a camera which can observe a Stage.
Definition view.h:23
const GraphicsEntityId & GetCamera()
get camera
bool IsEnabled() const
returns whether view is enabled
Definition view.h:111
virtual ~View()
destructor
Definition view.cc:35
void SetFrameScript(void(*func)(const Math::rectangle< int > &viewport, IndexT frameIndex, IndexT bufferIndex))
Set run function.
Definition view.h:138
GraphicsEntityId camera
Definition view.h:66
void SetStage(const Ptr< Stage > &stage)
set stage
Definition view.h:93
void(* func)(const Math::rectangle< int > &viewport, IndexT frameIndex, IndexT bufferIndex)
Definition view.h:65
Ptr< Stage > stage
Definition view.h:67
const Math::rectangle< int > & GetViewport()
Get viewport.
Definition view.h:156
void SetViewport(const Math::rectangle< int > &rect)
Set viewport.
Definition view.h:147
const Ptr< Stage > & GetStage() const
get stage
Definition view.h:102
void Render(const IndexT frameIndex, const Timing::Time time, const IndexT bufferIndex)
render through view
Definition view.cc:85
Math::rectangle< int > viewport
Definition view.h:64
void Disable()
disable this view
Definition view.h:129
bool enabled
Definition view.h:68
void SetCamera(const GraphicsEntityId &camera)
set camera
Definition view.h:75
void UpdateConstants()
Update constants.
Definition view.cc:44
void Enable()
enable this view
Definition view.h:120
View()
constructor
Definition view.cc:23
__DeclareClass(View)
A 2d rectangle class.
Definition rectangle.h:20
Nebula's smart pointer class which manages the life time of RefCounted objects.
Definition ptr.h:38
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:48