TGUI 1.9.0
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
30#if !TGUI_BUILD_AS_CXX_MODULE
31 #include <TGUI/Backend/Renderer/BackendRenderTarget.hpp>
32 #include <TGUI/Widgets/CanvasBase.hpp>
33#endif
34
35#include <TGUI/extlibs/IncludeSDL.hpp>
36
38
39TGUI_MODULE_EXPORT namespace tgui
40{
63 class TGUI_API CanvasSDLGPU : public CanvasBase
64 {
65 public:
66
67 using Ptr = std::shared_ptr<CanvasSDLGPU>;
68 using ConstPtr = std::shared_ptr<const CanvasSDLGPU>;
69
70 static constexpr const char StaticWidgetType[] = "CanvasSDLGPU";
71
79 CanvasSDLGPU(const char* typeName = StaticWidgetType, bool initRenderer = true);
80
84 CanvasSDLGPU(const CanvasSDLGPU& copy);
85
89 CanvasSDLGPU(CanvasSDLGPU&& copy) = default;
90
94 CanvasSDLGPU& operator= (const CanvasSDLGPU& right);
95
99 CanvasSDLGPU& operator= (CanvasSDLGPU&& right) = default;
100
108 TGUI_NODISCARD static CanvasSDLGPU::Ptr create(const Layout2d& size = {"100%", "100%"});
109
117 TGUI_NODISCARD static CanvasSDLGPU::Ptr copy(const CanvasSDLGPU::ConstPtr& canvas);
118
124 void setSize(const Layout2d& size) override;
125 using Widget::setSize;
126
133 void draw(BackendRenderTarget& target, RenderStates states) const override;
134
144 TGUI_NODISCARD SDL_GPUTexture* getTexture()
145 {
146 return m_backendTexture->getInternalTexture();
147 }
148
150 protected:
151
153 // Makes a copy of the widget
155 TGUI_NODISCARD Widget::Ptr clone() const override;
156
158 protected:
159
160 Vector2u m_textureSize;
161 std::shared_ptr<BackendTextureSDLGPU> m_backendTexture;
162 };
163}
164
166
167#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:144
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:67
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:68
static constexpr const char StaticWidgetType[]
Type name of the widget.
Definition CanvasSDLGPU.hpp:70
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:323
std::shared_ptr< Widget > Ptr
Shared widget pointer.
Definition Widget.hpp:86
virtual void setSize(const Layout2d &size)
Changes the size of the widget.
Namespace that contains all TGUI functions and classes.
Definition AbsoluteOrRelativeValue.hpp:38
States used for drawing.
Definition RenderStates.hpp:38