MCPcopy Create free account
hub / github.com/LibreVR/Revive / ViewportToTextureBounds

Method ViewportToTextureBounds

Revive/CompositorBase.cpp:281–315  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

279}
280
281vr::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
317void CompositorBase::BlitLayers(const ovrLayerHeader* dstLayer, const ovrLayerHeader* srcLayer)
318{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected