| 99 | } |
| 100 | |
| 101 | bool Tr2Blitter::DrawHelper( Tr2RenderContext& renderContext, Tr2Shader* shader, Tr2Material* material, const Tr2TextureAL* halTexture, bool isCameraSpace, const Vector2& tlTexCoord, const Vector2& brTexCoord, const Vector2& tlVertexCoord, const Vector2& brVertexCoord ) |
| 102 | { |
| 103 | CCP_ASSERT( material ); |
| 104 | if( !material ) |
| 105 | { |
| 106 | // Final build should not crash even if we get here with a null effect |
| 107 | return false; |
| 108 | } |
| 109 | |
| 110 | if( m_screenVertexDecl == -1 || !m_vertexBuffer.IsValid() ) |
| 111 | { |
| 112 | return false; |
| 113 | } |
| 114 | |
| 115 | if( !shader ) |
| 116 | { |
| 117 | return false; |
| 118 | } |
| 119 | |
| 120 | Tr2ScreenVertex* quad = NULL; |
| 121 | CR_RETURN_VAL( m_vertexBuffer.MapForWriting( quad, renderContext ), false ); |
| 122 | |
| 123 | if( isCameraSpace ) |
| 124 | { |
| 125 | CCP_ASSERT( tlVertexCoord[0] == 0.0f && tlVertexCoord[1] == 0.0f ); |
| 126 | CCP_ASSERT( brVertexCoord[0] == 1.0f && brVertexCoord[1] == 1.0f ); |
| 127 | |
| 128 | SetupScreenQuadInCameraSpace( quad ); |
| 129 | } |
| 130 | else |
| 131 | { |
| 132 | SetupScreenQuad( quad, tlTexCoord, brTexCoord, tlVertexCoord, brVertexCoord ); |
| 133 | } |
| 134 | |
| 135 | m_vertexBuffer.UnmapForWriting( renderContext ); |
| 136 | |
| 137 | renderContext.m_esm.ApplyVertexDeclaration( m_screenVertexDecl ); |
| 138 | renderContext.m_esm.ApplyStreamSource( 0, m_vertexBuffer, 0, sizeof( Tr2ScreenVertex ) ); |
| 139 | |
| 140 | static CTr2TransientTextureReference textureReference; |
| 141 | Tr2TextureAL texCopy; |
| 142 | if( halTexture ) |
| 143 | { |
| 144 | texCopy = *halTexture; |
| 145 | textureReference.SetTexture( &texCopy ); |
| 146 | GlobalStore().GetVariable( "BlitSource" )->SetValue( &textureReference ); |
| 147 | } |
| 148 | |
| 149 | unsigned int passCount = shader->GetPassCount( 0 ); |
| 150 | |
| 151 | for( unsigned int passIx = 0; passIx < passCount; ++passIx ) |
| 152 | { |
| 153 | shader->ApplyAllStateForPass( 0, passIx, renderContext ); |
| 154 | material->ApplyMaterialDataForPass( 0, passIx, renderContext ); |
| 155 | { |
| 156 | renderContext.SetTopology( TOP_TRIANGLE_STRIP ); |
| 157 | renderContext.DrawPrimitive( 0, 2 ); |
| 158 | } |
nothing calls this directly
no test coverage detected