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 | #else | 178 | #else |
| 179 | 179 | ||
| 180 | BasicFramebufferWrapper* _transferFbo; | ||
| 180 | ovrTexture OculusManager::_eyeTextures[ovrEye_Count]; | 181 | ovrTexture OculusManager::_eyeTextures[ovrEye_Count]; |
| 181 | GlWindow* OculusManager::_outputWindow{ nullptr }; | 182 | GlWindow* OculusManager::_outputWindow{ nullptr }; |
| 182 | 183 | ||
| @@ -296,11 +297,24 @@ void OculusManager::connect(QOpenGLContext* shareContext) { · 113 unmodified lines | |||
| 296 | #else | 297 | #else |
| 297 | _outputWindow = new GlWindow(shareContext); | 298 | _outputWindow = new GlWindow(shareContext); |
| 298 | _outputWindow->show(); | 299 | _outputWindow->show(); |
| 299 | _outputWindow->setFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint); | 300 | // _outputWindow->setFlags(Qt::FramelessWindowHint ); |
| 300 | _outputWindow->resize(_ovrHmd->Resolution.w, _ovrHmd->Resolution.h); | 301 | // _outputWindow->resize(_ovrHmd->Resolution.w, _ovrHmd->Resolution.h); |
| 301 | // _outputWindow->setPosition(_ovrHmd->Position.x, _ovrHmd->Position.y); | 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 | _outputWindow->makeCurrent(); | 312 | _outputWindow->makeCurrent(); |
| 303 | 313 | _transferFbo = new BasicFramebufferWrapper(); | |
| 314 | _transferFbo->Init(toGlm(_renderTargetSize)); | ||
| 315 | |||
| 316 | |||
| 317 | |||
| 304 | ovrGLConfig cfg; | 318 | ovrGLConfig cfg; |
| 305 | memset(&cfg, 0, sizeof(cfg)); | 319 | memset(&cfg, 0, sizeof(cfg)); |
| 306 | cfg.OGL.Header.API = ovrRenderAPI_OpenGL; | 320 | cfg.OGL.Header.API = ovrRenderAPI_OpenGL; |
| @@ -315,7 +329,7 @@ void OculusManager::connect(QOpenGLContext* shareContext) { · 8 unmodified lines | |||
| 315 | int configResult = ovrHmd_ConfigureRendering(_ovrHmd, &cfg.Config, | 329 | int configResult = ovrHmd_ConfigureRendering(_ovrHmd, &cfg.Config, |
| 316 | distortionCaps, _eyeFov, _eyeRenderDesc); | 330 | distortionCaps, _eyeFov, _eyeRenderDesc); |
| 317 | assert(configResult); | 331 | assert(configResult); |
| 318 | 332 | _outputWindow->doneCurrent(); | |
| 319 | 333 | ||
| 320 | for_each_eye([&](ovrEyeType eye) { | 334 | for_each_eye([&](ovrEyeType eye) { |
| 321 | //Get texture size | 335 | //Get texture size |
| @@ -358,6 +372,10 @@ void OculusManager::disconnect() { · 36 unmodified lines | |||
| 358 | delete _mirrorFbo; | 372 | delete _mirrorFbo; |
| 359 | _mirrorFbo = nullptr; | 373 | _mirrorFbo = nullptr; |
| 360 | } | 374 | } |
| 375 | #else | ||
| 376 | _outputWindow->showNormal(); | ||
| 377 | _outputWindow->deleteLater(); | ||
| 378 | _outputWindow = nullptr; | ||
| 361 | #endif | 379 | #endif |
| 362 | 380 | ||
| 363 | if (_ovrHmd) { | 381 | if (_ovrHmd) { |
| @@ -535,28 +553,11 @@ void OculusManager::display(QGLWidget * glCanvas, const glm::quat &bodyOrientati · 171 unmodified lines | |||
| 535 | assert(oldFrameIndex == -1 || (unsigned int)oldFrameIndex == _frameIndex - 1); | 553 | assert(oldFrameIndex == -1 || (unsigned int)oldFrameIndex == _frameIndex - 1); |
| 536 | oldFrameIndex = _frameIndex; | 554 | oldFrameIndex = _frameIndex; |
| 537 | #endif | 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 | 557 | if (_outputWindow->visibility() != QWindow::FullScreen) { |
| 543 | // Try to measure the amount of time taken to do the distortion | 558 | // _outputWindow->showFullScreen(); |
| 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(); | ||
| 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 | #ifndef Q_OS_WIN | 561 | #ifndef Q_OS_WIN |
| 561 | // FIXME: we need a better way of responding to the HSW. In particular | 562 | // FIXME: we need a better way of responding to the HSW. In particular |
| 562 | // we need to ensure that it's only displayed once per session, rather than | 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 | #endif | 576 | #endif |
| 576 | |||
| 577 | 577 | ||
| 578 | //beginFrameTiming must be called before display | 578 | //beginFrameTiming must be called before display |
| 579 | if (!_frameTimingActive) { | 579 | if (!_frameTimingActive) { |
| @@ -718,26 +718,16 @@ void OculusManager::display(QGLWidget * glCanvas, const glm::quat &bodyOrientati · 138 unmodified lines | |||
| 718 | Q_ASSERT(OVR_SUCCESS(res)); | 718 | Q_ASSERT(OVR_SUCCESS(res)); |
| 719 | _swapFbo->Increment(); | 719 | _swapFbo->Increment(); |
| 720 | #else | 720 | #else |
| 721 | glFinish(); | ||
| 721 | GLuint textureId = gpu::GLBackend::getTextureID(finalFbo->getRenderBuffer(0)); | 722 | GLuint textureId = gpu::GLBackend::getTextureID(finalFbo->getRenderBuffer(0)); |
| 723 | _outputWindow->makeCurrent(); | ||
| 722 | for_each_eye([&](ovrEyeType eye) { | 724 | for_each_eye([&](ovrEyeType eye) { |
| 723 | ovrGLTexture & glEyeTexture = reinterpret_cast<ovrGLTexture&>(_eyeTextures[eye]); | 725 | ovrGLTexture & glEyeTexture = reinterpret_cast<ovrGLTexture&>(_eyeTextures[eye]); |
| 724 | glEyeTexture.OGL.TexId = textureId; | 726 | glEyeTexture.OGL.TexId = textureId; |
| 725 | }); | 727 | }); |
| 726 | |||
| 727 | _outputWindow->makeCurrent(); | ||
| 728 | // restore our normal viewport | 728 | // restore our normal viewport |
| 729 | ovrHmd_EndFrame(_ovrHmd, eyeRenderPose, _eyeTextures); | 729 | ovrHmd_EndFrame(_ovrHmd, eyeRenderPose, _eyeTextures); |
| 730 | 730 | glCanvas->makeCurrent(); | |
| 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(); | ||
| 741 | #endif | 731 | #endif |
| 742 | 732 | ||
| 743 | 733 | ||