Showing the changes to interface/src/Application.cpp (1 of 216 files). Show all
Unified · Split
| @@ -44,6 +44,9 @@ · 43 unmodified lines | |||
| 44 | 44 | ||
| 45 | #include <QtNetwork/QNetworkDiskCache> | 45 | #include <QtNetwork/QNetworkDiskCache> |
| 46 | 46 | ||
| 47 | #include <gl/Config.h> | ||
| 48 | #include <QtGui/QOpenGLContext> | ||
| 49 | |||
| 47 | #include <AccountManager.h> | 50 | #include <AccountManager.h> |
| 48 | #include <AddressManager.h> | 51 | #include <AddressManager.h> |
| 49 | #include <ApplicationVersion.h> | 52 | #include <ApplicationVersion.h> |
| @@ -110,8 +113,6 @@ · 60 unmodified lines | |||
| 110 | #include "devices/EyeTracker.h" | 113 | #include "devices/EyeTracker.h" |
| 111 | #include "devices/Faceshift.h" | 114 | #include "devices/Faceshift.h" |
| 112 | #include "devices/Leapmotion.h" | 115 | #include "devices/Leapmotion.h" |
| 113 | #include "devices/MIDIManager.h" | ||
| 114 | #include "devices/RealSense.h" | ||
| 115 | #include "DiscoverabilityManager.h" | 116 | #include "DiscoverabilityManager.h" |
| 116 | #include "GLCanvas.h" | 117 | #include "GLCanvas.h" |
| 117 | #include "InterfaceActionFactory.h" | 118 | #include "InterfaceActionFactory.h" |
| @@ -149,6 +150,8 @@ · 31 unmodified lines | |||
| 149 | #include "ui/Stats.h" | 150 | #include "ui/Stats.h" |
| 150 | #include "ui/UpdateDialog.h" | 151 | #include "ui/UpdateDialog.h" |
| 151 | #include "Util.h" | 152 | #include "Util.h" |
| 153 | #include "InterfaceParentFinder.h" | ||
| 154 | |||
| 152 | 155 | ||
| 153 | 156 | ||
| 154 | // ON WIndows PC, NVidia Optimus laptop, we want to enable NVIDIA GPU | 157 | // ON WIndows PC, NVidia Optimus laptop, we want to enable NVIDIA GPU |
| @@ -297,6 +300,7 @@ bool setupEssentials(int& argc, char** argv) { · 142 unmodified lines | |||
| 297 | DependencyManager::registerInheritance<LimitedNodeList, NodeList>(); | 300 | DependencyManager::registerInheritance<LimitedNodeList, NodeList>(); |
| 298 | DependencyManager::registerInheritance<AvatarHashMap, AvatarManager>(); | 301 | DependencyManager::registerInheritance<AvatarHashMap, AvatarManager>(); |
| 299 | DependencyManager::registerInheritance<EntityActionFactoryInterface, InterfaceActionFactory>(); | 302 | DependencyManager::registerInheritance<EntityActionFactoryInterface, InterfaceActionFactory>(); |
| 303 | DependencyManager::registerInheritance<SpatialParentFinder, InterfaceParentFinder>(); | ||
| 300 | 304 | ||
| 301 | Setting::init(); | 305 | Setting::init(); |
| 302 | 306 | ||
| @@ -345,6 +349,7 @@ bool setupEssentials(int& argc, char** argv) { · 42 unmodified lines | |||
| 345 | DependencyManager::set<MessagesClient>(); | 349 | DependencyManager::set<MessagesClient>(); |
| 346 | DependencyManager::set<UserInputMapper>(); | 350 | DependencyManager::set<UserInputMapper>(); |
| 347 | DependencyManager::set<controller::ScriptingInterface, ControllerScriptingInterface>(); | 351 | DependencyManager::set<controller::ScriptingInterface, ControllerScriptingInterface>(); |
| 352 | DependencyManager::set<InterfaceParentFinder>(); | ||
| 348 | return true; | 353 | return true; |
| 349 | } | 354 | } |
| 350 | 355 | ||
| @@ -615,6 +620,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : · 264 unmodified lines | |||
| 615 | 620 | ||
| 616 | // enable mouse tracking; otherwise, we only get drag events | 621 | // enable mouse tracking; otherwise, we only get drag events |
| 617 | _glWidget->setMouseTracking(true); | 622 | _glWidget->setMouseTracking(true); |
| 623 | _glWidget->makeCurrent(); | ||
| 624 | _glWidget->initializeGL(); | ||
| 618 | 625 | ||
| 619 | _offscreenContext = new OffscreenGLCanvas(); | 626 | _offscreenContext = new OffscreenGLCanvas(); |
| 620 | _offscreenContext->create(_glWidget->context()->contextHandle()); | 627 | _offscreenContext->create(_glWidget->context()->contextHandle()); |
| @@ -719,12 +726,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : · 98 unmodified lines | |||
| 719 | // set the local loopback interface for local sounds from audio scripts | 726 | // set the local loopback interface for local sounds from audio scripts |
| 720 | AudioScriptingInterface::getInstance().setLocalAudioInterface(audioIO.data()); | 727 | AudioScriptingInterface::getInstance().setLocalAudioInterface(audioIO.data()); |
| 721 | 728 | ||
| 722 | #ifdef HAVE_RTMIDI | ||
| 723 | // setup the MIDIManager | ||
| 724 | MIDIManager& midiManagerInstance = MIDIManager::getInstance(); | ||
| 725 | midiManagerInstance.openDefaultPort(); | ||
| 726 | #endif | ||
| 727 | |||
| 728 | this->installEventFilter(this); | 729 | this->installEventFilter(this); |
| 729 | 730 | ||
| 730 | // initialize our face trackers after loading the menu settings | 731 | // initialize our face trackers after loading the menu settings |
| @@ -970,7 +971,6 @@ Application::~Application() { · 239 unmodified lines | |||
| 970 | nodeThread->wait(); | 971 | nodeThread->wait(); |
| 971 | 972 | ||
| 972 | Leapmotion::destroy(); | 973 | Leapmotion::destroy(); |
| 973 | RealSense::destroy(); | ||
| 974 | 974 | ||
| 975 | #if 0 | 975 | #if 0 |
| 976 | ConnexionClient::getInstance().destroy(); | 976 | ConnexionClient::getInstance().destroy(); |
| @@ -1141,7 +1141,7 @@ void Application::paintGL() { · 164 unmodified lines | |||
| 1141 | _lastInstantaneousFps = instantaneousFps; | 1141 | _lastInstantaneousFps = instantaneousFps; |
| 1142 | 1142 | ||
| 1143 | auto displayPlugin = getActiveDisplayPlugin(); | 1143 | auto displayPlugin = getActiveDisplayPlugin(); |
| 1144 | displayPlugin->preRender(); | 1144 | // FIXME not needed anymore? |
| 1145 | _offscreenContext->makeCurrent(); | 1145 | _offscreenContext->makeCurrent(); |
| 1146 | 1146 | ||
| 1147 | // update the avatar with a fresh HMD pose | 1147 | // update the avatar with a fresh HMD pose |
| @@ -1196,6 +1196,9 @@ void Application::paintGL() { · 48 unmodified lines | |||
| 1196 | QSize size = getDeviceSize(); | 1196 | QSize size = getDeviceSize(); |
| 1197 | renderArgs._viewport = glm::ivec4(0, 0, size.width(), size.height()); | 1197 | renderArgs._viewport = glm::ivec4(0, 0, size.width(), size.height()); |
| 1198 | _applicationOverlay.renderOverlay(&renderArgs); | 1198 | _applicationOverlay.renderOverlay(&renderArgs); |
| 1199 | gpu::FramebufferPointer overlayFramebuffer = _applicationOverlay.getOverlayFramebuffer(); | ||
| 1200 | |||
| 1201 | |||
| 1199 | } | 1202 | } |
| 1200 | 1203 | ||
| 1201 | { | 1204 | { |
| @@ -1250,7 +1253,7 @@ void Application::paintGL() { · 48 unmodified lines | |||
| 1250 | * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f)) * hmdRotation); | 1253 | * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f)) * hmdRotation); |
| 1251 | glm::vec3 hmdOffset = extractTranslation(myAvatar->getHMDSensorMatrix()); | 1254 | glm::vec3 hmdOffset = extractTranslation(myAvatar->getHMDSensorMatrix()); |
| 1252 | _myCamera.setPosition(myAvatar->getDefaultEyePosition() | 1255 | _myCamera.setPosition(myAvatar->getDefaultEyePosition() |
| 1253 | + glm::vec3(0, _raiseMirror * myAvatar->getScale(), 0) | 1256 | + glm::vec3(0, _raiseMirror * myAvatar->getAvatarScale(), 0) |
| 1254 | + (myAvatar->getOrientation() * glm::quat(glm::vec3(0.0f, _rotateMirror, 0.0f))) * | 1257 | + (myAvatar->getOrientation() * glm::quat(glm::vec3(0.0f, _rotateMirror, 0.0f))) * |
| 1255 | glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_FULLSCREEN_DISTANCE * _scaleMirror | 1258 | glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_FULLSCREEN_DISTANCE * _scaleMirror |
| 1256 | + (myAvatar->getOrientation() * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f))) * hmdOffset); | 1259 | + (myAvatar->getOrientation() * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f))) * hmdOffset); |
| @@ -1258,7 +1261,7 @@ void Application::paintGL() { · 1 unmodified line | |||
| 1258 | _myCamera.setRotation(myAvatar->getWorldAlignedOrientation() | 1261 | _myCamera.setRotation(myAvatar->getWorldAlignedOrientation() |
| 1259 | * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f))); | 1262 | * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f))); |
| 1260 | _myCamera.setPosition(myAvatar->getDefaultEyePosition() | 1263 | _myCamera.setPosition(myAvatar->getDefaultEyePosition() |
| 1261 | + glm::vec3(0, _raiseMirror * myAvatar->getScale(), 0) | 1264 | + glm::vec3(0, _raiseMirror * myAvatar->getAvatarScale(), 0) |
| 1262 | + (myAvatar->getOrientation() * glm::quat(glm::vec3(0.0f, _rotateMirror, 0.0f))) * | 1265 | + (myAvatar->getOrientation() * glm::quat(glm::vec3(0.0f, _rotateMirror, 0.0f))) * |
| 1263 | glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_FULLSCREEN_DISTANCE * _scaleMirror); | 1266 | glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_FULLSCREEN_DISTANCE * _scaleMirror); |
| 1264 | } | 1267 | } |
| @@ -1309,6 +1312,13 @@ void Application::paintGL() { · 44 unmodified lines | |||
| 1309 | auto baseProjection = renderArgs._viewFrustum->getProjection(); | 1312 | auto baseProjection = renderArgs._viewFrustum->getProjection(); |
| 1310 | auto hmdInterface = DependencyManager::get<HMDScriptingInterface>(); | 1313 | auto hmdInterface = DependencyManager::get<HMDScriptingInterface>(); |
| 1311 | float IPDScale = hmdInterface->getIPDScale(); | 1314 | float IPDScale = hmdInterface->getIPDScale(); |
| 1315 | |||
| 1316 | // Tell the plugin what pose we're using to render. In this case we're just using the | ||
| 1317 | // unmodified head pose because the only plugin that cares (the Oculus plugin) uses it | ||
| 1318 | // for rotational timewarp. If we move to support positonal timewarp, we need to | ||
| 1319 | // ensure this contains the full pose composed with the eye offsets. | ||
| 1320 | mat4 headPose = displayPlugin->getHeadPose(_frameCount); | ||
| 1321 | |||
| 1312 | // FIXME we probably don't need to set the projection matrix every frame, | 1322 | // FIXME we probably don't need to set the projection matrix every frame, |
| 1313 | // only when the display plugin changes (or in non-HMD modes when the user | 1323 | // only when the display plugin changes (or in non-HMD modes when the user |
| 1314 | // changes the FOV manually, which right now I don't think they can. | 1324 | // changes the FOV manually, which right now I don't think they can. |
| @@ -1324,12 +1334,7 @@ void Application::paintGL() { · 9 unmodified lines | |||
| 1324 | mat4 eyeOffsetTransform = glm::translate(mat4(), eyeOffset * -1.0f * IPDScale); | 1334 | mat4 eyeOffsetTransform = glm::translate(mat4(), eyeOffset * -1.0f * IPDScale); |
| 1325 | eyeOffsets[eye] = eyeOffsetTransform; | 1335 | eyeOffsets[eye] = eyeOffsetTransform; |
| 1326 | 1336 | ||
| 1327 | // Tell the plugin what pose we're using to render. In this case we're just using the | 1337 | displayPlugin->setEyeRenderPose(_frameCount, eye, headPose); |
| 1328 | // unmodified head pose because the only plugin that cares (the Oculus plugin) uses it | ||
| 1329 | // for rotational timewarp. If we move to support positonal timewarp, we need to | ||
| 1330 | // ensure this contains the full pose composed with the eye offsets. | ||
| 1331 | mat4 headPose = displayPlugin->getHeadPose(); | ||
| 1332 | displayPlugin->setEyeRenderPose(eye, headPose); | ||
| 1333 | 1338 | ||
| 1334 | eyeProjections[eye] = displayPlugin->getProjection(eye, baseProjection); | 1339 | eyeProjections[eye] = displayPlugin->getProjection(eye, baseProjection); |
| 1335 | }); | 1340 | }); |
| @@ -1344,6 +1349,7 @@ void Application::paintGL() { · 8 unmodified lines | |||
| 1344 | } | 1349 | } |
| 1345 | 1350 | ||
| 1346 | // Overlay Composition, needs to occur after screen space effects have completed | 1351 | // Overlay Composition, needs to occur after screen space effects have completed |
| 1352 | // FIXME migrate composition into the display plugins | ||
| 1347 | { | 1353 | { |
| 1348 | PROFILE_RANGE(__FUNCTION__ "/compositor"); | 1354 | PROFILE_RANGE(__FUNCTION__ "/compositor"); |
| 1349 | PerformanceTimer perfTimer("compositor"); | 1355 | PerformanceTimer perfTimer("compositor"); |
| @@ -1372,44 +1378,40 @@ void Application::paintGL() { · 22 unmodified lines | |||
| 1372 | { | 1378 | { |
| 1373 | PROFILE_RANGE(__FUNCTION__ "/pluginOutput"); | 1379 | PROFILE_RANGE(__FUNCTION__ "/pluginOutput"); |
| 1374 | PerformanceTimer perfTimer("pluginOutput"); | 1380 | PerformanceTimer perfTimer("pluginOutput"); |
| 1375 | auto primaryFbo = framebufferCache->getPrimaryFramebuffer(); | 1381 | auto primaryFramebuffer = framebufferCache->getPrimaryFramebuffer(); |
| 1376 | GLuint finalTexture = gpu::GLBackend::getTextureID(primaryFbo->getRenderBuffer(0)); | 1382 | auto scratchFramebuffer = framebufferCache->getFramebuffer(); |
| 1377 | // Ensure the rendering context commands are completed when rendering | 1383 | gpu::doInBatch(renderArgs._context, [=](gpu::Batch& batch) { |
| 1378 | GLsync sync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0); | 1384 | gpu::Vec4i rect; |
| 1379 | // Ensure the sync object is flushed to the driver thread before releasing the context | 1385 | rect.z = size.width(); |
| 1380 | // CRITICAL for the mac driver apparently. | 1386 | rect.w = size.height(); |
| 1381 | glFlush(); | 1387 | batch.setFramebuffer(scratchFramebuffer); |
| 1382 | _offscreenContext->doneCurrent(); | 1388 | batch.clearColorFramebuffer(gpu::Framebuffer::BUFFER_COLOR0, glm::vec4(0.0f, 0.0f, 0.0f, 0.0f)); |
| 1383 | 1389 | batch.blit(primaryFramebuffer, rect, scratchFramebuffer, rect); | |
| 1384 | // Switches to the display plugin context | 1390 | batch.setFramebuffer(nullptr); |
| 1385 | displayPlugin->preDisplay(); | 1391 | }); |
| 1386 | // Ensure all operations from the previous context are complete before we try to read the fbo | 1392 | auto finalTexturePointer = scratchFramebuffer->getRenderBuffer(0); |
| 1387 | glWaitSync(sync, 0, GL_TIMEOUT_IGNORED); | 1393 | GLuint finalTexture = gpu::GLBackend::getTextureID(finalTexturePointer); |
| 1388 | glDeleteSync(sync); | 1394 | Q_ASSERT(0 != finalTexture); |
| 1389 | uint64_t displayStart = usecTimestampNow(); | ||
| 1390 | 1395 | ||
| 1391 | { | 1396 | Q_ASSERT(!_lockedFramebufferMap.contains(finalTexture)); |
| 1392 | PROFILE_RANGE(__FUNCTION__ "/pluginDisplay"); | 1397 | _lockedFramebufferMap[finalTexture] = scratchFramebuffer; |
| 1393 | PerformanceTimer perfTimer("pluginDisplay"); | ||
| 1394 | displayPlugin->display(finalTexture, toGlm(size)); | ||
| 1395 | } | ||
| 1396 | 1398 | ||
| 1399 | uint64_t displayStart = usecTimestampNow(); | ||
| 1400 | Q_ASSERT(QOpenGLContext::currentContext() == _offscreenContext->getContext()); | ||
| 1397 | { | 1401 | { |
| 1398 | PROFILE_RANGE(__FUNCTION__ "/bufferSwap"); | 1402 | PROFILE_RANGE(__FUNCTION__ "/pluginSubmitScene"); |
| 1399 | PerformanceTimer perfTimer("bufferSwap"); | 1403 | PerformanceTimer perfTimer("pluginSubmitScene"); |
| 1400 | displayPlugin->finishFrame(); | 1404 | displayPlugin->submitSceneTexture(_frameCount, finalTexture, toGlm(size)); |
| 1401 | } | 1405 | } |
| 1406 | Q_ASSERT(QOpenGLContext::currentContext() == _offscreenContext->getContext()); | ||
| 1407 | |||
| 1402 | uint64_t displayEnd = usecTimestampNow(); | 1408 | uint64_t displayEnd = usecTimestampNow(); |
| 1403 | const float displayPeriodUsec = (float)(displayEnd - displayStart); // usecs | 1409 | const float displayPeriodUsec = (float)(displayEnd - displayStart); // usecs |
| 1404 | _lastPaintWait = displayPeriodUsec / (float)USECS_PER_SECOND; | 1410 | _lastPaintWait = displayPeriodUsec / (float)USECS_PER_SECOND; |
| 1405 | |||
| 1406 | } | 1411 | } |
| 1407 | 1412 | ||
| 1408 | { | 1413 | { |
| 1409 | PerformanceTimer perfTimer("makeCurrent"); | ||
| 1410 | _offscreenContext->makeCurrent(); | ||
| 1411 | Stats::getInstance()->setRenderDetails(renderArgs._details); | 1414 | Stats::getInstance()->setRenderDetails(renderArgs._details); |
| 1412 | |||
| 1413 | // Reset the gpu::Context Stages | 1415 | // Reset the gpu::Context Stages |
| 1414 | // Back to the default framebuffer; | 1416 | // Back to the default framebuffer; |
| 1415 | gpu::doInBatch(renderArgs._context, [=](gpu::Batch& batch) { | 1417 | gpu::doInBatch(renderArgs._context, [=](gpu::Batch& batch) { |
| @@ -2519,7 +2521,6 @@ void Application::init() { · 1103 unmodified lines | |||
| 2519 | qCDebug(interfaceapp) << "Loaded settings"; | 2521 | qCDebug(interfaceapp) << "Loaded settings"; |
| 2520 | 2522 | ||
| 2521 | Leapmotion::init(); | 2523 | Leapmotion::init(); |
| 2522 | RealSense::init(); | ||
| 2523 | 2524 | ||
| 2524 | // fire off an immediate domain-server check in now that settings are loaded | 2525 | // fire off an immediate domain-server check in now that settings are loaded |
| 2525 | DependencyManager::get<NodeList>()->sendDomainServerCheckIn(); | 2526 | DependencyManager::get<NodeList>()->sendDomainServerCheckIn(); |
| @@ -2618,7 +2619,7 @@ void Application::updateMyAvatarLookAtPosition() { · 92 unmodified lines | |||
| 2618 | lookAtPosition.x = -lookAtPosition.x; | 2619 | lookAtPosition.x = -lookAtPosition.x; |
| 2619 | } | 2620 | } |
| 2620 | if (isHMD) { | 2621 | if (isHMD) { |
| 2621 | glm::mat4 headPose = getActiveDisplayPlugin()->getHeadPose(); | 2622 | glm::mat4 headPose = getActiveDisplayPlugin()->getHeadPose(_frameCount); |
| 2622 | glm::quat hmdRotation = glm::quat_cast(headPose); | 2623 | glm::quat hmdRotation = glm::quat_cast(headPose); |
| 2623 | lookAtSpot = _myCamera.getPosition() + myAvatar->getOrientation() * (hmdRotation * lookAtPosition); | 2624 | lookAtSpot = _myCamera.getPosition() + myAvatar->getOrientation() * (hmdRotation * lookAtPosition); |
| 2624 | } else { | 2625 | } else { |
| @@ -3075,6 +3076,7 @@ void Application::queryOctree(NodeType_t serverType, PacketType packetType, Node · 450 unmodified lines | |||
| 3075 | // These will be the same for all servers, so we can set them up once and then reuse for each server we send to. | 3076 | // These will be the same for all servers, so we can set them up once and then reuse for each server we send to. |
| 3076 | _octreeQuery.setWantLowResMoving(true); | 3077 | _octreeQuery.setWantLowResMoving(true); |
| 3077 | _octreeQuery.setWantDelta(true); | 3078 | _octreeQuery.setWantDelta(true); |
| 3079 | _octreeQuery.setWantCompression(true); | ||
| 3078 | 3080 | ||
| 3079 | _octreeQuery.setCameraPosition(_viewFrustum.getPosition()); | 3081 | _octreeQuery.setCameraPosition(_viewFrustum.getPosition()); |
| 3080 | _octreeQuery.setCameraOrientation(_viewFrustum.getOrientation()); | 3082 | _octreeQuery.setCameraOrientation(_viewFrustum.getOrientation()); |
| @@ -3322,7 +3324,7 @@ MyAvatar* Application::getMyAvatar() const { · 241 unmodified lines | |||
| 3322 | return DependencyManager::get<AvatarManager>()->getMyAvatar(); | 3324 | return DependencyManager::get<AvatarManager>()->getMyAvatar(); |
| 3323 | } | 3325 | } |
| 3324 | 3326 | ||
| 3325 | const glm::vec3& Application::getAvatarPosition() const { | 3327 | glm::vec3 Application::getAvatarPosition() const { |
| 3326 | return getMyAvatar()->getPosition(); | 3328 | return getMyAvatar()->getPosition(); |
| 3327 | } | 3329 | } |
| 3328 | 3330 | ||
| @@ -4069,10 +4071,6 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri · 740 unmodified lines | |||
| 4069 | scriptEngine->registerGlobalObject("Scene", DependencyManager::get<SceneScriptingInterface>().data()); | 4071 | scriptEngine->registerGlobalObject("Scene", DependencyManager::get<SceneScriptingInterface>().data()); |
| 4070 | 4072 | ||
| 4071 | scriptEngine->registerGlobalObject("ScriptDiscoveryService", this->getRunningScriptsWidget()); | 4073 | scriptEngine->registerGlobalObject("ScriptDiscoveryService", this->getRunningScriptsWidget()); |
| 4072 | |||
| 4073 | #ifdef HAVE_RTMIDI | ||
| 4074 | scriptEngine->registerGlobalObject("MIDI", &MIDIManager::getInstance()); | ||
| 4075 | #endif | ||
| 4076 | } | 4074 | } |
| 4077 | 4075 | ||
| 4078 | bool Application::canAcceptURL(const QString& urlString) { | 4076 | bool Application::canAcceptURL(const QString& urlString) { |
| @@ -4520,7 +4518,7 @@ void Application::takeSnapshot() { · 441 unmodified lines | |||
| 4520 | player->setMedia(QUrl::fromLocalFile(inf.absoluteFilePath())); | 4518 | player->setMedia(QUrl::fromLocalFile(inf.absoluteFilePath())); |
| 4521 | player->play(); | 4519 | player->play(); |
| 4522 | 4520 | ||
| 4523 | QString fileName = Snapshot::saveSnapshot(_glWidget->grabFrameBuffer()); | 4521 | QString fileName = Snapshot::saveSnapshot(getActiveDisplayPlugin()->getScreenshot()); |
| 4524 | 4522 | ||
| 4525 | AccountManager& accountManager = AccountManager::getInstance(); | 4523 | AccountManager& accountManager = AccountManager::getInstance(); |
| 4526 | if (!accountManager.isLoggedIn()) { | 4524 | if (!accountManager.isLoggedIn()) { |
| @@ -4531,7 +4529,6 @@ void Application::takeSnapshot() { · 4 unmodified lines | |||
| 4531 | _snapshotShareDialog = new SnapshotShareDialog(fileName, _glWidget); | 4529 | _snapshotShareDialog = new SnapshotShareDialog(fileName, _glWidget); |
| 4532 | } | 4530 | } |
| 4533 | _snapshotShareDialog->show(); | 4531 | _snapshotShareDialog->show(); |
| 4534 | |||
| 4535 | } | 4532 | } |
| 4536 | 4533 | ||
| 4537 | float Application::getRenderResolutionScale() const { | 4534 | float Application::getRenderResolutionScale() const { |
| @@ -4714,10 +4711,6 @@ const DisplayPlugin* Application::getActiveDisplayPlugin() const { · 176 unmodified lines | |||
| 4714 | return ((Application*)this)->getActiveDisplayPlugin(); | 4711 | return ((Application*)this)->getActiveDisplayPlugin(); |
| 4715 | } | 4712 | } |
| 4716 | 4713 | ||
| 4717 | bool _activatingDisplayPlugin{ false }; | ||
| 4718 | QVector<QPair<QString, QString>> _currentDisplayPluginActions; | ||
| 4719 | QVector<QPair<QString, QString>> _currentInputPluginActions; | ||
| 4720 | |||
| 4721 | static void addDisplayPluginToMenu(DisplayPluginPointer displayPlugin, bool active = false) { | 4714 | static void addDisplayPluginToMenu(DisplayPluginPointer displayPlugin, bool active = false) { |
| 4722 | auto menu = Menu::getInstance(); | 4715 | auto menu = Menu::getInstance(); |
| 4723 | QString name = displayPlugin->getName(); | 4716 | QString name = displayPlugin->getName(); |
| @@ -4747,9 +4740,10 @@ void Application::updateDisplayMode() { · 23 unmodified lines | |||
| 4747 | bool first = true; | 4740 | bool first = true; |
| 4748 | foreach(auto displayPlugin, displayPlugins) { | 4741 | foreach(auto displayPlugin, displayPlugins) { |
| 4749 | addDisplayPluginToMenu(displayPlugin, first); | 4742 | addDisplayPluginToMenu(displayPlugin, first); |
| 4750 | QObject::connect(displayPlugin.get(), &DisplayPlugin::requestRender, [this] { | 4743 | // This must be a queued connection to avoid a deadlock |
| 4751 | paintGL(); | 4744 | QObject::connect(displayPlugin.get(), &DisplayPlugin::requestRender, |
| 4752 | }); | 4745 | this, &Application::paintGL, Qt::QueuedConnection); |
| 4746 | |||
| 4753 | QObject::connect(displayPlugin.get(), &DisplayPlugin::recommendedFramebufferSizeChanged, [this](const QSize & size) { | 4747 | QObject::connect(displayPlugin.get(), &DisplayPlugin::recommendedFramebufferSizeChanged, [this](const QSize & size) { |
| 4754 | resizeGL(); | 4748 | resizeGL(); |
| 4755 | }); | 4749 | }); |
| @@ -4791,19 +4785,18 @@ void Application::updateDisplayMode() { · 35 unmodified lines | |||
| 4791 | return; | 4785 | return; |
| 4792 | } | 4786 | } |
| 4793 | 4787 | ||
| 4794 | if (!_currentDisplayPluginActions.isEmpty()) { | 4788 | |
| 4789 | if (!_pluginContainer->currentDisplayActions().isEmpty()) { | ||
| 4795 | auto menu = Menu::getInstance(); | 4790 | auto menu = Menu::getInstance(); |
| 4796 | foreach(auto itemInfo, _currentDisplayPluginActions) { | 4791 | foreach(auto itemInfo, _pluginContainer->currentDisplayActions()) { |
| 4797 | menu->removeMenuItem(itemInfo.first, itemInfo.second); | 4792 | menu->removeMenuItem(itemInfo.first, itemInfo.second); |
| 4798 | } | 4793 | } |
| 4799 | _currentDisplayPluginActions.clear(); | 4794 | _pluginContainer->currentDisplayActions().clear(); |
| 4800 | } | 4795 | } |
| 4801 | 4796 | ||
| 4802 | if (newDisplayPlugin) { | 4797 | if (newDisplayPlugin) { |
| 4803 | _offscreenContext->makeCurrent(); | 4798 | _offscreenContext->makeCurrent(); |
| 4804 | _activatingDisplayPlugin = true; | ||
| 4805 | newDisplayPlugin->activate(); | 4799 | newDisplayPlugin->activate(); |
| 4806 | _activatingDisplayPlugin = false; | ||
| 4807 | _offscreenContext->makeCurrent(); | 4800 | _offscreenContext->makeCurrent(); |
| 4808 | offscreenUi->resize(fromGlm(newDisplayPlugin->getRecommendedUiSize())); | 4801 | offscreenUi->resize(fromGlm(newDisplayPlugin->getRecommendedUiSize())); |
| 4809 | _offscreenContext->makeCurrent(); | 4802 | _offscreenContext->makeCurrent(); |
| @@ -4929,7 +4922,7 @@ mat4 Application::getEyeOffset(int eye) const { · 119 unmodified lines | |||
| 4929 | 4922 | ||
| 4930 | mat4 Application::getHMDSensorPose() const { | 4923 | mat4 Application::getHMDSensorPose() const { |
| 4931 | if (isHMDMode()) { | 4924 | if (isHMDMode()) { |
| 4932 | return getActiveDisplayPlugin()->getHeadPose(); | 4925 | return getActiveDisplayPlugin()->getHeadPose(_frameCount); |
| 4933 | } | 4926 | } |
| 4934 | return mat4(); | 4927 | return mat4(); |
| 4935 | } | 4928 | } |