TGUI  0.9.5
Loading...
Searching...
No Matches
BackendRenderTarget.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_BACKEND_RENDER_TARGET_HPP
27#define TGUI_BACKEND_RENDER_TARGET_HPP
28
29#include <TGUI/Rect.hpp>
30#include <TGUI/Color.hpp>
31#include <TGUI/Sprite.hpp>
32#include <TGUI/Text.hpp>
33#include <TGUI/Outline.hpp>
34#include <TGUI/RenderStates.hpp>
35
37
38namespace tgui
39{
40 class Widget;
41 class RootContainer;
42
43
48 {
49 public:
50
54 virtual ~BackendRenderTargetBase() = default;
55
56#ifndef TGUI_REMOVE_DEPRECATED_CODE
63 TGUI_DEPRECATED("Use setView(view, viewport, targetSize) instead") virtual void setView(FloatRect view, FloatRect viewport);
64#endif
65
73 virtual void setView(FloatRect view, FloatRect viewport, Vector2f targetSize);
74
75
81 virtual void drawGui(const std::shared_ptr<RootContainer>& root) = 0;
82
83
90 virtual void drawWidget(const RenderStates& states, const std::shared_ptr<Widget>& widget);
91
92
103 virtual void addClippingLayer(const RenderStates& states, FloatRect rect);
104
105
111 virtual void removeClippingLayer();
112
113
122 virtual void drawBorders(const RenderStates& states, const Borders& borders, Vector2f size, Color color);
123
124
132 virtual void drawFilledRect(const RenderStates& states, Vector2f size, Color color);
133
134
141 virtual void drawSprite(const RenderStates& states, const Sprite& sprite) = 0;
142
143
150 virtual void drawText(const RenderStates& states, const Text& text) = 0;
151
152
164 virtual void drawTriangles(const RenderStates& states, const Vertex* vertices, std::size_t vertexCount, const int* indices = nullptr, std::size_t indexCount = 0) = 0;
165
166
176 void drawTriangles(const RenderStates& states, std::initializer_list<Vertex> vertices, std::initializer_list<int> indices = {});
177
178
188 virtual void drawCircle(const RenderStates& states, float size, const Color& backgroundColor, float borderThickness = 0, const Color& borderColor = {});
189
190
201 virtual void drawRoundedRectangle(const RenderStates& states, const Vector2f& size, const Color& backgroundColor, float radius,
202 const Borders& borders = {0}, const Color& borderColor = Color::Black);
203
205 protected:
206
215#ifdef TGUI_NEXT
216 virtual void updateClipping(FloatRect clipRect, FloatRect clipViewport) = 0;
217#else
218 virtual void updateClipping(FloatRect clipRect, FloatRect clipViewport) { (void)clipRect; (void)clipViewport; };
219#endif
220
221
223 protected:
224
225 FloatRect m_viewRect;
226 FloatRect m_viewport;
227 Vector2f m_targetSize;
228
229 std::vector<std::pair<FloatRect, FloatRect>> m_clipLayers;
230 };
231
233}
234
236
237#endif // TGUI_BACKEND_RENDER_TARGET_HPP
Base class for render targets.
Definition BackendRenderTarget.hpp:48
virtual void addClippingLayer(const RenderStates &states, FloatRect rect)
Adds another clipping region.
virtual void drawTriangles(const RenderStates &states, const Vertex *vertices, std::size_t vertexCount, const int *indices=nullptr, std::size_t indexCount=0)=0
Draws one or more triangles (using the color that is specified in the vertices)
virtual void drawFilledRect(const RenderStates &states, Vector2f size, Color color)
Draws a colored rectangle.
virtual void drawRoundedRectangle(const RenderStates &states, const Vector2f &size, const Color &backgroundColor, float radius, const Borders &borders={0}, const Color &borderColor=Color::Black)
Draws a rounded rectangle.
virtual void setView(FloatRect view, FloatRect viewport, Vector2f targetSize)
Informs the render target about which part of the window is used for rendering.
virtual void drawWidget(const RenderStates &states, const std::shared_ptr< Widget > &widget)
Draws a widget, if the widget is visible.
virtual void drawCircle(const RenderStates &states, float size, const Color &backgroundColor, float borderThickness=0, const Color &borderColor={})
Draws a circle.
virtual void updateClipping(FloatRect clipRect, FloatRect clipViewport)
Called from addClippingLayer and removeClippingLayer to apply the clipping.
Definition BackendRenderTarget.hpp:218
virtual void drawText(const RenderStates &states, const Text &text)=0
Draws some text.
virtual void removeClippingLayer()
Removes the last added clipping region.
virtual ~BackendRenderTargetBase()=default
Virtual destructor.
virtual void drawGui(const std::shared_ptr< RootContainer > &root)=0
Draws the gui and all of its widgets.
virtual void drawSprite(const RenderStates &states, const Sprite &sprite)=0
Draws a texture.
void drawTriangles(const RenderStates &states, std::initializer_list< Vertex > vertices, std::initializer_list< int > indices={})
Draws one or more triangles (using the color that is specified in the vertices)
virtual void drawBorders(const RenderStates &states, const Borders &borders, Vector2f size, Color color)
Draws borders inside a provided rectangle.
Wrapper for colors.
Definition Color.hpp:63
Definition Outline.hpp:39
Definition Sprite.hpp:49
Definition Text.hpp:44
Namespace that contains all TGUI functions and classes.
Definition AbsoluteOrRelativeValue.hpp:36
States used for drawing.
Definition RenderStates.hpp:39
Definition Vertex.hpp:37