lxgui
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
lxgui::gui::sdl::renderer Class Referencefinal

SDL implementation of rendering. More...

#include <gui_sdl_renderer.hpp>

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

Public Member Functions

 renderer (SDL_Renderer *rdr, bool initialise_sdl_image)
 Constructor. More...
 
std::string get_name () const override
 Returns a human-readable name for this renderer. More...
 
matrix4f get_view () const override
 Returns the current view matrix to use when rendering (viewport). More...
 
std::size_t get_texture_max_size () const override
 Returns the maximum texture width/height (in pixels). More...
 
bool is_texture_atlas_supported () const override
 Checks if the renderer supports texture atlases natively. More...
 
bool is_texture_vertex_color_supported () const override
 Checks if the renderer supports setting colors for each vertex of a textured quad. More...
 
std::shared_ptr< gui::materialcreate_material (const vector2ui &dimensions, const color32 *pixel_data, material::filter filt=material::filter::none) override
 Creates a new material from arbitrary pixel data. More...
 
std::shared_ptr< gui::materialcreate_material (std::shared_ptr< gui::render_target > target, const bounds2f &location) override
 Creates a new material from a portion of a render target. More...
 
std::shared_ptr< gui::render_targetcreate_render_target (const vector2ui &dimensions, material::filter filt=material::filter::none) override
 Creates a new render target. More...
 
bool is_vertex_cache_supported () const override
 Checks if the renderer supports vertex caches. More...
 
std::shared_ptr< gui::vertex_cachecreate_vertex_cache (gui::vertex_cache::type type) override
 Creates a new empty vertex cache. More...
 
void notify_window_resized (const vector2ui &new_dimensions) override
 Notifies the renderer that the render window has been resized. More...
 
SDL_Renderer * get_sdl_renderer () const
 Returns the SDL renderer implementation. 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...
 
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...
 
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...
 
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_material (std::shared_ptr< render_target > target)
 Creates a new material from an entire render target. 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...
 
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...
 

Protected Member Functions

std::shared_ptr< gui::materialcreate_material_ (const std::string &file_name, material::filter filt) override
 Creates a new material from a texture file. More...
 
std::shared_ptr< gui::atlascreate_atlas_ (material::filter filt) override
 Creates a new atlas with a given texture filter mode. More...
 
std::shared_ptr< gui::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) override
 Creates a new font. More...
 
void begin_ (std::shared_ptr< gui::render_target > target) override
 Begins rendering on a particular render target. More...
 
void end_ () override
 Ends rendering. More...
 
void set_view_ (const matrix4f &view_matrix) override
 Sets the view matrix to use when rendering (viewport). More...
 
void render_quad_ (const sdl::material *mat, const std::array< vertex, 4 > &vertex_list)
 Renders a quad from a material and array of vertices. More...
 
void render_quads_ (const gui::material *mat, const std::vector< std::array< vertex, 4 >> &quad_list) override
 Renders a set of quads. More...
 
void render_cache_ (const gui::material *mat, const gui::vertex_cache &cache, const matrix4f &model_transform) override
 Renders a vertex cache. 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

SDL implementation of rendering.

Definition at line 18 of file gui_sdl_renderer.hpp.

Constructor & Destructor Documentation

◆ renderer()

lxgui::gui::sdl::renderer::renderer ( SDL_Renderer *  rdr,
bool  initialise_sdl_image 
)
explicit

Constructor.

Parameters
rdrA pre-initialised SDL renderer
initialise_sdl_imageSet to 'true' if SDL Image has not been initialised yet

Member Function Documentation

◆ auto_detect_settings()

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

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)
inherited

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_()

void lxgui::gui::sdl::renderer::begin_ ( std::shared_ptr< gui::render_target target)
overrideprotectedvirtual

Begins rendering on a particular render target.

Parameters
targetThe render target (main screen if nullptr)

Implements lxgui::gui::renderer.

◆ create_atlas_()

std::shared_ptr<gui::atlas> lxgui::gui::sdl::renderer::create_atlas_ ( material::filter  filt)
overrideprotectedvirtual

Creates a new atlas with a given texture filter mode.

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

Implements lxgui::gui::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 
)
inherited

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 
)
inherited

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 
)
inherited

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_()

std::shared_ptr<gui::font> lxgui::gui::sdl::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 
)
overrideprotectedvirtual

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
This implementation uses FreeType to load vector fonts and rasterize them. Bitmap fonts are not yet supported.

Implements lxgui::gui::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 
)
inherited

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]

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

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

Implements lxgui::gui::renderer.

◆ create_material() [3/4]

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

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

Implements lxgui::gui::renderer.

◆ create_material() [4/4]

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

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_()

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

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
Only PNG textures are supported by this implementation (parsed by libpng).

Implements lxgui::gui::renderer.

◆ create_render_target()

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

Creates a new render target.

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

Implements lxgui::gui::renderer.

◆ create_vertex_cache()

std::shared_ptr<gui::vertex_cache> lxgui::gui::sdl::renderer::create_vertex_cache ( gui::vertex_cache::type  type)
overridevirtual

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().

Implements lxgui::gui::renderer.

◆ end()

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

Ends rendering.

Definition at line 37 of file gui_renderer.cpp.

◆ end_()

void lxgui::gui::sdl::renderer::end_ ( )
overrideprotectedvirtual

Ends rendering.

Implements lxgui::gui::renderer.

◆ flush_quad_batch()

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

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 
)
protectedinherited

Definition at line 289 of file gui_renderer.cpp.

◆ get_batch_count()

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

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()

std::string lxgui::gui::sdl::renderer::get_name ( ) const
overridevirtual

Returns a human-readable name for this renderer.

Returns
A human-readable name for this renderer

Implements lxgui::gui::renderer.

◆ get_sdl_renderer()

SDL_Renderer* lxgui::gui::sdl::renderer::get_sdl_renderer ( ) const

Returns the SDL renderer implementation.

Returns
the SDL renderer implementation

◆ get_texture_atlas_page_count()

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

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
inherited

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()

std::size_t lxgui::gui::sdl::renderer::get_texture_max_size ( ) const
overridevirtual

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

Returns
The maximum texture width/height (in pixels)

Implements lxgui::gui::renderer.

◆ get_vertex_count()

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

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()

matrix4f lxgui::gui::sdl::renderer::get_view ( ) const
overridevirtual

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.

Implements lxgui::gui::renderer.

◆ is_quad_batching_enabled()

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

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
inherited

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()

bool lxgui::gui::sdl::renderer::is_texture_atlas_supported ( ) const
overridevirtual

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.

Implements lxgui::gui::renderer.

◆ is_texture_vertex_color_supported()

bool lxgui::gui::sdl::renderer::is_texture_vertex_color_supported ( ) const
overridevirtual

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

Returns
'true' if supported, 'false' otherwise

Implements lxgui::gui::renderer.

◆ is_vertex_cache_enabled()

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

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()

bool lxgui::gui::sdl::renderer::is_vertex_cache_supported ( ) const
overridevirtual

Checks if the renderer supports vertex caches.

Returns
'true' if supported, 'false' otherwise

Implements lxgui::gui::renderer.

◆ notify_window_resized()

void lxgui::gui::sdl::renderer::notify_window_resized ( const vector2ui new_dimensions)
overridevirtual

Notifies the renderer that the render window has been resized.

Parameters
new_dimensionsThe new window dimensions

Reimplemented from lxgui::gui::renderer.

◆ render_cache()

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

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_()

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

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.

Implements lxgui::gui::renderer.

◆ render_quad()

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

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_quad_()

void lxgui::gui::sdl::renderer::render_quad_ ( const sdl::material mat,
const std::array< vertex, 4 > &  vertex_list 
)
protected

Renders a quad from a material and array of vertices.

Parameters
matThe material to use to to render the quad, or null if none
vertex_listThe list of 4 vertices making up the quad
Note
This function is meant to be called between begin() and end() only.

◆ render_quads()

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

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_()

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

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. 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.

Implements lxgui::gui::renderer.

◆ reset_counters()

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

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)
inherited

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)
inherited

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)
inherited

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)
inherited

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)
inherited

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_()

void lxgui::gui::sdl::renderer::set_view_ ( const matrix4f view_matrix)
overrideprotectedvirtual

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.

Implements lxgui::gui::renderer.

Member Data Documentation

◆ atlas_list_

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

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_
protectedinherited

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_
protectedinherited

Definition at line 496 of file gui_renderer.hpp.


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