TGUI  1.0-rc2
Loading...
Searching...
No Matches
CanvasOpenGL3.hpp
1
2//
3// TGUI - Texus' Graphical User Interface
4// Copyright (C) 2012-2023 Bruno Van de Velde (vdv_b@tgui.eu)
5//
6// This software is provided 'as-is', without any express or implied warranty.
7// In no event will the authors be held liable for any damages arising from the use of this software.
8//
9// Permission is granted to anyone to use this software for any purpose,
10// including commercial applications, and to alter it and redistribute it freely,
11// subject to the following restrictions:
12//
13// 1. The origin of this software must not be misrepresented;
14// you must not claim that you wrote the original software.
15// If you use this software in a product, an acknowledgment
16// in the product documentation would be appreciated but is not required.
17//
18// 2. Altered source versions must be plainly marked as such,
19// and must not be misrepresented as being the original software.
20//
21// 3. This notice may not be removed or altered from any source distribution.
22//
24
25
26#ifndef TGUI_CANVAS_OPENGL3_HPP
27#define TGUI_CANVAS_OPENGL3_HPP
28
29#include <TGUI/Backend/Renderer/OpenGL3/BackendTextureOpenGL3.hpp>
30
31#if TGUI_BUILD_AS_CXX_MODULE
32 import tgui;
33#else
34 #include <TGUI/Backend/Renderer/BackendRenderTarget.hpp>
35 #include <TGUI/Widgets/ClickableWidget.hpp>
36#endif
37
39
40TGUI_MODULE_EXPORT namespace tgui
41{
66 class TGUI_API CanvasOpenGL3 : public ClickableWidget
67 {
68 public:
69
70 using Ptr = std::shared_ptr<CanvasOpenGL3>;
71 using ConstPtr = std::shared_ptr<const CanvasOpenGL3>;
72
73 static constexpr const char StaticWidgetType[] = "CanvasOpenGL3";
74
75
83 CanvasOpenGL3(const char* typeName = StaticWidgetType, bool initRenderer = true);
84
85
90
91
95 CanvasOpenGL3(CanvasOpenGL3&& copy) = default;
96
97
101 ~CanvasOpenGL3() override;
102
103
107 CanvasOpenGL3& operator= (const CanvasOpenGL3& right);
108
109
113 CanvasOpenGL3& operator= (CanvasOpenGL3&& right) = default;
114
115
124 TGUI_NODISCARD static CanvasOpenGL3::Ptr create(const Layout2d& size = {"100%", "100%"});
125
126
135 TGUI_NODISCARD static CanvasOpenGL3::Ptr copy(const CanvasOpenGL3::ConstPtr& canvas);
136
137
144 void setSize(const Layout2d& size) override;
145 using Widget::setSize;
146
147
155 void draw(BackendRenderTarget& target, RenderStates states) const override;
156
157
164 TGUI_NODISCARD bool canGainFocus() const override;
165
166
174 unsigned int bindFramebuffer() const;
175
176
178 protected:
179
181 // Makes a copy of the widget
183 TGUI_NODISCARD Widget::Ptr clone() const override;
184
185
187 protected:
188
189 unsigned int m_textureId = 0;
190 unsigned int m_frameBuffer = 0;
191 Vector2u m_textureSize;
192 Vector2u m_usedTextureSize;
193 std::shared_ptr<BackendTextureOpenGL3> m_backendTexture = std::make_shared<BackendTextureOpenGL3>();
194 };
195}
196
198
199#endif // TGUI_CANVAS_OPENGL3_HPP
Base class for render targets.
Definition BackendRenderTarget.hpp:48
Definition CanvasOpenGL3.hpp:67
std::shared_ptr< const CanvasOpenGL3 > ConstPtr
Shared constant widget pointer.
Definition CanvasOpenGL3.hpp:71
CanvasOpenGL3(const CanvasOpenGL3 &copy)
Copy constructor.
static TGUI_NODISCARD CanvasOpenGL3::Ptr copy(const CanvasOpenGL3::ConstPtr &canvas)
Makes a copy of another canvas.
void draw(BackendRenderTarget &target, RenderStates states) const override
Draw the widget to a render target.
std::shared_ptr< CanvasOpenGL3 > Ptr
Shared widget pointer.
Definition CanvasOpenGL3.hpp:70
TGUI_NODISCARD bool canGainFocus() const override
Returns whether the widget can gain focus.
~CanvasOpenGL3() override
Destructor.
unsigned int bindFramebuffer() const
Binds the framebuffer of the canvas.
TGUI_NODISCARD Widget::Ptr clone() const override
Makes a copy of the widget if you don't know its exact type.
void setSize(const Layout2d &size) override
Changes the size of the widget.
CanvasOpenGL3(CanvasOpenGL3 &&copy)=default
Default move constructor.
static TGUI_NODISCARD CanvasOpenGL3::Ptr create(const Layout2d &size={"100%", "100%"})
Creates a new canvas widget.
Clickable widget.
Definition ClickableWidget.hpp:40
Class to store the position or size of a widget.
Definition Layout.hpp:289
std::shared_ptr< Widget > Ptr
Shared widget pointer.
Definition Widget.hpp:87
Namespace that contains all TGUI functions and classes.
Definition AbsoluteOrRelativeValue.hpp:39
States used for drawing.
Definition RenderStates.hpp:39