| 69 | } |
| 70 | |
| 71 | void TriProjection::SetProjection( Tr2RenderContext& renderContext ) |
| 72 | { |
| 73 | Matrix viewport2projectionAdjustment = IdentityMatrix(); |
| 74 | auto& viewport = renderContext.m_esm.GetViewport(); |
| 75 | auto& deviceViewport = renderContext.m_esm.GetDeviceViewport(); |
| 76 | |
| 77 | // In case we shrunk the viewport we need to scale and/or offset the |
| 78 | // projection matrix |
| 79 | viewport2projectionAdjustment._11 = viewport.width / deviceViewport.m_width; |
| 80 | viewport2projectionAdjustment._22 = viewport.height / deviceViewport.m_height; |
| 81 | viewport2projectionAdjustment._31 = ( viewport.width - deviceViewport.m_width ) / deviceViewport.m_width; |
| 82 | viewport2projectionAdjustment._32 = ( viewport.height - deviceViewport.m_height ) / deviceViewport.m_height; |
| 83 | if( viewport.x < 0 ) |
| 84 | { |
| 85 | viewport2projectionAdjustment._31 *= -1; |
| 86 | } |
| 87 | |
| 88 | if( viewport.y + viewport.height > int( renderContext.m_esm.GetRenderTargetHeight() ) ) |
| 89 | { |
| 90 | viewport2projectionAdjustment._32 *= -1; |
| 91 | } |
| 92 | |
| 93 | |
| 94 | switch( m_projectionType ) |
| 95 | { |
| 96 | case TRIPROJECTION_FOV: |
| 97 | Tr2Renderer::SetPerspectiveProjection( m_fov, m_zn, m_zf, m_aspect, viewport2projectionAdjustment ); |
| 98 | break; |
| 99 | case TRIPROJECTION_OFF_CENTER: |
| 100 | Tr2Renderer::SetPerspectiveProjection( m_left, m_right, m_bottom, m_top, m_zn, m_zf, viewport2projectionAdjustment ); |
| 101 | break; |
| 102 | case TRIPROJECTION_ORTHO: |
| 103 | Tr2Renderer::SetOrthoProjection( m_left, m_top, m_zn, m_zf, viewport2projectionAdjustment ); |
| 104 | break; |
| 105 | case TRIPROJECTION_CUSTOM: |
| 106 | Tr2Renderer::SetProjectionTransform( m_customTransform, viewport2projectionAdjustment ); |
| 107 | break; |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | void TriProjection::SetProjection() |
| 112 | { |
no test coverage detected