| 51 | } |
| 52 | |
| 53 | void SetupScreenQuadInCameraSpace( Tr2ScreenVertex quad[4], int width, int height ) |
| 54 | { |
| 55 | const TriViewport& viewport = Tr2Renderer::GetViewport(); |
| 56 | |
| 57 | // Top-left and bottom-right in projection space: |
| 58 | // See explanation in SetupScreenQuad for pixel offsets |
| 59 | Vector3 tl( -1.0f, 1.0f, 1.0f ); |
| 60 | Vector3 br( 1.0f, -1.0f, 1.0f ); |
| 61 | |
| 62 | // Transform to view space: |
| 63 | const Matrix& projectionRaw = Tr2Renderer::GetProjectionRawTransform(); |
| 64 | Matrix proj2view = Inverse( projectionRaw ); |
| 65 | tl = TransformCoord( tl, proj2view ); |
| 66 | br = TransformCoord( br, proj2view ); |
| 67 | |
| 68 | int edge1 = 1; |
| 69 | int edge2 = 2; |
| 70 | |
| 71 | USE_MAIN_THREAD_RENDER_CONTEXT(); //TODO! pass it in for cull mode |
| 72 | if( !renderContext.m_esm.IsCullModeInverted() ) |
| 73 | { |
| 74 | // Flip the interior edge direction in the quad which produces a correctly |
| 75 | // oriented strip of two triangles |
| 76 | edge1 = 2; |
| 77 | edge2 = 1; |
| 78 | } |
| 79 | |
| 80 | // The vertex shader should ensure that the z coordinate is pushed to w |
| 81 | Vector2 tlTC( 0.0f, 0.0f ); |
| 82 | Vector2 brTC( 1.0f, 1.0f ); |
| 83 | |
| 84 | // Top Left |
| 85 | quad[0].p = Vector4( tl.x, tl.y, tl.z, 1.0f ); |
| 86 | quad[0].t = tlTC; |
| 87 | |
| 88 | // Top right |
| 89 | quad[edge1].p = Vector4( br.x, tl.y, tl.z, 1.0f ); |
| 90 | quad[edge1].t = Vector2( brTC.x, tlTC.y ); |
| 91 | |
| 92 | // Bottom left |
| 93 | quad[edge2].p = Vector4( tl.x, br.y, tl.z, 1.0f ); |
| 94 | quad[edge2].t = Vector2( tlTC.x, brTC.y ); |
| 95 | |
| 96 | // Bottom right |
| 97 | quad[3].p = Vector4( br.x, br.y, tl.z, 1.0f ); |
| 98 | quad[3].t = brTC; |
| 99 | } |
| 100 | |
| 101 | |
| 102 | bool FillAndSetConstants( Tr2ConstantBufferAL& buffer, const void* const data, const size_t dataSize, unsigned constantTypeMask, const unsigned registerIndex, Tr2RenderContext& renderContext ) |
no test coverage detected