TGUI  1.0-alpha
CanvasOpenGL3.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_OPENGL3_HPP
27#define TGUI_CANVAS_OPENGL3_HPP
28
29#include <TGUI/Config.hpp>
30#include <TGUI/Backend/Renderer/OpenGL3/BackendTextureOpenGL3.hpp>
31#include <TGUI/Backend/Renderer/BackendRenderTarget.hpp>
32#include <TGUI/Widgets/ClickableWidget.hpp>
33
35
36namespace tgui
37{
62 class TGUI_API CanvasOpenGL3 : public ClickableWidget
63 {
64 public:
65
66 typedef std::shared_ptr<CanvasOpenGL3> Ptr;
67 typedef std::shared_ptr<const CanvasOpenGL3> ConstPtr;
68
69
77 CanvasOpenGL3(const char* typeName = "CanvasOpenGL3", bool initRenderer = true);
78
79
84
85
89 CanvasOpenGL3(CanvasOpenGL3&& copy) = default;
90
91
96
97
101 CanvasOpenGL3& operator= (const CanvasOpenGL3& right);
102
103
107 CanvasOpenGL3& operator= (CanvasOpenGL3&& right) = default;
108
109
118 static CanvasOpenGL3::Ptr create(Layout2d size = {"100%", "100%"});
119
120
130
131
138 void setSize(const Layout2d& size) override;
139 using Widget::setSize;
140
141
149 void draw(BackendRenderTarget& target, RenderStates states) const override;
150
151
158 bool canGainFocus() const override;
159
160
168 unsigned int bindFramebuffer() const;
169
170
172 protected:
173
175 // Makes a copy of the widget
177 Widget::Ptr clone() const override;
178
179
181 protected:
182
183 unsigned int m_textureId = 0;
184 unsigned int m_frameBuffer = 0;
185 Vector2u m_textureSize;
186 Vector2u m_usedTextureSize;
187 std::shared_ptr<BackendTextureOpenGL3> m_backendTexture;
188 };
189}
190
192
193#endif // TGUI_CANVAS_OPENGL3_HPP
Base class for render targets.
Definition: BackendRenderTarget.hpp:48
Definition: CanvasOpenGL3.hpp:63
static CanvasOpenGL3::Ptr create(Layout2d size={"100%", "100%"})
Creates a new canvas widget.
CanvasOpenGL3(const CanvasOpenGL3 &copy)
Copy constructor.
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:66
Widget::Ptr clone() const override
Makes a copy of the widget if you don't know its exact type.
~CanvasOpenGL3()
Destructor.
unsigned int bindFramebuffer() const
Binds the framebuffer of the canvas.
std::shared_ptr< const CanvasOpenGL3 > ConstPtr
Shared constant widget pointer.
Definition: CanvasOpenGL3.hpp:67
bool canGainFocus() const override
Returns whether the widget can gain focus.
void setSize(const Layout2d &size) override
Changes the size of the widget.
CanvasOpenGL3(CanvasOpenGL3 &&copy)=default
Default move constructor.
static CanvasOpenGL3::Ptr copy(CanvasOpenGL3::ConstPtr canvas)
Makes a copy of another canvas.
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
virtual void setSize(const Layout2d &size)
Changes the size of the widget.
Namespace that contains all TGUI functions and classes.
Definition: AbsoluteOrRelativeValue.hpp:36
States used for drawing.
Definition: RenderStates.hpp:39