25#ifndef TGUI_CANVAS_SFML_HPP
26#define TGUI_CANVAS_SFML_HPP
28#include <TGUI/Backend/Renderer/SFML-Graphics/BackendTextureSFML.hpp>
30#if !TGUI_BUILD_AS_CXX_MODULE
31 #include <TGUI/Backend/Renderer/BackendRenderTarget.hpp>
32 #include <TGUI/Widgets/CanvasBase.hpp>
35#include <SFML/Graphics/RenderTexture.hpp>
36#include <SFML/Graphics/Sprite.hpp>
40TGUI_MODULE_EXPORT
namespace tgui
72 using Ptr = std::shared_ptr<CanvasSFML>;
73 using ConstPtr = std::shared_ptr<const CanvasSFML>;
75 static constexpr const char StaticWidgetType[] =
"CanvasSFML";
84 CanvasSFML(
const char* typeName = StaticWidgetType,
bool initRenderer =
true);
130 using Widget::setSize;
152 TGUI_NODISCARD
const sf::View&
getView()
const;
188 void draw(
const sf::Drawable& drawable,
const sf::RenderStates& states = {});
198 void draw(
const sf::Vertex* vertices, std::size_t vertexCount,
199 sf::PrimitiveType type,
const sf::RenderStates& states = {});
236 return m_renderTexture;
251 sf::RenderTexture m_renderTexture;
Base class for render targets.
Definition BackendRenderTarget.hpp:46
This class is used as base class for the backend-specific canvas widgets.
Definition CanvasBase.hpp:38
CanvasSFML provides a way to directly render SFML contents on a widget.
Definition CanvasSFML.hpp:69
static CanvasSFML::Ptr create(const Layout2d &size={"100%", "100%"})
Creates a new canvas widget.
IntRect getViewport() const
Get the viewport of the currently applied view, applied to this canvas.
void draw(const Sprite &sprite, const RenderStates &states={})
Draws a TGUI sprite to the canvas.
CanvasSFML(const CanvasSFML ©)
Copy constructor.
void setView(const sf::View &view)
Change the current active view.
static CanvasSFML::Ptr copy(const CanvasSFML::ConstPtr &canvas)
Makes a copy of another canvas.
void setSize(const Layout2d &size) override
Changes the size of the widget.
sf::View getDefaultView() const
Get the default view of the canvas.
sf::RenderTexture & getRenderTexture()
Access the internal render texture that the canvas widget uses to draw on.
Definition CanvasSFML.hpp:234
std::shared_ptr< CanvasSFML > Ptr
Shared widget pointer.
Definition CanvasSFML.hpp:72
void draw(const sf::Vertex *vertices, std::size_t vertexCount, sf::PrimitiveType type, const sf::RenderStates &states={})
Draws primitives defined by an array of vertices.
const sf::View & getView() const
Get the view currently in use in the canvas.
void draw(const sf::Drawable &drawable, const sf::RenderStates &states={})
Draws a drawable object to the canvas.
void clear(Color color=Color::Black)
Clears the entire canvas with a single color.
void display()
Updates the contents of the canvas.
CanvasSFML(CanvasSFML &©) noexcept
Move constructor.
Widget::Ptr clone() const override
Makes a copy of the widget if you don't know its exact type.
std::shared_ptr< const CanvasSFML > ConstPtr
Shared constant widget pointer.
Definition CanvasSFML.hpp:73
void draw(BackendRenderTarget &target, RenderStates states) const override
Draw the widget to a render target.
Wrapper for colors.
Definition Color.hpp:73
Class to store the position or size of a widget.
Definition Layout.hpp:323
Namespace that contains all TGUI functions and classes.
Definition AbsoluteOrRelativeValue.hpp:38
States used for drawing.
Definition RenderStates.hpp:38