To deal with the adjusted viewport that D3D9 forces us to create when viewport extends beyond the screen
| 265 | // To deal with the adjusted viewport that D3D9 forces us to create when viewport |
| 266 | // extends beyond the screen |
| 267 | void AdjustTextureCoordsToViewport( Tr2RenderContext& renderContext, Vector2& topLeft, Vector2& bottomRight ) |
| 268 | { |
| 269 | Vector2 tlTexCoordAdjusted = topLeft; |
| 270 | |
| 271 | auto& viewportOnDevice = renderContext.m_esm.GetDeviceViewport(); |
| 272 | auto& viewport = renderContext.m_esm.GetViewport(); |
| 273 | |
| 274 | int deltaX = (int)viewportOnDevice.m_x - viewport.x; |
| 275 | int deltaY = (int)viewportOnDevice.m_y - viewport.y; |
| 276 | |
| 277 | float xOffset = float( deltaX ) / viewport.width; |
| 278 | float yOffset = float( deltaY ) / viewport.height; |
| 279 | |
| 280 | tlTexCoordAdjusted.x += xOffset * bottomRight.x; |
| 281 | tlTexCoordAdjusted.y += yOffset * bottomRight.y; |
| 282 | |
| 283 | Vector2 brTexCoordAdjusted; |
| 284 | brTexCoordAdjusted = bottomRight; |
| 285 | brTexCoordAdjusted.x *= float( viewportOnDevice.m_width + deltaX ) / viewport.width; |
| 286 | brTexCoordAdjusted.y *= float( viewportOnDevice.m_height + deltaY ) / viewport.height; |
| 287 | |
| 288 | topLeft = tlTexCoordAdjusted; |
| 289 | bottomRight = brTexCoordAdjusted; |
| 290 | } |
| 291 | |
| 292 | |
| 293 | template <typename T> |
no test coverage detected