lxgui
Public Types | Public Member Functions | Protected Attributes | List of all members
lxgui::gui::vertex_cache Class Referenceabstract

An object representing cached vertex data on the GPU. More...

#include <gui_vertex_cache.hpp>

Inheritance diagram for lxgui::gui::vertex_cache:
lxgui::gui::gl::vertex_cache lxgui::gui::sfml::vertex_cache

Public Types

enum class  type { triangles , quads }
 The type of vertex data contained in a vertex_cache. More...
 

Public Member Functions

 vertex_cache (type t)
 Constructor. More...
 
virtual ~vertex_cache ()=default
 Destructor. More...
 
 vertex_cache (const vertex_cache &)=delete
 Non-copiable. More...
 
 vertex_cache (vertex_cache &&)=delete
 Non-movable. More...
 
vertex_cacheoperator= (const vertex_cache &)=delete
 Non-copiable. More...
 
vertex_cacheoperator= (vertex_cache &&)=delete
 Non-movable. More...
 
virtual void update (const vertex *vertex_data, std::size_t num_vertex)=0
 Update the data stored in the cache to form new triangles. More...
 
std::size_t get_vertex_count () const
 Returns the number of vertices stored in this cache. More...
 

Protected Attributes

type type_ = type::triangles
 
std::size_t num_vertex_ = 0
 

Detailed Description

An object representing cached vertex data on the GPU.

A vertex cache stores vertices and indices that can be used to draw any shape on the screen. If the type is TRIANGLES, each group of 3 vertices forms a triangle, while if the type is QUADS, each group of 4 vertices forms a quad.

Using this class enables more efficient rendering of large groups of sprites or quads that share the same material (texture). This is especially true if the data to render does not change often.

A vertex cache can be rendered with gui::renderer::render_vertex_cache().

Note
This is an abstract class that must be inherited from and created by the corresponding gui::renderer.

Definition at line 29 of file gui_vertex_cache.hpp.

Member Enumeration Documentation

◆ type

The type of vertex data contained in a vertex_cache.

Enumerator
triangles 
quads 

3 vertices per element

4 vertices per element

Definition at line 32 of file gui_vertex_cache.hpp.

Constructor & Destructor Documentation

◆ vertex_cache() [1/3]

lxgui::gui::vertex_cache::vertex_cache ( type  t)
explicit

Constructor.

Parameters
tThe type of data this cache will hold

A default constructed vertex cache holds no data. Use update() to store vertices to be rendered.

Definition at line 5 of file gui_vertex_cache.cpp.

◆ ~vertex_cache()

virtual lxgui::gui::vertex_cache::~vertex_cache ( )
virtualdefault

Destructor.

Reimplemented in lxgui::gui::gl::vertex_cache.

◆ vertex_cache() [2/3]

lxgui::gui::vertex_cache::vertex_cache ( const vertex_cache )
delete

Non-copiable.

◆ vertex_cache() [3/3]

lxgui::gui::vertex_cache::vertex_cache ( vertex_cache &&  )
delete

Non-movable.

Member Function Documentation

◆ get_vertex_count()

std::size_t lxgui::gui::vertex_cache::get_vertex_count ( ) const
inline

Returns the number of vertices stored in this cache.

Returns
The number of vertices stored in this cache

Definition at line 73 of file gui_vertex_cache.hpp.

◆ operator=() [1/2]

vertex_cache& lxgui::gui::vertex_cache::operator= ( const vertex_cache )
delete

Non-copiable.

◆ operator=() [2/2]

vertex_cache& lxgui::gui::vertex_cache::operator= ( vertex_cache &&  )
delete

Non-movable.

◆ update()

virtual void lxgui::gui::vertex_cache::update ( const vertex vertex_data,
std::size_t  num_vertex 
)
pure virtual

Update the data stored in the cache to form new triangles.

Parameters
vertex_dataThe vertices to cache
num_vertexThe number of vertices to cache
Note
If the type if TRIANGLES, num_vertex must be a multiple of 3. If the type if QUADS, num_vertex must be a multiple of 4.

Implemented in lxgui::gui::sfml::vertex_cache, and lxgui::gui::gl::vertex_cache.

Member Data Documentation

◆ num_vertex_

std::size_t lxgui::gui::vertex_cache::num_vertex_ = 0
protected

Definition at line 79 of file gui_vertex_cache.hpp.

◆ type_

type lxgui::gui::vertex_cache::type_ = type::triangles
protected

Definition at line 78 of file gui_vertex_cache.hpp.


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