TGUI  1.5
Loading...
Searching...
No Matches
tgui::BackendRenderTarget Class Referenceabstract

Base class for render targets. More...

#include <TGUI/Backend/Renderer/BackendRenderTarget.hpp>

Inheritance diagram for tgui::BackendRenderTarget:
tgui::BackendRenderTargetGLES2 tgui::BackendRenderTargetOpenGL3 tgui::BackendRenderTargetRaylib tgui::BackendRenderTargetSDL tgui::BackendRenderTargetSFML

Public Member Functions

 BackendRenderTarget (const BackendRenderTarget &)=delete
 
 BackendRenderTarget (BackendRenderTarget &&)=delete
 
BackendRenderTargetoperator= (const BackendRenderTarget &)=delete
 
BackendRenderTargetoperator= (BackendRenderTarget &&)=delete
 
 BackendRenderTarget ()=default
 Default constructor.
 
virtual ~BackendRenderTarget ()=default
 Virtual destructor.
 
virtual void setClearColor (const Color &color)=0
 Select the color that will be used by clearScreen.
 
virtual void clearScreen ()=0
 Clears the screen, called at the beginning of each frame when gui.mainLoop() is called.
 
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 drawGui (const std::shared_ptr< RootContainer > &root)=0
 Draws the gui and all of its widgets.
 
virtual void drawWidget (const RenderStates &states, const std::shared_ptr< Widget > &widget)
 Draws a widget, if the widget is visible.
 
virtual void addClippingLayer (const RenderStates &states, FloatRect rect)
 Adds another clipping region.
 
virtual void removeClippingLayer ()
 Removes the last added clipping region.
 
virtual void drawBorders (const RenderStates &states, const Borders &borders, Vector2f size, Color color)
 Draws borders inside a provided rectangle.
 
virtual void drawFilledRect (const RenderStates &states, Vector2f size, Color color)
 Draws a colored rectangle.
 
virtual void drawSprite (const RenderStates &states, const Sprite &sprite)
 Draws a texture.
 
virtual void drawText (const RenderStates &states, const Text &text)
 Draws some text.
 
virtual void drawTriangle (const RenderStates &states, const Vertex &point1, const Vertex &point2, const Vertex &point3)
 Draws a single triangles (using the color that is specified in the vertices)
 
virtual void drawCircle (const RenderStates &states, float size, const Color &backgroundColor, float borderThickness=0, const Color &borderColor={})
 Draws a circle.
 
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 drawVertexArray (const RenderStates &states, const Vertex *vertices, std::size_t vertexCount, const unsigned int *indices, std::size_t indexCount, const std::shared_ptr< BackendTexture > &texture)=0
 Draws a vertex array. This is called by the other draw functions when they are not overriden.
 
TGUI_NODISCARD Vector2f getPixelsPerPoint () const
 Returns the current mapping between the screen pixels and the points in the current view.
 

Protected Member Functions

virtual void updateClipping (FloatRect clipRect, FloatRect clipViewport)=0
 Called from addClippingLayer and removeClippingLayer to apply the clipping.
 

Protected Attributes

FloatRect m_viewRect
 
FloatRect m_viewport
 
Vector2f m_targetSize
 
std::vector< std::pair< FloatRect, FloatRect > > m_clipLayers
 
Vector2f m_pixelsPerPoint = {1, 1}
 

Detailed Description

Base class for render targets.

Member Function Documentation

◆ addClippingLayer()

virtual void tgui::BackendRenderTarget::addClippingLayer ( const RenderStates & states,
FloatRect rect )
virtual

Adds another clipping region.

Parameters
statesRender states to use for drawing
rectThe clipping region

If multiple clipping regions were added then contents is only shown in the intersection of all regions.

Warning
Every call to addClippingLayer must have a matching call to removeClippingLayer.

◆ clearScreen()

virtual void tgui::BackendRenderTarget::clearScreen ( )
pure virtual

Clears the screen, called at the beginning of each frame when gui.mainLoop() is called.

Implemented in tgui::BackendRenderTargetGLES2, tgui::BackendRenderTargetOpenGL3, tgui::BackendRenderTargetRaylib, tgui::BackendRenderTargetSDL, and tgui::BackendRenderTargetSFML.

◆ drawBorders()

virtual void tgui::BackendRenderTarget::drawBorders ( const RenderStates & states,
const Borders & borders,
Vector2f size,
Color color )
virtual

Draws borders inside a provided rectangle.

Parameters
statesRender states to use for drawing
bordersThe size of the borders on each side
sizeThe size of the rectangle in which borders will be drawn
colorColor of the borders

◆ drawCircle()

virtual void tgui::BackendRenderTarget::drawCircle ( const RenderStates & states,
float size,
const Color & backgroundColor,
float borderThickness = 0,
const Color & borderColor = {} )
virtual

Draws a circle.

Parameters
statesRender states to use for drawing
sizeDiameter of the circle
backgroundColorColor to fill the circle with
borderThicknessThickness of the border to draw around the circle (outside given size if thickness is positive)
borderColorColor of the border, if borderThickness differs from 0

◆ drawFilledRect()

virtual void tgui::BackendRenderTarget::drawFilledRect ( const RenderStates & states,
Vector2f size,
Color color )
virtual

Draws a colored rectangle.

Parameters
statesRender states to use for drawing
sizeSize of the rectangle
colorColor of the rectangle

◆ drawGui()

virtual void tgui::BackendRenderTarget::drawGui ( const std::shared_ptr< RootContainer > & root)
pure virtual

Draws the gui and all of its widgets.

Parameters
rootRoot container that holds all widgets in the gui

Implemented in tgui::BackendRenderTargetGLES2, tgui::BackendRenderTargetOpenGL3, tgui::BackendRenderTargetRaylib, tgui::BackendRenderTargetSDL, and tgui::BackendRenderTargetSFML.

◆ drawRoundedRectangle()

virtual void tgui::BackendRenderTarget::drawRoundedRectangle ( const RenderStates & states,
const Vector2f & size,
const Color & backgroundColor,
float radius,
const Borders & borders = {0},
const Color & borderColor = Color::Black )
virtual

Draws a rounded rectangle.

Parameters
statesRender states to use for drawing
sizeSize of the rectangle (includes borders)
backgroundColorFill color of the rectangle
radiusRadius of the rounded corners
bordersOptional borders on the sides of the rectangle (must be the same on all sides)
borderColorColor of the borders

◆ drawSprite()

virtual void tgui::BackendRenderTarget::drawSprite ( const RenderStates & states,
const Sprite & sprite )
virtual

Draws a texture.

Parameters
statesRender states to use for drawing
spriteImage to draw

Reimplemented in tgui::BackendRenderTargetSFML.

◆ drawText()

virtual void tgui::BackendRenderTarget::drawText ( const RenderStates & states,
const Text & text )
virtual

Draws some text.

Parameters
statesRender states to use for drawing
textText to draw

◆ drawTriangle()

virtual void tgui::BackendRenderTarget::drawTriangle ( const RenderStates & states,
const Vertex & point1,
const Vertex & point2,
const Vertex & point3 )
virtual

Draws a single triangles (using the color that is specified in the vertices)

Parameters
statesRender states to use for drawing
point1First point of the triangle
point2Second point of the triangle
point3Third point of the triangle

To draw multiple triangles at once, optionally with a texture, use the drawVertexArray function.

◆ drawVertexArray()

virtual void tgui::BackendRenderTarget::drawVertexArray ( const RenderStates & states,
const Vertex * vertices,
std::size_t vertexCount,
const unsigned int * indices,
std::size_t indexCount,
const std::shared_ptr< BackendTexture > & texture )
pure virtual

Draws a vertex array. This is called by the other draw functions when they are not overriden.

Parameters
statesRender states to use for drawing
verticesPointer to first element in array of vertices
vertexCountAmount of elements in the vertex array
indicesPointer to first element in array of indices
indexCountAmount of elements in the indices array
textureTexture to use, or nullptr when drawing colored triangles

Implemented in tgui::BackendRenderTargetGLES2, tgui::BackendRenderTargetOpenGL3, tgui::BackendRenderTargetRaylib, tgui::BackendRenderTargetSDL, and tgui::BackendRenderTargetSFML.

◆ drawWidget()

virtual void tgui::BackendRenderTarget::drawWidget ( const RenderStates & states,
const std::shared_ptr< Widget > & widget )
virtual

Draws a widget, if the widget is visible.

Parameters
statesRender states to use for drawing
widgetThe widget to draw

◆ getPixelsPerPoint()

TGUI_NODISCARD Vector2f tgui::BackendRenderTarget::getPixelsPerPoint ( ) const

Returns the current mapping between the screen pixels and the points in the current view.

Returns
Pixels per point

Example when rounding rendering to the nearest pixel:

states.transform.roundPosition(target.getPixelsPerPoint());
Since
TGUI 1.4

◆ removeClippingLayer()

virtual void tgui::BackendRenderTarget::removeClippingLayer ( )
virtual

Removes the last added clipping region.

Warning
The addClippingLayer function must have been called before calling this function.

◆ setClearColor()

virtual void tgui::BackendRenderTarget::setClearColor ( const Color & color)
pure virtual

Select the color that will be used by clearScreen.

Parameters
colorBackground color of the window

Implemented in tgui::BackendRenderTargetGLES2, tgui::BackendRenderTargetOpenGL3, tgui::BackendRenderTargetRaylib, tgui::BackendRenderTargetSDL, and tgui::BackendRenderTargetSFML.

◆ setView()

virtual void tgui::BackendRenderTarget::setView ( FloatRect view,
FloatRect viewport,
Vector2f targetSize )
virtual

Informs the render target about which part of the window is used for rendering.

Parameters
viewDefines which part of the gui is being shown
viewportDefines which part of the window is being rendered to
targetSizeSize of the window

Reimplemented in tgui::BackendRenderTargetGLES2, tgui::BackendRenderTargetOpenGL3, tgui::BackendRenderTargetRaylib, and tgui::BackendRenderTargetSDL.

◆ updateClipping()

virtual void tgui::BackendRenderTarget::updateClipping ( FloatRect clipRect,
FloatRect clipViewport )
protectedpure virtual

Called from addClippingLayer and removeClippingLayer to apply the clipping.

Parameters
clipRectView rectangle to apply
clipViewportViewport to apply

Both rectangles may be empty when nothing that will be drawn is going to be visible.

Implemented in tgui::BackendRenderTargetGLES2, tgui::BackendRenderTargetOpenGL3, tgui::BackendRenderTargetRaylib, tgui::BackendRenderTargetSDL, and tgui::BackendRenderTargetSFML.


The documentation for this class was generated from the following file: