TGUI 1.9.0
Loading...
Searching...
No Matches

Render target implementation that uses SDL3's GPU API. More...

#include <TGUI/Backend/Renderer/SDL_GPU/BackendRenderTargetSDLGPU.hpp>

Inheritance diagram for tgui::BackendRenderTargetSDLGPU:
tgui::BackendRenderTarget

Classes

struct  DrawCommand
 

Public Member Functions

 BackendRenderTargetSDLGPU (SDL_GPUDevice *device, SDL_GPUTextureFormat swapchainTextureFormat)
 Constructor.
 
 ~BackendRenderTargetSDLGPU ()
 Descructor.
 
void setClearColor (const Color &color) override
 Select the color that will be used by clearScreen.
 
void clearScreen () override
 Clears the screen, called at the beginning of each frame when gui.mainLoop() is called.
 
void setView (FloatRect view, FloatRect viewport, Vector2f targetSize) override
 Informs the render target about which part of the window is used for rendering.
 
void drawGui (const std::shared_ptr< RootContainer > &) override
 This function is not used by this backend, use drawGui(SDL_GPURenderPass*) instead.
 
bool prepareDrawGui (const std::shared_ptr< RootContainer > &root, SDL_GPUCommandBuffer *cmdBuffer, SDL_GPUCopyPass *copyPass=nullptr)
 Prepares drawing the gui and all of its widgets.
 
void drawGui (SDL_GPURenderPass *renderPass)
 Draws the gui and all of its widgets.
 
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) override
 Draws a vertex array. This is called by the other draw functions.
 
- Public Member Functions inherited from tgui::BackendRenderTarget
 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 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 drawTextOutline (const RenderStates &states, const Text &text)
 Draws only the outline of some text.
 
virtual void drawTextWithoutOutline (const RenderStates &states, const Text &text)
 Draws some text, but without rendering its outline.
 
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.
 
Vector2f getPixelsPerPoint () const
 Returns the current mapping between the screen pixels and the points in the current view.
 

Protected Member Functions

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

Protected Attributes

SDL_GPUDevice * m_device = nullptr
 
SDL_GPUGraphicsPipeline * m_pipeline = nullptr
 
SDL_GPUSampler * m_samplerNearest = nullptr
 
SDL_GPUSampler * m_samplerLinear = nullptr
 
std::unique_ptr< BackendTextureSDLGPUm_emptyTexture
 
Transform m_projectionTransform
 
std::vector< Vertexm_vertices
 
std::vector< unsigned int > m_indices
 
SDL_Rect m_clipRect
 
std::vector< DrawCommandm_drawCommands
 
SDL_GPUBuffer * m_vertexBuffer = nullptr
 
SDL_GPUBuffer * m_indexBuffer = nullptr
 
- Protected Attributes inherited from tgui::BackendRenderTarget
FloatRect m_viewRect
 
FloatRect m_viewport
 
Vector2f m_targetSize
 
std::vector< std::pair< FloatRect, FloatRect > > m_clipLayers
 
Vector2f m_pixelsPerPoint = {1, 1}
 

Detailed Description

Render target implementation that uses SDL3's GPU API.

Constructor & Destructor Documentation

◆ BackendRenderTargetSDLGPU()

tgui::BackendRenderTargetSDLGPU::BackendRenderTargetSDLGPU ( SDL_GPUDevice * device,
SDL_GPUTextureFormat swapchainTextureFormat )

Constructor.

Parameters
deviceDevice used for rendering
swapchainTextureFormatTexture format returned by SDL_GetGPUSwapchainTextureFormat(device, window)

Member Function Documentation

◆ clearScreen()

void tgui::BackendRenderTargetSDLGPU::clearScreen ( )
overridevirtual

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

Implements tgui::BackendRenderTarget.

◆ drawGui() [1/2]

void tgui::BackendRenderTargetSDLGPU::drawGui ( const std::shared_ptr< RootContainer > & )
inlineoverridevirtual

This function is not used by this backend, use drawGui(SDL_GPURenderPass*) instead.

Implements tgui::BackendRenderTarget.

◆ drawGui() [2/2]

void tgui::BackendRenderTargetSDLGPU::drawGui ( SDL_GPURenderPass * renderPass)

Draws the gui and all of its widgets.

Parameters
rootRoot container that holds all widgets in the gui
cmdBufferCommand buffer to add rendering instructions to
renderPassActive render pass
Warning
prepareDrawGui must have been called before calling this function
Bound GraphicsPipeline, VertexBuffers, IndexBuffer and FragmentSamplers will be changed by this function
Scissor rectangle is changed by this function to contain the entire window
Viewport is changed by this function

◆ drawVertexArray()

void tgui::BackendRenderTargetSDLGPU::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 )
overridevirtual

Draws a vertex array. This is called by the other draw functions.

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

Implements tgui::BackendRenderTarget.

◆ prepareDrawGui()

bool tgui::BackendRenderTargetSDLGPU::prepareDrawGui ( const std::shared_ptr< RootContainer > & root,
SDL_GPUCommandBuffer * cmdBuffer,
SDL_GPUCopyPass * copyPass = nullptr )

Prepares drawing the gui and all of its widgets.

Parameters
rootRoot container that holds all widgets in the gui
cmdBufferCommand buffer to add rendering instructions to
copyPassOptional active copy pass
Returns
True if there weren't any errors, false if something went wrong (e.g. could not create or upload buffer)
Warning
If copyPass is a nullptr then this function uses a new SDL_GPUCopyPass internally, there should be no active pass when calling this function in this case.

◆ setClearColor()

void tgui::BackendRenderTargetSDLGPU::setClearColor ( const Color & color)
overridevirtual

Select the color that will be used by clearScreen.

Parameters
colorBackground color of the window

Implements tgui::BackendRenderTarget.

◆ setView()

void tgui::BackendRenderTargetSDLGPU::setView ( FloatRect view,
FloatRect viewport,
Vector2f targetSize )
overridevirtual

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 from tgui::BackendRenderTarget.

◆ updateClipping()

void tgui::BackendRenderTargetSDLGPU::updateClipping ( FloatRect clipRect,
FloatRect clipViewport )
overrideprotectedvirtual

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.

Implements tgui::BackendRenderTarget.


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