MCPcopy Create free account
hub / github.com/TankOs/SFGUI / UpdateImage

Method UpdateImage

src/SFGUI/Renderer.cpp:711–741  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

709}
710
711void Renderer::UpdateImage( const sf::Vector2f& offset, const sf::Image& data ) {
712 // We insert padding between atlas elements to prevent
713 // texture filtering from screwing up our images.
714 // If 1 pixel isn't enough, increase.
715 const static auto padding = 1;
716
717 sf::Vector2i int_offset( static_cast<int>( std::floor( offset.x + .5f ) ), static_cast<int>( std::floor( offset.y + .5f ) ) );
718 sf::Vector2i int_size( static_cast<sf::Vector2i>( data.getSize() ) + sf::Vector2i( 0, padding ) );
719
720 for( const auto& texture : m_textures ) {
721 if( texture.offset == int_offset ) {
722 if( texture.size != int_size ) {
723#if defined( SFGUI_DEBUG )
724 std::cerr << "Tried to update texture with mismatching image size.\n";
725#endif
726 return;
727 }
728
729 auto page = static_cast<std::size_t>( int_offset.y / max_texture_size );
730
731 m_texture_atlas[page]->update( data, { 0u, static_cast<unsigned int>( int_offset.y % max_texture_size ) } );
732
733 return;
734 }
735 }
736
737// Only enable during development.
738//#if defined( SFGUI_DEBUG )
739// std::cerr << "Tried to update non-existant image at (" << offset.x << "," << offset.y << ").\n";
740//#endif
741}
742
743/// @endcond
744

Callers 2

UpdateMethod · 0.80
SetImageMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected