TGUI  1.0-alpha
tgui::BackendRenderTargetOpenGL3 Class Reference

Render target implementation that makes use of modern OpenGL. More...

#include <TGUI/Backend/Renderer/OpenGL3/BackendRenderTargetOpenGL3.hpp>

Inheritance diagram for tgui::BackendRenderTargetOpenGL3:
tgui::BackendRenderTarget

Public Member Functions

 BackendRenderTargetOpenGL3 ()
 Default constructor.
 
 ~BackendRenderTargetOpenGL3 ()
 Destructor.
 
void setClearColor (const Color &color) override
 Select the color that will be used by clearScreen. This will be called when gui.mainLoop() is called. More...
 
void clearScreen () override
 Clears the screen, called at the beginning of each frame when gui.mainLoop() is called. More...
 
void setView (FloatRect view, FloatRect viewport, Vector2f targetSize) override
 Informs the render target about which part of the window is used for rendering. More...
 
void drawGui (const std::shared_ptr< RootContainer > &root) override
 Draws the gui and all of its widgets. More...
 
void drawVertexArray (const RenderStates &states, const Vertex *vertices, std::size_t vertexCount, const 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. More...
 
- Public Member Functions inherited from tgui::BackendRenderTarget
virtual ~BackendRenderTarget ()=default
 Virtual destructor.
 
virtual void setClearColor (const tgui::Color &color)=0
 Select the color that will be used by clearScreen. More...
 
virtual void clearScreen ()=0
 Clears the screen, called at the beginning of each frame when gui.mainLoop() is called. More...
 
virtual void setView (FloatRect view, FloatRect viewport, Vector2f targetSize)
 Informs the render target about which part of the window is used for rendering. More...
 
virtual void drawGui (const std::shared_ptr< RootContainer > &root)=0
 Draws the gui and all of its widgets. More...
 
virtual void drawWidget (const RenderStates &states, const std::shared_ptr< Widget > &widget)
 Draws a widget, if the widget is visible. More...
 
virtual void addClippingLayer (const RenderStates &states, FloatRect rect)
 Adds another clipping region. More...
 
virtual void removeClippingLayer ()
 Removes the last added clipping region. More...
 
virtual void drawBorders (const RenderStates &states, const Borders &borders, Vector2f size, Color color)
 Draws borders inside a provided rectangle. More...
 
virtual void drawFilledRect (const RenderStates &states, Vector2f size, Color color)
 Draws a colored rectangle. More...
 
virtual void drawSprite (const RenderStates &states, const Sprite &sprite)
 Draws a texture. More...
 
virtual void drawText (const RenderStates &states, const Text &text)
 Draws some text. More...
 
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) More...
 
virtual void drawCircle (const RenderStates &states, float size, const Color &backgroundColor, float borderThickness=0, const Color &borderColor={})
 Draws a circle. More...
 
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. More...
 
virtual void drawVertexArray (const RenderStates &states, const Vertex *vertices, std::size_t vertexCount, const 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. More...
 

Protected Member Functions

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

Protected Attributes

unsigned int m_shaderProgram = 0
 
unsigned int m_vertexArray = 0
 
unsigned int m_vertexBuffer = 0
 
unsigned int m_indexBuffer = 0
 
std::size_t m_vertexBufferSize = 0
 
std::size_t m_indexBufferSize = 0
 
std::unique_ptr< BackendTextureOpenGL3m_emptyTexture
 
std::shared_ptr< BackendTextureOpenGL3m_currentTexture
 
Transform m_projectionTransform
 
int m_projectionMatrixShaderUniformLocation = 0
 
- 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 makes use of modern OpenGL.

Member Function Documentation

◆ clearScreen()

void tgui::BackendRenderTargetOpenGL3::clearScreen ( )
overridevirtual

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

Implements tgui::BackendRenderTarget.

◆ drawGui()

void tgui::BackendRenderTargetOpenGL3::drawGui ( const std::shared_ptr< RootContainer > &  root)
overridevirtual

Draws the gui and all of its widgets.

Parameters
rootRoot container that holds all widgets in the gui

GL_BLEND, GL_DEPTH_TEST, GL_CULL_FACE and GL_SCISSOR_TEST are temporarily changed but restored at the end of this function

Implements tgui::BackendRenderTarget.

◆ drawVertexArray()

void tgui::BackendRenderTargetOpenGL3::drawVertexArray ( const RenderStates states,
const Vertex vertices,
std::size_t  vertexCount,
const 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.

◆ setClearColor()

void tgui::BackendRenderTargetOpenGL3::setClearColor ( const Color color)
overridevirtual

Select the color that will be used by clearScreen. This will be called when gui.mainLoop() is called.

Parameters
colorBackground color of the window

Implements tgui::BackendRenderTarget.

◆ setView()

void tgui::BackendRenderTargetOpenGL3::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::BackendRenderTargetOpenGL3::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: