Showing the changes to interface/src/devices/OculusManager.cpp (1 of 7 files). Show all
Unified · Split
| @@ -177,6 +177,7 @@ ovrLayerEyeFov OculusManager::_sceneLayer; · 176 unmodified lines | ||
| 177 | 177 | |
| 178 | 178 | #else |
| 179 | 179 | |
| 180 | +BasicFramebufferWrapper* _transferFbo; | |
| 180 | 181 | ovrTexture OculusManager::_eyeTextures[ovrEye_Count]; |
| 181 | 182 | GlWindow* OculusManager::_outputWindow{ nullptr }; |
| 182 | 183 | |
| @@ -296,11 +297,24 @@ void OculusManager::connect(QOpenGLContext* shareContext) { · 113 unmodified lines | ||
| 296 | 297 | #else |
| 297 | 298 | _outputWindow = new GlWindow(shareContext); |
| 298 | 299 | _outputWindow->show(); |
| 299 | − _outputWindow->setFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint); | |
| 300 | − _outputWindow->resize(_ovrHmd->Resolution.w, _ovrHmd->Resolution.h); | |
| 301 | − // _outputWindow->setPosition(_ovrHmd->Position.x, _ovrHmd->Position.y); | |
| 300 | +// _outputWindow->setFlags(Qt::FramelessWindowHint ); | |
| 301 | +// _outputWindow->resize(_ovrHmd->Resolution.w, _ovrHmd->Resolution.h); | |
| 302 | +// _outputWindow->setPosition(_ovrHmd->WindowsPos.x, _ovrHmd->WindowsPos.y); | |
| 303 | + ivec2 desiredPosition = toGlm(_ovrHmd->WindowsPos); | |
| 304 | + foreach(QScreen* screen, qGuiApp->screens()) { | |
| 305 | + ivec2 screenPosition = toGlm(screen->geometry().topLeft()); | |
| 306 | + if (screenPosition == desiredPosition) { | |
| 307 | + _outputWindow->setScreen(screen); | |
| 308 | + break; | |
| 309 | + } | |
| 310 | + } | |
| 311 | + _outputWindow->showFullScreen(); | |
| 302 | 312 | _outputWindow->makeCurrent(); |
| 303 | − | |
| 313 | + _transferFbo = new BasicFramebufferWrapper(); | |
| 314 | + _transferFbo->Init(toGlm(_renderTargetSize)); | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 304 | 318 | ovrGLConfig cfg; |
| 305 | 319 | memset(&cfg, 0, sizeof(cfg)); |
| 306 | 320 | cfg.OGL.Header.API = ovrRenderAPI_OpenGL; |
| @@ -315,7 +329,7 @@ void OculusManager::connect(QOpenGLContext* shareContext) { · 8 unmodified lines | ||
| 315 | 329 | int configResult = ovrHmd_ConfigureRendering(_ovrHmd, &cfg.Config, |
| 316 | 330 | distortionCaps, _eyeFov, _eyeRenderDesc); |
| 317 | 331 | assert(configResult); |
| 318 | − | |
| 332 | + _outputWindow->doneCurrent(); | |
| 319 | 333 | |
| 320 | 334 | for_each_eye([&](ovrEyeType eye) { |
| 321 | 335 | //Get texture size |
| @@ -358,6 +372,10 @@ void OculusManager::disconnect() { · 36 unmodified lines | ||
| 358 | 372 | delete _mirrorFbo; |
| 359 | 373 | _mirrorFbo = nullptr; |
| 360 | 374 | } |
| 375 | +#else | |
| 376 | + _outputWindow->showNormal(); | |
| 377 | + _outputWindow->deleteLater(); | |
| 378 | + _outputWindow = nullptr; | |
| 361 | 379 | #endif |
| 362 | 380 | |
| 363 | 381 | if (_ovrHmd) { |
| @@ -535,28 +553,11 @@ void OculusManager::display(QGLWidget * glCanvas, const glm::quat &bodyOrientati · 171 unmodified lines | ||
| 535 | 553 | assert(oldFrameIndex == -1 || (unsigned int)oldFrameIndex == _frameIndex - 1); |
| 536 | 554 | oldFrameIndex = _frameIndex; |
| 537 | 555 | #endif |
| 538 | − | |
| 539 | − // Every so often do some additional timing calculations and debug output | |
| 540 | − bool debugFrame = 0 == _frameIndex % 400; | |
| 541 | 556 | |
| 542 | −#if 0 | |
| 543 | − // Try to measure the amount of time taken to do the distortion | |
| 544 | − // (does not seem to work on OSX with SDK based distortion) | |
| 545 | − // FIXME can't use a static object here, because it will cause a crash when the | |
| 546 | − // query attempts deconstruct after the GL context is gone. | |
| 547 | − static bool timerActive = false; | |
| 548 | − static QOpenGLTimerQuery timerQuery; | |
| 549 | − if (!timerQuery.isCreated()) { | |
| 550 | − timerQuery.create(); | |
| 557 | + if (_outputWindow->visibility() != QWindow::FullScreen) { | |
| 558 | + // _outputWindow->showFullScreen(); | |
| 551 | 559 | } |
| 552 | 560 | |
| 553 | − if (timerActive && timerQuery.isResultAvailable()) { | |
| 554 | − auto result = timerQuery.waitForResult(); | |
| 555 | − if (result) { qCDebug(interfaceapp) << "Distortion took " << result << "ns"; }; | |
| 556 | − timerActive = false; | |
| 557 | − } | |
| 558 | −#endif | |
| 559 | − | |
| 560 | 561 | #ifndef Q_OS_WIN |
| 561 | 562 | // FIXME: we need a better way of responding to the HSW. In particular |
| 562 | 563 | // we need to ensure that it's only displayed once per session, rather than |
| @@ -573,7 +574,6 @@ void OculusManager::display(QGLWidget * glCanvas, const glm::quat &bodyOrientati · 10 unmodified lines | ||
| 573 | 574 | } |
| 574 | 575 | } |
| 575 | 576 | #endif |
| 576 | − | |
| 577 | 577 | |
| 578 | 578 | //beginFrameTiming must be called before display |
| 579 | 579 | if (!_frameTimingActive) { |
| @@ -718,26 +718,16 @@ void OculusManager::display(QGLWidget * glCanvas, const glm::quat &bodyOrientati · 138 unmodified lines | ||
| 718 | 718 | Q_ASSERT(OVR_SUCCESS(res)); |
| 719 | 719 | _swapFbo->Increment(); |
| 720 | 720 | #else |
| 721 | + glFinish(); | |
| 721 | 722 | GLuint textureId = gpu::GLBackend::getTextureID(finalFbo->getRenderBuffer(0)); |
| 723 | + _outputWindow->makeCurrent(); | |
| 722 | 724 | for_each_eye([&](ovrEyeType eye) { |
| 723 | 725 | ovrGLTexture & glEyeTexture = reinterpret_cast<ovrGLTexture&>(_eyeTextures[eye]); |
| 724 | 726 | glEyeTexture.OGL.TexId = textureId; |
| 725 | 727 | }); |
| 726 | − | |
| 727 | − _outputWindow->makeCurrent(); | |
| 728 | 728 | // restore our normal viewport |
| 729 | 729 | ovrHmd_EndFrame(_ovrHmd, eyeRenderPose, _eyeTextures); |
| 730 | − | |
| 731 | − //auto outputSize = _outputWindow->size(); | |
| 732 | − //glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); | |
| 733 | − //auto srcFboSize = finalFbo->getSize(); | |
| 734 | − //glBindFramebuffer(GL_READ_FRAMEBUFFER, gpu::GLBackend::getFramebufferID(finalFbo)); | |
| 735 | − //glBlitFramebuffer( | |
| 736 | − // 0, 0, srcFboSize.x, srcFboSize.y, | |
| 737 | − // 0, 0, outputSize.width(), outputSize.height(), | |
| 738 | − // GL_COLOR_BUFFER_BIT, GL_NEAREST); | |
| 739 | − //glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); | |
| 740 | − //glCanvas->swapBuffers(); | |
| 730 | + glCanvas->makeCurrent(); | |
| 741 | 731 | #endif |
| 742 | 732 | |
| 743 | 733 | |