TGUI  1.0-beta
Loading...
Searching...
No Matches
CanvasGLES2.hpp
1
2//
3// TGUI - Texus' Graphical User Interface
4// Copyright (C) 2012-2022 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_GLES2_HPP
27#define TGUI_CANVAS_GLES2_HPP
28
29#include <TGUI/Config.hpp>
30#include <TGUI/Backend/Renderer/GLES2/BackendTextureGLES2.hpp>
31#include <TGUI/Backend/Renderer/BackendRenderTarget.hpp>
32#include <TGUI/Widgets/ClickableWidget.hpp>
33
35
36namespace tgui
37{
62 class TGUI_API CanvasGLES2 : public ClickableWidget
63 {
64 public:
65
66 using Ptr = std::shared_ptr<CanvasGLES2>;
67 using ConstPtr = std::shared_ptr<const CanvasGLES2>;
68
69 static constexpr const char StaticWidgetType[] = "CanvasGLES2";
70
71
79 CanvasGLES2(const char* typeName = StaticWidgetType, bool initRenderer = true);
80
81
86
87
91 CanvasGLES2(CanvasGLES2&& copy) = default;
92
93
97 ~CanvasGLES2() override;
98
99
103 CanvasGLES2& operator= (const CanvasGLES2& right);
104
105
109 CanvasGLES2& operator= (CanvasGLES2&& right) = default;
110
111
120 static CanvasGLES2::Ptr create(const Layout2d& size = {"100%", "100%"});
121
122
132
133
140 void setSize(const Layout2d& size) override;
141 using Widget::setSize;
142
143
151 void draw(BackendRenderTarget& target, RenderStates states) const override;
152
153
160 bool canGainFocus() const override;
161
162
170 unsigned int bindFramebuffer() const;
171
172
174 protected:
175
177 // Makes a copy of the widget
179 Widget::Ptr clone() const override;
180
181
183 protected:
184
185 unsigned int m_textureId = 0;
186 unsigned int m_frameBuffer = 0;
187 Vector2u m_textureSize;
188 Vector2u m_usedTextureSize;
189 std::shared_ptr<BackendTextureGLES2> m_backendTexture = std::make_shared<BackendTextureGLES2>();
190 };
191}
192
194
195#endif // TGUI_CANVAS_GLES2_HPP
Base class for render targets.
Definition: BackendRenderTarget.hpp:48
Definition: CanvasGLES2.hpp:63
Widget::Ptr clone() const override
Makes a copy of the widget if you don't know its exact type.
std::shared_ptr< const CanvasGLES2 > ConstPtr
Shared constant widget pointer.
Definition: CanvasGLES2.hpp:67
static CanvasGLES2::Ptr create(const Layout2d &size={"100%", "100%"})
Creates a new canvas widget.
CanvasGLES2(const CanvasGLES2 &copy)
Copy constructor.
bool canGainFocus() const override
Returns whether the widget can gain focus.
void draw(BackendRenderTarget &target, RenderStates states) const override
Draw the widget to a render target.
void setSize(const Layout2d &size) override
Changes the size of the widget.
static CanvasGLES2::Ptr copy(const CanvasGLES2::ConstPtr &canvas)
Makes a copy of another canvas.
std::shared_ptr< CanvasGLES2 > Ptr
Shared widget pointer.
Definition: CanvasGLES2.hpp:66
unsigned int bindFramebuffer() const
Binds the framebuffer of the canvas.
CanvasGLES2(CanvasGLES2 &&copy)=default
Default move constructor.
~CanvasGLES2() override
Destructor.
Clickable widget.
Definition: ClickableWidget.hpp:40
Class to store the position or size of a widget.
Definition: Layout.hpp:284
std::shared_ptr< Widget > Ptr
Shared widget pointer.
Definition: Widget.hpp:73
Namespace that contains all TGUI functions and classes.
Definition: AbsoluteOrRelativeValue.hpp:36
States used for drawing.
Definition: RenderStates.hpp:39