MCPcopy Create free account
hub / github.com/carbonengine/trinity / PrepareSprites

Method PrepareSprites

trinity/Font/Tr2FontMeasurer.cpp:743–1043  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

741}
742
743void Tr2FontMeasurer::PrepareSprites( Tr2Sprite2dScene* renderer, const Vector2& translation, const Color& color, Tr2SpriteObjectEffect sfx, Tr2SpriteObjectBlendMode blendMode, Tr2SpriteTarget target, float glowBrightness, bool dropShadow, const Vector2& shadowOffset, const Color& shadowColor, Tr2SpriteObjectEffect shadowSfx )
744{
745 CCP_STATS_ZONE( __FUNCTION__ );
746
747 if( m_vertices )
748 {
749 CCP_DELETE[] m_vertices;
750 m_vertices = nullptr;
751 m_vertexCount = 0;
752
753 CCP_DELETE[] m_indices;
754 m_indices = nullptr;
755 m_indexCount = 0;
756 }
757
758 unsigned int spriteCount = 0;
759 for( auto it = m_committedRenderData.begin(); it != m_committedRenderData.end(); ++it )
760 {
761 Tr2FontRenderData* rd = *it;
762 spriteCount += rd->bitmapCount;
763 if( rd->underline )
764 {
765 ++spriteCount;
766 }
767 }
768
769 if( spriteCount == 0 )
770 {
771 return;
772 }
773
774 if( dropShadow )
775 {
776 spriteCount *= 2;
777 }
778
779 m_drawCalls.clear();
780
781 m_vertexCount = spriteCount * 4;
782 m_vertices = CCP_NEW( "Tr2FontMeasurer/m_vertices" ) Tr2Sprite2dD3DVertex[m_vertexCount];
783
784 m_indexCount = spriteCount * 6;
785 m_indices = CCP_NEW( "Tr2FontMeasurer/m_indices" ) unsigned short[m_indexCount];
786 unsigned short* curIndex = m_indices;
787
788 Tr2AtlasTexture* currentTexture = nullptr;
789
790 // Index of current sprite in the loop
791 unsigned int spriteIx = 0;
792
793 // Index of start of run with current texture
794 unsigned int startIx = 0;
795
796 // Index of vertex. This is reset for each drawcall, as the vertex buffer
797 // is segmented for each drawcall.
798 int vertexIx = 0;
799
800 auto addSprites = [&]( const Vector2& offset, const Color& currentColor, Tr2SpriteObjectEffect currentSfx ) {

Callers 1

GatherSpritesMethod · 0.80

Calls 10

PackBlendModeFunction · 0.85
getMethod · 0.80
GetTextureWindowMethod · 0.80
GetTextureWidthMethod · 0.80
GetTextureHeightMethod · 0.80
Vector4Class · 0.50
beginMethod · 0.45
endMethod · 0.45
GetTextureMethod · 0.45

Tested by

no test coverage detected