-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathScreenSpaceGuiArea.hpp
80 lines (60 loc) · 2.44 KB
/
ScreenSpaceGuiArea.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
////////////////////////////////////////////////////////////////////////////////////////////////////
// This file is part of CosmoScout VR //
////////////////////////////////////////////////////////////////////////////////////////////////////
// SPDX-FileCopyrightText: German Aerospace Center (DLR) <[email protected]>
// SPDX-License-Identifier: MIT
#ifndef CS_GUI_VISTA_SCREENSPACEGUIAREA_HPP
#define CS_GUI_VISTA_SCREENSPACEGUIAREA_HPP
#include "GuiArea.hpp"
#include <VistaAspects/VistaObserver.h>
#include <VistaKernel/GraphicsManager/VistaOpenGLDraw.h>
#include <VistaOGLExt/VistaGLSLShader.h>
#include <vector>
class VistaTransformNode;
class VistaTransformMatrix;
class VistaVector3D;
class VistaQuaternion;
class VistaProjection;
class VistaViewport;
class VistaGLSLShader;
class VistaVertexArrayObject;
class VistaBufferObject;
namespace cs::gui {
/// This class is used to render static UI elements, which are always at the same position of the
/// screen.
class CS_GUI_EXPORT ScreenSpaceGuiArea : public GuiArea,
public IVistaOpenGLDraw,
public IVistaObserver {
public:
explicit ScreenSpaceGuiArea(VistaViewport* pViewport);
ScreenSpaceGuiArea(ScreenSpaceGuiArea const& other) = delete;
ScreenSpaceGuiArea(ScreenSpaceGuiArea&& other) = delete;
ScreenSpaceGuiArea& operator=(ScreenSpaceGuiArea const& other) = delete;
ScreenSpaceGuiArea& operator=(ScreenSpaceGuiArea&& other) = delete;
~ScreenSpaceGuiArea() override = default;
int getWidth() const override;
int getHeight() const override;
/// Draws the UI to screen.
bool Do() override;
bool GetBoundingBox(VistaBoundingBox& oBoundingBox) override;
/// Handles changes to the screen size.
void ObserverUpdate(IVistaObserveable* pObserveable, int nMsg, int nTicket) override;
private:
virtual void onViewportChange();
VistaViewport* mViewport;
VistaGLSLShader mShader;
bool mShaderDirty = true;
int mWidth = 0;
int mHeight = 0;
int mDelayedViewportUpdate = 0;
struct {
uint32_t position = 0;
uint32_t scale = 0;
uint32_t texSize = 0;
uint32_t texture = 0;
} mUniforms;
static const char* const QUAD_VERT;
static const char* const QUAD_FRAG;
};
} // namespace cs::gui
#endif // CS_GUI_VISTA_SCREENSPACEGUIAREA_HPP