| 279 | } |
| 280 | |
| 281 | vr::VRTextureBounds_t CompositorBase::ViewportToTextureBounds(ovrRecti viewport, ovrTextureSwapChain swapChain, unsigned int flags) |
| 282 | { |
| 283 | vr::VRTextureBounds_t bounds; |
| 284 | float w = (float)swapChain->Desc.Width; |
| 285 | float h = (float)swapChain->Desc.Height; |
| 286 | bounds.uMin = viewport.Pos.x / w; |
| 287 | bounds.vMin = viewport.Pos.y / h; |
| 288 | |
| 289 | // Sanity check for the viewport size. |
| 290 | // Workaround for Defense Grid 2, which leaves these variables uninitialized. |
| 291 | if (viewport.Size.w > 0 && viewport.Size.h > 0) |
| 292 | { |
| 293 | bounds.uMax = (viewport.Pos.x + viewport.Size.w) / w; |
| 294 | bounds.vMax = (viewport.Pos.y + viewport.Size.h) / h; |
| 295 | } |
| 296 | else |
| 297 | { |
| 298 | bounds.uMax = 1.0f; |
| 299 | bounds.vMax = 1.0f; |
| 300 | } |
| 301 | |
| 302 | if (flags & ovrLayerFlag_TextureOriginAtBottomLeft) |
| 303 | { |
| 304 | bounds.vMin = 1.0f - bounds.vMin; |
| 305 | bounds.vMax = 1.0f - bounds.vMax; |
| 306 | } |
| 307 | |
| 308 | if (GetAPI() == vr::TextureType_OpenGL) |
| 309 | { |
| 310 | bounds.vMin = 1.0f - bounds.vMin; |
| 311 | bounds.vMax = 1.0f - bounds.vMax; |
| 312 | } |
| 313 | |
| 314 | return bounds; |
| 315 | } |
| 316 | |
| 317 | void CompositorBase::BlitLayers(const ovrLayerHeader* dstLayer, const ovrLayerHeader* srcLayer) |
| 318 | { |
nothing calls this directly
no outgoing calls
no test coverage detected