TGUI 1.11
Loading...
Searching...
No Matches
CanvasSDLGPU.hpp
1
2//
3// TGUI - Texus' Graphical User Interface
4// Copyright (C) 2012-2025 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#ifndef TGUI_CANVAS_SDL_GPU_HPP
26#define TGUI_CANVAS_SDL_GPU_HPP
27
28#include <TGUI/Backend/Renderer/SDL_GPU/BackendTextureSDLGPU.hpp>
29#include <TGUI/Backend/Renderer/BackendRenderTarget.hpp>
30#include <TGUI/Widgets/CanvasBase.hpp>
31
32#include <TGUI/extlibs/IncludeSDL.hpp>
33
35
36namespace tgui
37{
60 class TGUI_API CanvasSDLGPU : public CanvasBase
61 {
62 public:
63
64 using Ptr = std::shared_ptr<CanvasSDLGPU>;
65 using ConstPtr = std::shared_ptr<const CanvasSDLGPU>;
66
67 static constexpr const char StaticWidgetType[] = "CanvasSDLGPU";
68
76 CanvasSDLGPU(const char* typeName = StaticWidgetType, bool initRenderer = true);
77
81 CanvasSDLGPU(const CanvasSDLGPU& copy);
82
86 CanvasSDLGPU(CanvasSDLGPU&& copy) = default;
87
91 CanvasSDLGPU& operator= (const CanvasSDLGPU& right);
92
96 CanvasSDLGPU& operator= (CanvasSDLGPU&& right) = default;
97
105 TGUI_NODISCARD static CanvasSDLGPU::Ptr create(const Layout2d& size = {"100%", "100%"});
106
114 TGUI_NODISCARD static CanvasSDLGPU::Ptr copy(const CanvasSDLGPU::ConstPtr& canvas);
115
121 void setSize(const Layout2d& size) override;
122 using Widget::setSize;
123
130 void draw(BackendRenderTarget& target, RenderStates states) const override;
131
141 TGUI_NODISCARD SDL_GPUTexture* getTexture()
142 {
143 return m_backendTexture->getInternalTexture();
144 }
145
147 protected:
148
150 // Makes a copy of the widget
152 TGUI_NODISCARD Widget::Ptr clone() const override;
153
155 protected:
156
157 Vector2u m_textureSize;
158 std::shared_ptr<BackendTextureSDLGPU> m_backendTexture;
159 };
160}
161
163
164#endif // TGUI_CANVAS_SDL_GPU_HPP
Base class for render targets.
Definition BackendRenderTarget.hpp:46
SDL_GPUTexture * getTexture()
Access the internal texture on which you can render.
Definition CanvasSDLGPU.hpp:141
void setSize(const Layout2d &size) override
Changes the size of the widget.
static CanvasSDLGPU::Ptr create(const Layout2d &size={"100%", "100%"})
Creates a new canvas widget.
std::shared_ptr< CanvasSDLGPU > Ptr
Shared widget pointer.
Definition CanvasSDLGPU.hpp:64
static CanvasSDLGPU::Ptr copy(const CanvasSDLGPU::ConstPtr &canvas)
Makes a copy of another canvas.
CanvasSDLGPU(const CanvasSDLGPU &copy)
Copy constructor.
void draw(BackendRenderTarget &target, RenderStates states) const override
Draw the widget to a render target.
std::shared_ptr< const CanvasSDLGPU > ConstPtr
Shared constant widget pointer.
Definition CanvasSDLGPU.hpp:65
static constexpr const char StaticWidgetType[]
Type name of the widget.
Definition CanvasSDLGPU.hpp:67
CanvasSDLGPU(CanvasSDLGPU &&copy)=default
Default move constructor.
Widget::Ptr clone() const override
Makes a copy of the widget if you don't know its exact type.
Class to store the position or size of a widget.
Definition Layout.hpp:321
std::shared_ptr< Widget > Ptr
Shared widget pointer.
Definition Widget.hpp:87
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:38