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

Method EndLayer

trinity/Sprite2d/Tr2Sprite2dScene.cpp:1632–1684  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1630}
1631
1632void Tr2Sprite2dScene::EndLayer( float x, float y, float width, float height, ITr2Sprite2dTexture* secondaryTexture )
1633{
1634 CCP_STATS_ZONE( __FUNCTION__ );
1635 USE_MAIN_THREAD_RENDER_CONTEXT();
1636
1637 D3DPERF_EVENT( L"Tr2Sprite2dScene::EndLayer" );
1638
1639 CCP_ASSERT( m_transformStack->empty() );
1640 CCP_DELETE( m_transformStack );
1641
1642 m_clipStack->pop_back();
1643 CCP_ASSERT( m_clipStack->empty() );
1644 CCP_DELETE( m_clipStack );
1645
1646 // Finish outstanding rendering before resetting render target
1647 IssueDrawCall();
1648
1649 renderContext.m_esm.PopRenderTarget();
1650
1651 // Set the coordinate transformations and clipping to what it was before we started
1652 // this layer.
1653 const StackOfStacksEntry_t& entry = m_stackOfStacks.back();
1654
1655 m_transformStack = entry.transformStack;
1656 m_clipStack = entry.clipStack;
1657
1658
1659 // Render the layer into the current one as a sprite
1660 SetTexture( 0, entry.renderTargetWrapper, S2D_TS_NONE );
1661 SetTextureTransform( 0, nullptr );
1662 SetTileMode( 0 );
1663
1664 if( secondaryTexture )
1665 {
1666 secondaryTexture->Apply( this, 1 );
1667 }
1668
1669 Tr2Sprite2dD3DVertex vertices[4];
1670 PrepareSpriteVerts( &vertices[0], Vector2( x, y ), width, height, m_spriteEffect );
1671
1672 static unsigned short s_layerIndices[6] = { 0, 1, 3, 3, 1, 2 };
1673 RenderTriangleVerts( &vertices[0], 4, s_layerIndices, 6 );
1674
1675 m_stackOfStacks.pop_back();
1676
1677 if( m_stackOfStacks.empty() )
1678 {
1679 // Once we exit the final layer the 2d render context is determined by the scene
1680 m_is2dRenderContext = m_is2dRender;
1681 }
1682
1683 DetermineViewportSize();
1684}
1685
1686void Tr2Sprite2dScene::SetColor( const Color& color )
1687{

Callers 1

GatherSpritesMethod · 0.80

Calls 3

emptyMethod · 0.80
PopRenderTargetMethod · 0.45
ApplyMethod · 0.45

Tested by

no test coverage detected