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

Method SetProjection

trinity/TriProjection.cpp:71–109  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

69}
70
71void 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
111void TriProjection::SetProjection()
112{

Callers 2

Calls 3

SetPerspectiveProjectionFunction · 0.85
GetRenderTargetHeightMethod · 0.80
GetViewportMethod · 0.45

Tested by

no test coverage detected