lxgui
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
lxgui::gui::renderer Class Referenceabstract

Abstract type for implementation specific management. More...

#include <gui_renderer.hpp>

Inheritance diagram for lxgui::gui::renderer:
lxgui::gui::gl::renderer lxgui::gui::sdl::renderer lxgui::gui::sfml::renderer

Public Member Functions

 renderer ()=default
 Constructor. More...
 
 renderer (const renderer &)=delete
 Non-copiable. More...
 
 renderer (renderer &&)=delete
 Non-movable. More...
 
rendereroperator= (const renderer &)=delete
 Non-copiable. More...
 
rendereroperator= (renderer &&)=delete
 Non-movable. More...
 
virtual ~renderer ()=default
 Destructor. More...
 
virtual std::string get_name () const =0
 Returns a human-readable name for this renderer. More...
 
virtual bool is_texture_vertex_color_supported () const =0
 Checks if the renderer supports setting colors for each vertex of a textured quad. More...
 
bool is_quad_batching_enabled () const
 Checks if the renderer has quad render batching enabled. More...
 
void set_quad_batching_enabled (bool enabled)
 Enables/disables quad batching. More...
 
virtual std::size_t get_texture_max_size () const =0
 Returns the maximum texture width/height (in pixels). More...
 
virtual bool is_texture_atlas_supported () const =0
 Checks if the renderer supports texture atlases natively. More...
 
bool is_texture_atlas_enabled () const
 Checks if the renderer has texture atlases enabled. More...
 
void set_texture_atlas_enabled (bool enabled)
 Enables/disables texture atlases. More...
 
std::size_t get_texture_atlas_page_size () const
 Returns the width/height of a texture atlas page (in pixels). More...
 
void set_texture_atlas_page_size (std::size_t page_size)
 Set the width/height of a texture atlas page (in pixels). More...
 
std::size_t get_texture_atlas_page_count () const
 Count the total number of texture atlas pages currently in use. More...
 
virtual bool is_vertex_cache_supported () const =0
 Checks if the renderer supports vertex caches. More...
 
bool is_vertex_cache_enabled () const
 Checks if the renderer has enabled support for vertex caches. More...
 
void set_vertex_cache_enabled (bool enabled)
 Enables/disables vertex caches. More...
 
void auto_detect_settings ()
 Automatically determines the best rendering settings for the current platform. More...
 
void reset_counters ()
 Resets the number of batches to zero (for analytics only). More...
 
std::size_t get_batch_count () const
 Returns the number of batches of vertices sent to the GPU since the last call to reset_counters. More...
 
std::size_t get_vertex_count () const
 Returns the number of vertices sent to the GPU since the last call to reset_counters. More...
 
void begin (std::shared_ptr< render_target > target=nullptr)
 Begins rendering on a particular render target. More...
 
void end ()
 Ends rendering. More...
 
void flush_quad_batch ()
 Flushes any pending quad batch render operation. More...
 
void set_view (const matrix4f &view_matrix)
 Sets the view matrix to use when rendering (viewport). More...
 
virtual matrix4f get_view () const =0
 Returns the current view matrix to use when rendering (viewport). More...
 
void render_quad (const quad &q)
 Renders a quad. More...
 
void render_quads (const material *mat, const std::vector< std::array< vertex, 4 >> &quad_list)
 Renders a set of quads. More...
 
void render_cache (const material *mat, const vertex_cache &cache, const matrix4f &model_transform=matrix4f::identity)
 Renders a vertex cache. More...
 
std::shared_ptr< materialcreate_material (const std::string &file_name, material::filter filt=material::filter::none)
 Creates a new material from a texture file. More...
 
std::shared_ptr< materialcreate_atlas_material (const std::string &atlas_category, const std::string &file_name, material::filter filt=material::filter::none)
 Creates a new material from a texture file. More...
 
virtual std::shared_ptr< materialcreate_material (std::shared_ptr< render_target > target, const bounds2f &location)=0
 Creates a new material from a portion of a render target. More...
 
std::shared_ptr< materialcreate_material (std::shared_ptr< render_target > target)
 Creates a new material from an entire render target. More...
 
virtual std::shared_ptr< materialcreate_material (const vector2ui &dimensions, const color32 *pixel_data, material::filter filt=material::filter::none)=0
 Creates a new material from arbitrary pixel data. More...
 
virtual std::shared_ptr< render_targetcreate_render_target (const vector2ui &dimensions, material::filter filt=material::filter::none)=0
 Creates a new render target. More...
 
std::shared_ptr< fontcreate_font (const std::string &font_file, std::size_t size, std::size_t outline, const std::vector< code_point_range > &code_points, char32_t default_code_point)
 Creates a new font. More...
 
std::shared_ptr< fontcreate_atlas_font (const std::string &atlas_category, const std::string &font_file, std::size_t size, std::size_t outline, const std::vector< code_point_range > &code_points, char32_t default_code_point)
 Creates a new font. More...
 
virtual std::shared_ptr< vertex_cachecreate_vertex_cache (gui::vertex_cache::type type)=0
 Creates a new empty vertex cache. More...
 
virtual void notify_window_resized (const vector2ui &dimensions)
 Notifies the renderer that the render window has been resized. More...
 

Protected Member Functions

virtual void begin_ (std::shared_ptr< render_target > target)=0
 Begins rendering on a particular render target. More...
 
virtual void end_ ()=0
 Ends rendering. More...
 
virtual void set_view_ (const matrix4f &view_matrix)=0
 Sets the view matrix to use when rendering (viewport). More...
 
virtual void render_quads_ (const material *mat, const std::vector< std::array< vertex, 4 >> &quad_list)=0
 Renders a set of quads. More...
 
virtual void render_cache_ (const material *mat, const vertex_cache &cache, const matrix4f &model_transform)=0
 Renders a vertex cache. More...
 
virtual std::shared_ptr< materialcreate_material_ (const std::string &file_name, material::filter filt)=0
 Creates a new material from a texture file. More...
 
virtual std::shared_ptr< atlascreate_atlas_ (material::filter filt)=0
 Creates a new atlas with a given texture filter mode. More...
 
virtual std::shared_ptr< fontcreate_font_ (const std::string &font_file, std::size_t size, std::size_t outline, const std::vector< code_point_range > &code_points, char32_t default_code_point)=0
 Creates a new font. More...
 
atlasget_atlas_ (const std::string &atlas_category, material::filter filt)
 

Protected Attributes

std::unordered_map< std::string, std::weak_ptr< gui::material > > texture_list_
 
std::unordered_map< std::string, std::shared_ptr< gui::atlas > > atlas_list_
 
std::unordered_map< std::string, std::weak_ptr< gui::font > > font_list_
 

Detailed Description

Abstract type for implementation specific management.

Definition at line 26 of file gui_renderer.hpp.

Constructor & Destructor Documentation

◆ renderer() [1/3]

lxgui::gui::renderer::renderer ( )
default

Constructor.

◆ renderer() [2/3]

lxgui::gui::renderer::renderer ( const renderer )
delete

Non-copiable.

◆ renderer() [3/3]

lxgui::gui::renderer::renderer ( renderer &&  )
delete

Non-movable.

◆ ~renderer()

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

Destructor.

Member Function Documentation

◆ auto_detect_settings()

void lxgui::gui::renderer::auto_detect_settings ( )

Automatically determines the best rendering settings for the current platform.

Definition at line 283 of file gui_renderer.cpp.

◆ begin()

void lxgui::gui::renderer::begin ( std::shared_ptr< render_target target = nullptr)

Begins rendering on a particular render target.

Parameters
targetThe render target (main screen if nullptr)

Definition at line 11 of file gui_renderer.cpp.

◆ begin_()

virtual void lxgui::gui::renderer::begin_ ( std::shared_ptr< render_target target)
protectedpure virtual

Begins rendering on a particular render target.

Parameters
targetThe render target (main screen if nullptr)

Implemented in lxgui::gui::sfml::renderer, lxgui::gui::sdl::renderer, and lxgui::gui::gl::renderer.

◆ create_atlas_()

virtual std::shared_ptr<atlas> lxgui::gui::renderer::create_atlas_ ( material::filter  filt)
protectedpure virtual

Creates a new atlas with a given texture filter mode.

Parameters
filtThe filtering to apply to the texture
Returns
The new atlas

Implemented in lxgui::gui::sfml::renderer, lxgui::gui::sdl::renderer, and lxgui::gui::gl::renderer.

◆ create_atlas_font()

std::shared_ptr< font > lxgui::gui::renderer::create_atlas_font ( const std::string &  atlas_category,
const std::string &  font_file,
std::size_t  size,
std::size_t  outline,
const std::vector< code_point_range > &  code_points,
char32_t  default_code_point 
)

Creates a new font.

Parameters
atlas_categoryThe category of atlas in which to create the font texture
font_fileThe file from which to read the font
sizeThe requested size of the characters (in points)
outlineThe thickness of the outline (in points)
code_pointsThe list of Unicode characters to load
default_code_pointThe character to display as fallback
Note
Even though the gui has been designed to use vector fonts files (such as .ttf or .otf font formats), nothing prevents the implementation from using any other font type, including bitmap fonts.
See create_atlas_material() for more information on atlases.

Definition at line 329 of file gui_renderer.cpp.

◆ create_atlas_material()

std::shared_ptr< material > lxgui::gui::renderer::create_atlas_material ( const std::string &  atlas_category,
const std::string &  file_name,
material::filter  filt = material::filter::none 
)

Creates a new material from a texture file.

Parameters
atlas_categoryThe category of atlas in which to create the texture
file_nameThe name of the file
filtThe filtering to apply to the texture
Returns
The new material
Note
Supported texture formats are defined by implementation. The gui library is completely unaware of this.
The atlas category is a hint that the implementation can use to select the texture atlas in which to place this new texture. If a group of textures is known to be used to render objects that are often rendered consecutively (for example, various tiles of a background), they should be placed in the same category to maximize the chance of draw call batching. Conversely, if two texture are known to rarely be used in the same context (for example, a special effect particle texture and a UI button texture), they should not be placed in the same category, as this could otherwise fill up the atlas quickly, and reduce batching opportunities.
Because of how texture atlases work, it is not possible to use texture coordinate wrapping for materials from an atlas. Trying to use coordinates outside the [0,1] range will start reading texture data from another material.

Definition at line 307 of file gui_renderer.cpp.

◆ create_font()

std::shared_ptr< gui::font > lxgui::gui::renderer::create_font ( const std::string &  font_file,
std::size_t  size,
std::size_t  outline,
const std::vector< code_point_range > &  code_points,
char32_t  default_code_point 
)

Creates a new font.

Parameters
font_fileThe file from which to read the font
sizeThe requested size of the characters (in points)
outlineThe thickness of the outline (in points)
code_pointsThe list of Unicode characters to load
default_code_pointThe character to display as fallback
Note
Even though the gui has been designed to use vector fonts files (such as .ttf or .otf font formats), nothing prevents the implementation from using any other font type, including bitmap fonts.
If an outline thickness other than zero is requested, only the outline itself will be rendered by the returned font. A non-outlined font must be rendered above the outlined font to fill the actual characters.

Definition at line 222 of file gui_renderer.cpp.

◆ create_font_()

virtual std::shared_ptr<font> lxgui::gui::renderer::create_font_ ( const std::string &  font_file,
std::size_t  size,
std::size_t  outline,
const std::vector< code_point_range > &  code_points,
char32_t  default_code_point 
)
protectedpure virtual

Creates a new font.

Parameters
font_fileThe file from which to read the font
sizeThe requested size of the characters (in points)
outlineThe thickness of the outline (in points)
code_pointsThe list of Unicode characters to load
default_code_pointThe character to display as fallback
Note
Even though the gui has been designed to use vector fonts files (such as .ttf or .otf font formats), nothing prevents the implementation from using any other font type, including bitmap fonts.

Implemented in lxgui::gui::sfml::renderer, lxgui::gui::sdl::renderer, and lxgui::gui::gl::renderer.

◆ create_material() [1/4]

std::shared_ptr< gui::material > lxgui::gui::renderer::create_material ( const std::string &  file_name,
material::filter  filt = material::filter::none 
)

Creates a new material from a texture file.

Parameters
file_nameThe name of the file
filtThe filtering to apply to the texture
Returns
The new material
Note
Supported texture formats are defined by implementation. The gui library is completely unaware of this.

Definition at line 182 of file gui_renderer.cpp.

◆ create_material() [2/4]

virtual std::shared_ptr<material> lxgui::gui::renderer::create_material ( const vector2ui dimensions,
const color32 pixel_data,
material::filter  filt = material::filter::none 
)
pure virtual

Creates a new material from arbitrary pixel data.

Parameters
dimensionsThe dimensions of the material
pixel_dataThe color data for all the pixels in the material
filtThe filtering to apply to the texture
Returns
The new material

Implemented in lxgui::gui::sfml::renderer, lxgui::gui::sdl::renderer, and lxgui::gui::gl::renderer.

◆ create_material() [3/4]

std::shared_ptr< material > lxgui::gui::renderer::create_material ( std::shared_ptr< render_target target)

Creates a new material from an entire render target.

Parameters
targetThe render target from which to read the pixels
Returns
The new material

Definition at line 359 of file gui_renderer.cpp.

◆ create_material() [4/4]

virtual std::shared_ptr<material> lxgui::gui::renderer::create_material ( std::shared_ptr< render_target target,
const bounds2f location 
)
pure virtual

Creates a new material from a portion of a render target.

Parameters
targetThe render target from which to read the pixels
locationThe portion of the render target to use as material
Returns
The new material

Implemented in lxgui::gui::sfml::renderer, lxgui::gui::sdl::renderer, and lxgui::gui::gl::renderer.

◆ create_material_()

virtual std::shared_ptr<material> lxgui::gui::renderer::create_material_ ( const std::string &  file_name,
material::filter  filt 
)
protectedpure virtual

Creates a new material from a texture file.

Parameters
file_nameThe name of the file
filtThe filtering to apply to the texture
Returns
The new material
Note
Supported texture formats are defined by implementation. The gui library is completely unaware of this.

Implemented in lxgui::gui::sfml::renderer, lxgui::gui::sdl::renderer, and lxgui::gui::gl::renderer.

◆ create_render_target()

virtual std::shared_ptr<render_target> lxgui::gui::renderer::create_render_target ( const vector2ui dimensions,
material::filter  filt = material::filter::none 
)
pure virtual

Creates a new render target.

Parameters
dimensionsThe dimensions of the render target
filtThe filtering to apply to the target texture when displayed

Implemented in lxgui::gui::sfml::renderer, lxgui::gui::sdl::renderer, and lxgui::gui::gl::renderer.

◆ create_vertex_cache()

virtual std::shared_ptr<vertex_cache> lxgui::gui::renderer::create_vertex_cache ( gui::vertex_cache::type  type)
pure virtual

Creates a new empty vertex cache.

Parameters
typeThe type of data this cache will hold
Note
Not all implementations support vertex caches. See is_vertex_cache_supported().

Implemented in lxgui::gui::sfml::renderer, lxgui::gui::sdl::renderer, and lxgui::gui::gl::renderer.

◆ end()

void lxgui::gui::renderer::end ( )

Ends rendering.

Definition at line 37 of file gui_renderer.cpp.

◆ end_()

virtual void lxgui::gui::renderer::end_ ( )
protectedpure virtual

◆ flush_quad_batch()

void lxgui::gui::renderer::flush_quad_batch ( )

Flushes any pending quad batch render operation.

Note
If is_quad_batching_enabled(), quad rendering is done in batches. This means that the quads are not actually rendered until this function is called. The renderer calls this function automatically in various situations: when calling end(), when trying to render something that is no included in the batching system (such as render_cache()), or when changing the global state of the render (such as with set_view()). If you have your own rendering operations that are not going through this renderer (like raw OpenGL calls), make sure you call this function before doing your own rendering.
This function is meant to be called between begin() and end() only.

Definition at line 136 of file gui_renderer.cpp.

◆ get_atlas_()

atlas & lxgui::gui::renderer::get_atlas_ ( const std::string &  atlas_category,
material::filter  filt 
)
protected

Definition at line 289 of file gui_renderer.cpp.

◆ get_batch_count()

std::size_t lxgui::gui::renderer::get_batch_count ( ) const

Returns the number of batches of vertices sent to the GPU since the last call to reset_counters.

Returns
The number of batches of vertices sent to the GPU since the last call to reset_counters

Definition at line 52 of file gui_renderer.cpp.

◆ get_name()

virtual std::string lxgui::gui::renderer::get_name ( ) const
pure virtual

Returns a human-readable name for this renderer.

Returns
A human-readable name for this renderer

Implemented in lxgui::gui::sfml::renderer, lxgui::gui::sdl::renderer, and lxgui::gui::gl::renderer.

◆ get_texture_atlas_page_count()

std::size_t lxgui::gui::renderer::get_texture_atlas_page_count ( ) const

Count the total number of texture atlas pages currently in use.

Returns
The total number of texture atlas pages currently in use

Definition at line 265 of file gui_renderer.cpp.

◆ get_texture_atlas_page_size()

std::size_t lxgui::gui::renderer::get_texture_atlas_page_size ( ) const

Returns the width/height of a texture atlas page (in pixels).

Returns
The width/height of a texture atlas page (in pixels)

Definition at line 254 of file gui_renderer.cpp.

◆ get_texture_max_size()

virtual std::size_t lxgui::gui::renderer::get_texture_max_size ( ) const
pure virtual

Returns the maximum texture width/height (in pixels).

Returns
The maximum texture width/height (in pixels)

Implemented in lxgui::gui::sfml::renderer, lxgui::gui::sdl::renderer, and lxgui::gui::gl::renderer.

◆ get_vertex_count()

std::size_t lxgui::gui::renderer::get_vertex_count ( ) const

Returns the number of vertices sent to the GPU since the last call to reset_counters.

Returns
The number of vertices sent to the GPU since the last call to reset_counters

Definition at line 56 of file gui_renderer.cpp.

◆ get_view()

virtual matrix4f lxgui::gui::renderer::get_view ( ) const
pure virtual

Returns the current view matrix to use when rendering (viewport).

Returns
The current view matrix to use when rendering
Note
See set_view() for more information. The returned matrix may be different from the matrix given to set_view(), if the rendering backend does not support certain transformations.

Implemented in lxgui::gui::sfml::renderer, lxgui::gui::sdl::renderer, and lxgui::gui::gl::renderer.

◆ is_quad_batching_enabled()

bool lxgui::gui::renderer::is_quad_batching_enabled ( ) const

Checks if the renderer has quad render batching enabled.

Returns
'true' if enabled, 'false' otherwise

Definition at line 173 of file gui_renderer.cpp.

◆ is_texture_atlas_enabled()

bool lxgui::gui::renderer::is_texture_atlas_enabled ( ) const

Checks if the renderer has texture atlases enabled.

Returns
'true' if enabled, 'false' otherwise

Definition at line 246 of file gui_renderer.cpp.

◆ is_texture_atlas_supported()

virtual bool lxgui::gui::renderer::is_texture_atlas_supported ( ) const
pure virtual

Checks if the renderer supports texture atlases natively.

Returns
'true' if enabled, 'false' otherwise
Note
If 'false', texture atlases will be implemented using a generic solution with render targets.

Implemented in lxgui::gui::sfml::renderer, lxgui::gui::sdl::renderer, and lxgui::gui::gl::renderer.

◆ is_texture_vertex_color_supported()

virtual bool lxgui::gui::renderer::is_texture_vertex_color_supported ( ) const
pure virtual

Checks if the renderer supports setting colors for each vertex of a textured quad.

Returns
'true' if supported, 'false' otherwise

Implemented in lxgui::gui::sfml::renderer, lxgui::gui::sdl::renderer, and lxgui::gui::gl::renderer.

◆ is_vertex_cache_enabled()

bool lxgui::gui::renderer::is_vertex_cache_enabled ( ) const

Checks if the renderer has enabled support for vertex caches.

Returns
'true' if vertex caches are supported and enabled, 'false' otherwise

Definition at line 275 of file gui_renderer.cpp.

◆ is_vertex_cache_supported()

virtual bool lxgui::gui::renderer::is_vertex_cache_supported ( ) const
pure virtual

Checks if the renderer supports vertex caches.

Returns
'true' if supported, 'false' otherwise

Implemented in lxgui::gui::sfml::renderer, lxgui::gui::sdl::renderer, and lxgui::gui::gl::renderer.

◆ notify_window_resized()

void lxgui::gui::renderer::notify_window_resized ( const vector2ui dimensions)
virtual

Notifies the renderer that the render window has been resized.

Parameters
dimensionsThe new window dimensions

Reimplemented in lxgui::gui::sfml::renderer, lxgui::gui::sdl::renderer, and lxgui::gui::gl::renderer.

Definition at line 364 of file gui_renderer.cpp.

◆ operator=() [1/2]

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

Non-copiable.

◆ operator=() [2/2]

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

Non-movable.

◆ render_cache()

void lxgui::gui::renderer::render_cache ( const material mat,
const vertex_cache cache,
const matrix4f model_transform = matrix4f::identity 
)

Renders a vertex cache.

Parameters
matThe material to use for rendering, or null if none
cacheThe vertex cache
model_transformThe transformation matrix to apply to vertices
Note
This function is meant to be called between begin() and end() only. When multiple quads share the same material, it is always more efficient to call this method than calling render_quad repeatedly, as it allows to reduce the number of draw calls. This method is also more efficient than render_quads(), as the vertex data is already cached to the GPU and does not need sending again. However, not all implementations support vertex caches. See is_vertex_cache_supported(). Note finally that rendering a vertex cache always triggers a draw call, no matter what, even when quad batching is enabled. For this reason, if quad batching is enabled, only use vertex caches for large vertex arrays and not for just a handful of quads. Benchmark when in doubt.

Definition at line 160 of file gui_renderer.cpp.

◆ render_cache_()

virtual void lxgui::gui::renderer::render_cache_ ( const material mat,
const vertex_cache cache,
const matrix4f model_transform 
)
protectedpure virtual

Renders a vertex cache.

Parameters
matThe material to use for rendering, or null if none
cacheThe vertex cache
model_transformThe transformation matrix to apply to vertices
Note
This function is meant to be called between begin() and end() only. When multiple quads share the same material, it is always more efficient to call this method than calling render_quad repeatedly, as it allows to reduce the number of draw calls. This method is also more efficient than render_quads(), as the vertex data is already cached to the GPU and does not need sending again. However, not all implementations support vertex caches. See is_vertex_cache_supported(). Note finally that rendering a vertex cache always triggers a draw call, no matter what, even when quad batching is enabled. For this reason, if quad batching is enabled, only use vertex caches for large vertex arrays and not for just a handful of quads. Benchmark when in doubt.

Implemented in lxgui::gui::sfml::renderer, lxgui::gui::sdl::renderer, and lxgui::gui::gl::renderer.

◆ render_quad()

void lxgui::gui::renderer::render_quad ( const quad q)

Renders a quad.

Parameters
qThe quad to render on the current render target
Note
This function is meant to be called between begin() and end() only.

Definition at line 68 of file gui_renderer.cpp.

◆ render_quads()

void lxgui::gui::renderer::render_quads ( const material mat,
const std::vector< std::array< vertex, 4 >> &  quad_list 
)

Renders a set of quads.

Parameters
matThe material to use for rendering, or null if none
quad_listThe list of the quads you want to render
Note
This function is meant to be called between begin() and end() only. When multiple quads share the same material, it is always more efficient to call this method than calling render_quad repeatedly, as it allows to reduce the number of draw calls.

Definition at line 89 of file gui_renderer.cpp.

◆ render_quads_()

virtual void lxgui::gui::renderer::render_quads_ ( const material mat,
const std::vector< std::array< vertex, 4 >> &  quad_list 
)
protectedpure virtual

Renders a set of quads.

Parameters
matThe material to use for rendering, or null if none
quad_listThe list of the quads you want to render
Note
This function is meant to be called between begin() and end() only. When multiple quads share the same material, it is always more efficient to call this method than calling render_quad repeatedly, as it allows to reduce the number of draw calls.

Implemented in lxgui::gui::sfml::renderer, lxgui::gui::sdl::renderer, and lxgui::gui::gl::renderer.

◆ reset_counters()

void lxgui::gui::renderer::reset_counters ( )

Resets the number of batches to zero (for analytics only).

Note
See get_batch_count() and get_vertex_count(). This should be called a the beginning of a frame.

Definition at line 45 of file gui_renderer.cpp.

◆ set_quad_batching_enabled()

void lxgui::gui::renderer::set_quad_batching_enabled ( bool  enabled)

Enables/disables quad batching.

Parameters
enabled'true' to enable quad batching, 'false' to disable it
Note
Quad batching is enabled by default.
When quad batching is disabled, each call to render_quads() renders immediately to the screen. This can lead to a large number of draw calls. With quad batching enabled, the renderer accumulates quads into a local cache, and only renders them when necessary (i.e., when the texture changes, when another immediate rendering call is requested, or the frame ends).

Definition at line 177 of file gui_renderer.cpp.

◆ set_texture_atlas_enabled()

void lxgui::gui::renderer::set_texture_atlas_enabled ( bool  enabled)

Enables/disables texture atlases.

Parameters
enabled'true' to enable texture atlases, 'false' to disable them
Note
Texture atlases are enabled by default. Changing this flag will only impact newly created materials. Existing materials will not be affected.
In general, texture atlases only increase performance when vertex caches are supported and used (see is_vertex_cache_supported()). The can actually decrease performance when vertex caches are not supported, if texture tiling is used a lot (e.g., in frame backdrop edges). It is therefore recommended to disable texture atlases if vertex caches are not supported.

Definition at line 250 of file gui_renderer.cpp.

◆ set_texture_atlas_page_size()

void lxgui::gui::renderer::set_texture_atlas_page_size ( std::size_t  page_size)

Set the width/height of a texture atlas page (in pixels).

Parameters
page_sizeThe texture width/height in pixels
Note
Changing this value will only impact newly created atlas pages. Existing pages will not be affected.
Increase this value to allow more materials to fit on a single atlas page, therefore improving performance. Decrease tihs value if the memory usage from atlas textures is too large. Set it to zero to fall back to the implementation-defined default value.

Definition at line 261 of file gui_renderer.cpp.

◆ set_vertex_cache_enabled()

void lxgui::gui::renderer::set_vertex_cache_enabled ( bool  enabled)

Enables/disables vertex caches.

Parameters
enabled'true' to enable vertex caches, 'false' to disable them
Note
Even if enabled with this function, vertex caches may not be supported by the renderer, see is_vertex_cache_supported().

Definition at line 279 of file gui_renderer.cpp.

◆ set_view()

void lxgui::gui::renderer::set_view ( const matrix4f view_matrix)

Sets the view matrix to use when rendering (viewport).

Parameters
view_matrixThe view matrix
Note
This function is called by default in begin(), which resets the view to span the entire render target (or the entire screen). Therefore it is only necessary to use this function when a custom view is required. The view matrix converts custom "world" coordinates into screen-space coordinates, where the X and Y coordinates represent the horizontal and vertical dimensions on the screen, respectively, and range from -1 to +1. In screen-space coordinates, the top-left corner of the screen has coordinates (-1,-1), and the bottom-left corner of the screen is (+1,+1).
Warning
Although the view is specified here as a matrix for maximum flexibility, some backends do not actually support arbitrary view matrices. For such backends, the view matrix will be simplified to a simpler 2D translate + rotate + scale transform, or even just translate + scale.

Definition at line 60 of file gui_renderer.cpp.

◆ set_view_()

virtual void lxgui::gui::renderer::set_view_ ( const matrix4f view_matrix)
protectedpure virtual

Sets the view matrix to use when rendering (viewport).

Parameters
view_matrixThe view matrix
Note
This function is called by default in begin(), which resets the view to span the entire render target (or the entire screen). Therefore it is only necessary to use this function when a custom view is required. The view matrix converts custom "world" coordinates into screen-space coordinates, where the X and Y coordinates represent the horizontal and vertical dimensions on the screen, respectively, and range from -1 to +1. In screen-space coordinates, the top-left corner of the screen has coordinates (-1,-1), and the bottom-left corner of the screen is (+1,+1).
Warning
Although the view is specified here as a matrix for maximum flexibility, some backends do not actually support arbitrary view matrices. For such backends, the view matrix will be simplified to a simpler 2D translate + rotate + scale transform, or even just translate + scale.

Implemented in lxgui::gui::sfml::renderer, lxgui::gui::sdl::renderer, and lxgui::gui::gl::renderer.

Member Data Documentation

◆ atlas_list_

std::unordered_map<std::string, std::shared_ptr<gui::atlas> > lxgui::gui::renderer::atlas_list_
protected

Definition at line 497 of file gui_renderer.hpp.

◆ font_list_

std::unordered_map<std::string, std::weak_ptr<gui::font> > lxgui::gui::renderer::font_list_
protected

Definition at line 498 of file gui_renderer.hpp.

◆ texture_list_

std::unordered_map<std::string, std::weak_ptr<gui::material> > lxgui::gui::renderer::texture_list_
protected

Definition at line 496 of file gui_renderer.hpp.


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