| 704 | } |
| 705 | |
| 706 | void Tr2Sprite2dScene::SetTexture( unsigned ix, Tr2AtlasTexturePtr tex, Tr2Sprite2dTextureSettings settings ) |
| 707 | { |
| 708 | //CCP_STATS_ZONE( __FUNCTION__ ); |
| 709 | |
| 710 | CCP_STATS_INC( spriteSceneTextureCount ); |
| 711 | |
| 712 | CCP_ASSERT( ix < 2 ); |
| 713 | |
| 714 | #if !CCP_DEPLOY |
| 715 | if( !tex ) |
| 716 | { |
| 717 | tex = m_defaultTexture; |
| 718 | } |
| 719 | #endif |
| 720 | |
| 721 | Tr2TextureAL* texAL = nullptr; |
| 722 | if( tex ) |
| 723 | { |
| 724 | texAL = tex->GetTexture(); |
| 725 | if( !texAL ) |
| 726 | { |
| 727 | if( tex->GetRenderTarget() ) |
| 728 | { |
| 729 | texAL = tex->GetRenderTarget(); |
| 730 | } |
| 731 | } |
| 732 | } |
| 733 | |
| 734 | // Note that we can't assume that the same value for 'tex' results in the |
| 735 | // same D3D texture - the underlying texture may shift in the atlas. |
| 736 | if( !m_texture[ix] || texAL != m_texture[ix]->GetTexture() ) |
| 737 | { |
| 738 | CCP_STATS_INC( spriteSceneDrawCallTexture ); |
| 739 | IssueDrawCall(); |
| 740 | m_texture[ix] = tex; |
| 741 | |
| 742 | if( ix == 0 ) |
| 743 | { |
| 744 | Vector4 texelSize; |
| 745 | if( texAL ) |
| 746 | { |
| 747 | texelSize.x = 1.0f / texAL->GetWidth(); |
| 748 | texelSize.y = 1.0f / texAL->GetHeight(); |
| 749 | } |
| 750 | else |
| 751 | { |
| 752 | texelSize.x = 0.0f; |
| 753 | texelSize.y = 0.0f; |
| 754 | } |
| 755 | texelSize.z = 0.0f; |
| 756 | texelSize.w = 0.0f; |
| 757 | m_texelSizeVar[ix] = texelSize; |
| 758 | } |
| 759 | } |
| 760 | |
| 761 | m_texture[ix] = tex; |
| 762 | |
| 763 | TextureSetting& texSettings = m_textureSettings[ix]; |
no test coverage detected