History

Working on SDK 0.6

Bradley Austin Davis committed 11 years ago

Commit 5a52a381 parent de268c47 files · +42 −43Browse files

Showing the changes to interface/src/devices/OculusManager.cpp (1 of 7 files). Show all

Unified · Split

interface/src/devices/OculusManager.cpp+28−38
@@ -177,6 +177,7 @@ ovrLayerEyeFov OculusManager::_sceneLayer; · 176 unmodified lines
177177
178178 #else
179179
180+BasicFramebufferWrapper* _transferFbo;
180181 ovrTexture OculusManager::_eyeTextures[ovrEye_Count];
181182 GlWindow* OculusManager::_outputWindow{ nullptr };
182183
@@ -296,11 +297,24 @@ void OculusManager::connect(QOpenGLContext* shareContext) { · 113 unmodified lines
296297 #else
297298 _outputWindow = new GlWindow(shareContext);
298299 _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();
302312 _outputWindow->makeCurrent();
303−
313+ _transferFbo = new BasicFramebufferWrapper();
314+ _transferFbo->Init(toGlm(_renderTargetSize));
315+
316+
317+
304318 ovrGLConfig cfg;
305319 memset(&cfg, 0, sizeof(cfg));
306320 cfg.OGL.Header.API = ovrRenderAPI_OpenGL;
@@ -315,7 +329,7 @@ void OculusManager::connect(QOpenGLContext* shareContext) { · 8 unmodified lines
315329 int configResult = ovrHmd_ConfigureRendering(_ovrHmd, &cfg.Config,
316330 distortionCaps, _eyeFov, _eyeRenderDesc);
317331 assert(configResult);
318−
332+ _outputWindow->doneCurrent();
319333
320334 for_each_eye([&](ovrEyeType eye) {
321335 //Get texture size
@@ -358,6 +372,10 @@ void OculusManager::disconnect() { · 36 unmodified lines
358372 delete _mirrorFbo;
359373 _mirrorFbo = nullptr;
360374 }
375+#else
376+ _outputWindow->showNormal();
377+ _outputWindow->deleteLater();
378+ _outputWindow = nullptr;
361379 #endif
362380
363381 if (_ovrHmd) {
@@ -535,28 +553,11 @@ void OculusManager::display(QGLWidget * glCanvas, const glm::quat &bodyOrientati · 171 unmodified lines
535553 assert(oldFrameIndex == -1 || (unsigned int)oldFrameIndex == _frameIndex - 1);
536554 oldFrameIndex = _frameIndex;
537555 #endif
538−
539− // Every so often do some additional timing calculations and debug output
540− bool debugFrame = 0 == _frameIndex % 400;
541556
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();
551559 }
552560
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−
560561 #ifndef Q_OS_WIN
561562 // FIXME: we need a better way of responding to the HSW. In particular
562563 // 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
573574 }
574575 }
575576 #endif
576−
577577
578578 //beginFrameTiming must be called before display
579579 if (!_frameTimingActive) {
@@ -718,26 +718,16 @@ void OculusManager::display(QGLWidget * glCanvas, const glm::quat &bodyOrientati · 138 unmodified lines
718718 Q_ASSERT(OVR_SUCCESS(res));
719719 _swapFbo->Increment();
720720 #else
721+ glFinish();
721722 GLuint textureId = gpu::GLBackend::getTextureID(finalFbo->getRenderBuffer(0));
723+ _outputWindow->makeCurrent();
722724 for_each_eye([&](ovrEyeType eye) {
723725 ovrGLTexture & glEyeTexture = reinterpret_cast<ovrGLTexture&>(_eyeTextures[eye]);
724726 glEyeTexture.OGL.TexId = textureId;
725727 });
726−
727− _outputWindow->makeCurrent();
728728 // restore our normal viewport
729729 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();
741731 #endif
742732
743733