Showing the changes to interface/src/ui/ApplicationOverlay.cpp (1 of 35 files). Show all
Unified · Split
| @@ -12,10 +12,13 @@ · 11 unmodified lines | |||
| 12 | #include "InterfaceConfig.h" | 12 | #include "InterfaceConfig.h" |
| 13 | 13 | ||
| 14 | #include <QOpenGLFramebufferObject> | 14 | #include <QOpenGLFramebufferObject> |
| 15 | #include <QOpenGLTexture> | ||
| 15 | 16 | ||
| 16 | #include <avatar/AvatarManager.h> | 17 | #include <avatar/AvatarManager.h> |
| 17 | #include <GLMHelpers.h> | 18 | #include <GLMHelpers.h> |
| 18 | #include <PathUtils.h> | 19 | #include <PathUtils.h> |
| 20 | #include <gpu/GLBackend.h> | ||
| 21 | #include <GLMHelpers.h> | ||
| 19 | #include <PerfStat.h> | 22 | #include <PerfStat.h> |
| 20 | #include <OffscreenUi.h> | 23 | #include <OffscreenUi.h> |
| 21 | 24 | ||
| @@ -25,7 +28,6 @@ · 3 unmodified lines | |||
| 25 | #include "audio/AudioToolBox.h" | 28 | #include "audio/AudioToolBox.h" |
| 26 | #include "Application.h" | 29 | #include "Application.h" |
| 27 | #include "ApplicationOverlay.h" | 30 | #include "ApplicationOverlay.h" |
| 28 | #include "devices/OculusManager.h" | ||
| 29 | 31 | ||
| 30 | #include "Util.h" | 32 | #include "Util.h" |
| 31 | #include "ui/Stats.h" | 33 | #include "ui/Stats.h" |
| @@ -45,7 +47,7 @@ const float CONNECTION_STATUS_BORDER_LINE_WIDTH = 4.0f; · 13 unmodified lines | |||
| 45 | 47 | ||
| 46 | static const float MOUSE_PITCH_RANGE = 1.0f * PI; | 48 | static const float MOUSE_PITCH_RANGE = 1.0f * PI; |
| 47 | static const float MOUSE_YAW_RANGE = 0.5f * TWO_PI; | 49 | static const float MOUSE_YAW_RANGE = 0.5f * TWO_PI; |
| 48 | 50 | static const glm::vec2 MOUSE_RANGE(MOUSE_YAW_RANGE, MOUSE_PITCH_RANGE); | |
| 49 | 51 | ||
| 50 | // Return a point's cartesian coordinates on a sphere from pitch and yaw | 52 | // Return a point's cartesian coordinates on a sphere from pitch and yaw |
| 51 | glm::vec3 getPoint(float yaw, float pitch) { | 53 | glm::vec3 getPoint(float yaw, float pitch) { |
| @@ -133,7 +135,7 @@ void ApplicationOverlay::renderReticle(glm::quat orientation, float alpha) { · 81 unmodified lines | |||
| 133 | } | 135 | } |
| 134 | 136 | ||
| 135 | ApplicationOverlay::ApplicationOverlay() : | 137 | ApplicationOverlay::ApplicationOverlay() : |
| 136 | _textureFov(glm::radians(DEFAULT_OCULUS_UI_ANGULAR_SIZE)), | 138 | _textureFov(glm::radians(DEFAULT_HMD_UI_ANGULAR_SIZE)), |
| 137 | _textureAspectRatio(1.0f), | 139 | _textureAspectRatio(1.0f), |
| 138 | _lastMouseMove(0), | 140 | _lastMouseMove(0), |
| 139 | _magnifier(true), | 141 | _magnifier(true), |
| @@ -185,10 +187,10 @@ ApplicationOverlay::~ApplicationOverlay() { · 45 unmodified lines | |||
| 185 | void ApplicationOverlay::renderOverlay() { | 187 | void ApplicationOverlay::renderOverlay() { |
| 186 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), "ApplicationOverlay::displayOverlay()"); | 188 | PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), "ApplicationOverlay::displayOverlay()"); |
| 187 | Overlays& overlays = qApp->getOverlays(); | 189 | Overlays& overlays = qApp->getOverlays(); |
| 188 | auto glCanvas = Application::getInstance()->getGLWidget(); | ||
| 189 | 190 | ||
| 190 | _textureFov = glm::radians(_oculusUIAngularSize); | 191 | _textureFov = glm::radians(_hmdUIAngularSize); |
| 191 | _textureAspectRatio = (float)glCanvas->getDeviceWidth() / (float)glCanvas->getDeviceHeight(); | 192 | auto deviceSize = Application::getInstance()->getDeviceSize(); |
| 193 | _textureAspectRatio = (float)deviceSize.width() / (float)deviceSize.height(); | ||
| 192 | 194 | ||
| 193 | //Handle fading and deactivation/activation of UI | 195 | //Handle fading and deactivation/activation of UI |
| 194 | 196 | ||
| @@ -201,12 +203,12 @@ void ApplicationOverlay::renderOverlay() { · 6 unmodified lines | |||
| 201 | _overlays.buildFramebufferObject(); | 203 | _overlays.buildFramebufferObject(); |
| 202 | _overlays.bind(); | 204 | _overlays.bind(); |
| 203 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); | 205 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
| 204 | 206 | ||
| 205 | glPushMatrix(); { | 207 | glPushMatrix(); { |
| 206 | const float NEAR_CLIP = -10000; | 208 | const float NEAR_CLIP = -10000; |
| 207 | const float FAR_CLIP = 10000; | 209 | const float FAR_CLIP = 10000; |
| 208 | glLoadIdentity(); | 210 | glLoadIdentity(); |
| 209 | glOrtho(0, glCanvas->width(), glCanvas->height(), 0, NEAR_CLIP, FAR_CLIP); | 211 | glOrtho(0, deviceSize.width(), deviceSize.height(), 0, NEAR_CLIP, FAR_CLIP); |
| 210 | 212 | ||
| 211 | glMatrixMode(GL_MODELVIEW); | 213 | glMatrixMode(GL_MODELVIEW); |
| 212 | 214 | ||
| @@ -278,7 +280,7 @@ void ApplicationOverlay::displayOverlayTexture() { · 65 unmodified lines | |||
| 278 | } | 280 | } |
| 279 | 281 | ||
| 280 | // Draws the FBO texture for Oculus rift. | 282 | // Draws the FBO texture for Oculus rift. |
| 281 | void ApplicationOverlay::displayOverlayTextureOculus(Camera& whichCamera) { | 283 | void ApplicationOverlay::displayOverlayTextureHmd(Camera& whichCamera) { |
| 282 | if (_alpha == 0.0f) { | 284 | if (_alpha == 0.0f) { |
| 283 | return; | 285 | return; |
| 284 | } | 286 | } |
| @@ -356,7 +358,7 @@ void ApplicationOverlay::displayOverlayTextureOculus(Camera& whichCamera) { · 71 unmodified lines | |||
| 356 | } | 358 | } |
| 357 | 359 | ||
| 358 | // Draws the FBO texture for 3DTV. | 360 | // Draws the FBO texture for 3DTV. |
| 359 | void ApplicationOverlay::displayOverlayTexture3DTV(Camera& whichCamera, float aspectRatio, float fov) { | 361 | void ApplicationOverlay::displayOverlayTextureStereo(Camera& whichCamera, float aspectRatio, float fov) { |
| 360 | if (_alpha == 0.0f) { | 362 | if (_alpha == 0.0f) { |
| 361 | return; | 363 | return; |
| 362 | } | 364 | } |
| @@ -411,19 +413,19 @@ void ApplicationOverlay::displayOverlayTexture3DTV(Camera& whichCamera, float as · 48 unmodified lines | |||
| 411 | overlayColor); | 413 | overlayColor); |
| 412 | }); | 414 | }); |
| 413 | 415 | ||
| 414 | auto glCanvas = Application::getInstance()->getGLWidget(); | 416 | if (!_crosshairTexture) { |
| 415 | if (_crosshairTexture == 0) { | 417 | _crosshairTexture = DependencyManager::get<TextureCache>()-> |
| 416 | _crosshairTexture = glCanvas->bindTexture(QImage(PathUtils::resourcesPath() + "images/sixense-reticle.png")); | 418 | getImageTexture(PathUtils::resourcesPath() + "images/sixense-reticle.png"); |
| 417 | } | 419 | } |
| 418 | 420 | ||
| 419 | //draw the mouse pointer | 421 | //draw the mouse pointer |
| 420 | glBindTexture(GL_TEXTURE_2D, _crosshairTexture); | 422 | glBindTexture(GL_TEXTURE_2D, gpu::GLBackend::getTextureID(_crosshairTexture)); |
| 421 | 423 | glm::vec2 canvasSize = qApp->getCanvasSize(); | |
| 422 | const float reticleSize = 40.0f / glCanvas->width() * quadWidth; | 424 | const float reticleSize = 40.0f / canvasSize.x * quadWidth; |
| 423 | x -= reticleSize / 2.0f; | 425 | x -= reticleSize / 2.0f; |
| 424 | y += reticleSize / 2.0f; | 426 | y += reticleSize / 2.0f; |
| 425 | const float mouseX = (qApp->getMouseX() / (float)glCanvas->width()) * quadWidth; | 427 | const float mouseX = (qApp->getMouseX() / (float)canvasSize.x) * quadWidth; |
| 426 | const float mouseY = (1.0 - (qApp->getMouseY() / (float)glCanvas->height())) * quadHeight; | 428 | const float mouseY = (1.0 - (qApp->getMouseY() / (float)canvasSize.y)) * quadHeight; |
| 427 | 429 | ||
| 428 | glm::vec4 reticleColor = { RETICLE_COLOR[0], RETICLE_COLOR[1], RETICLE_COLOR[2], 1.0f }; | 430 | glm::vec4 reticleColor = { RETICLE_COLOR[0], RETICLE_COLOR[1], RETICLE_COLOR[2], 1.0f }; |
| 429 | 431 | ||
| @@ -447,24 +449,23 @@ void ApplicationOverlay::displayOverlayTexture3DTV(Camera& whichCamera, float as · 17 unmodified lines | |||
| 447 | glEnable(GL_LIGHTING); | 449 | glEnable(GL_LIGHTING); |
| 448 | } | 450 | } |
| 449 | 451 | ||
| 450 | void ApplicationOverlay::computeOculusPickRay(float x, float y, glm::vec3& origin, glm::vec3& direction) const { | 452 | void ApplicationOverlay::computeHmdPickRay(glm::vec2 cursorPos, glm::vec3& origin, glm::vec3& direction) { |
| 451 | const MyAvatar* myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar(); | 453 | const MyAvatar* myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar(); |
| 452 | const float pitch = (0.5f - y) * MOUSE_PITCH_RANGE; | 454 | cursorPos = 0.5f - cursorPos; |
| 453 | const float yaw = (0.5f - x) * MOUSE_YAW_RANGE; | 455 | cursorPos *= MOUSE_RANGE; |
| 454 | const glm::quat orientation(glm::vec3(pitch, yaw, 0.0f)); | 456 | const glm::quat orientation(glm::vec3(cursorPos, 0.0f)); |
| 455 | const glm::vec3 localDirection = orientation * IDENTITY_FRONT; | 457 | const glm::vec3 localDirection = orientation * IDENTITY_FRONT; |
| 456 | 458 | ||
| 457 | // Get cursor position | 459 | // Get cursor position |
| 458 | const glm::vec3 cursorPos = myAvatar->getDefaultEyePosition() + myAvatar->getOrientation() * localDirection; | 460 | const glm::vec3 cursorDir = myAvatar->getDefaultEyePosition() + myAvatar->getOrientation() * localDirection; |
| 459 | 461 | ||
| 460 | // Ray start where the eye position is and stop where the cursor is | 462 | // Ray start where the eye position is and stop where the cursor is |
| 461 | origin = myAvatar->getEyePosition(); | 463 | origin = myAvatar->getEyePosition(); |
| 462 | direction = cursorPos - origin; | 464 | direction = cursorDir - origin; |
| 463 | } | 465 | } |
| 464 | 466 | ||
| 465 | //Caculate the click location using one of the sixense controllers. Scale is not applied | 467 | //Caculate the click location using one of the sixense controllers. Scale is not applied |
| 466 | QPoint ApplicationOverlay::getPalmClickLocation(const PalmData *palm) const { | 468 | QPoint ApplicationOverlay::getPalmClickLocation(const PalmData *palm) const { |
| 467 | auto glCanvas = Application::getInstance()->getGLWidget(); | ||
| 468 | MyAvatar* myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar(); | 469 | MyAvatar* myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar(); |
| 469 | 470 | ||
| 470 | glm::vec3 tip = myAvatar->getLaserPointerTipPosition(palm); | 471 | glm::vec3 tip = myAvatar->getLaserPointerTipPosition(palm); |
| @@ -475,8 +476,8 @@ QPoint ApplicationOverlay::getPalmClickLocation(const PalmData *palm) const { · 4 unmodified lines | |||
| 475 | glm::vec3 tipPos = invOrientation * (tip - eyePos); | 476 | glm::vec3 tipPos = invOrientation * (tip - eyePos); |
| 476 | 477 | ||
| 477 | QPoint rv; | 478 | QPoint rv; |
| 478 | 479 | auto canvasSize = qApp->getCanvasSize(); | |
| 479 | if (OculusManager::isConnected()) { | 480 | if (qApp->isHMDMode()) { |
| 480 | float t; | 481 | float t; |
| 481 | 482 | ||
| 482 | //We back the ray up by dir to ensure that it will not start inside the UI. | 483 | //We back the ray up by dir to ensure that it will not start inside the UI. |
| @@ -495,8 +496,8 @@ QPoint ApplicationOverlay::getPalmClickLocation(const PalmData *palm) const { · 12 unmodified lines | |||
| 495 | float u = asin(collisionPos.x) / (_textureFov)+0.5f; | 496 | float u = asin(collisionPos.x) / (_textureFov)+0.5f; |
| 496 | float v = 1.0 - (asin(collisionPos.y) / (_textureFov)+0.5f); | 497 | float v = 1.0 - (asin(collisionPos.y) / (_textureFov)+0.5f); |
| 497 | 498 | ||
| 498 | rv.setX(u * glCanvas->width()); | 499 | rv.setX(u * canvasSize.x); |
| 499 | rv.setY(v * glCanvas->height()); | 500 | rv.setY(v * canvasSize.y); |
| 500 | } | 501 | } |
| 501 | } else { | 502 | } else { |
| 502 | //if they did not click on the overlay, just set the coords to INT_MAX | 503 | //if they did not click on the overlay, just set the coords to INT_MAX |
| @@ -513,8 +514,8 @@ QPoint ApplicationOverlay::getPalmClickLocation(const PalmData *palm) const { · 10 unmodified lines | |||
| 513 | ndcSpacePos = glm::vec3(clipSpacePos) / clipSpacePos.w; | 514 | ndcSpacePos = glm::vec3(clipSpacePos) / clipSpacePos.w; |
| 514 | } | 515 | } |
| 515 | 516 | ||
| 516 | rv.setX(((ndcSpacePos.x + 1.0) / 2.0) * glCanvas->width()); | 517 | rv.setX(((ndcSpacePos.x + 1.0) / 2.0) * canvasSize.x); |
| 517 | rv.setY((1.0 - ((ndcSpacePos.y + 1.0) / 2.0)) * glCanvas->height()); | 518 | rv.setY((1.0 - ((ndcSpacePos.y + 1.0) / 2.0)) * canvasSize.y); |
| 518 | } | 519 | } |
| 519 | return rv; | 520 | return rv; |
| 520 | } | 521 | } |
| @@ -539,18 +540,17 @@ bool ApplicationOverlay::calculateRayUICollisionPoint(const glm::vec3& position, · 18 unmodified lines | |||
| 539 | 540 | ||
| 540 | //Renders optional pointers | 541 | //Renders optional pointers |
| 541 | void ApplicationOverlay::renderPointers() { | 542 | void ApplicationOverlay::renderPointers() { |
| 542 | auto glCanvas = Application::getInstance()->getGLWidget(); | ||
| 543 | |||
| 544 | //lazily load crosshair texture | 543 | //lazily load crosshair texture |
| 545 | if (_crosshairTexture == 0) { | 544 | if (_crosshairTexture == 0) { |
| 546 | _crosshairTexture = glCanvas->bindTexture(QImage(PathUtils::resourcesPath() + "images/sixense-reticle.png")); | 545 | _crosshairTexture = DependencyManager::get<TextureCache>()-> |
| 546 | getImageTexture(PathUtils::resourcesPath() + "images/sixense-reticle.png"); | ||
| 547 | } | 547 | } |
| 548 | glEnable(GL_TEXTURE_2D); | 548 | glEnable(GL_TEXTURE_2D); |
| 549 | 549 | ||
| 550 | glActiveTexture(GL_TEXTURE0); | 550 | glActiveTexture(GL_TEXTURE0); |
| 551 | glBindTexture(GL_TEXTURE_2D, _crosshairTexture); | 551 | glBindTexture(GL_TEXTURE_2D, gpu::GLBackend::getTextureID(_crosshairTexture)); |
| 552 | 552 | ||
| 553 | if (OculusManager::isConnected() && !qApp->getLastMouseMoveWasSimulated() && !qApp->isMouseHidden()) { | 553 | if (qApp->isHMDMode() && !qApp->getLastMouseMoveWasSimulated() && !qApp->isMouseHidden()) { |
| 554 | //If we are in oculus, render reticle later | 554 | //If we are in oculus, render reticle later |
| 555 | if (_lastMouseMove == 0) { | 555 | if (_lastMouseMove == 0) { |
| 556 | _lastMouseMove = usecTimestampNow(); | 556 | _lastMouseMove = usecTimestampNow(); |
| @@ -561,9 +561,9 @@ void ApplicationOverlay::renderPointers() { · 4 unmodified lines | |||
| 561 | if (_reticlePosition[MOUSE] != position) { | 561 | if (_reticlePosition[MOUSE] != position) { |
| 562 | _lastMouseMove = usecTimestampNow(); | 562 | _lastMouseMove = usecTimestampNow(); |
| 563 | } else if (usecTimestampNow() - _lastMouseMove > MAX_IDLE_TIME * USECS_PER_SECOND) { | 563 | } else if (usecTimestampNow() - _lastMouseMove > MAX_IDLE_TIME * USECS_PER_SECOND) { |
| 564 | float pitch = 0.0f, yaw = 0.0f, roll = 0.0f; // radians | 564 | //float pitch = 0.0f, yaw = 0.0f, roll = 0.0f; // radians |
| 565 | OculusManager::getEulerAngles(yaw, pitch, roll); | 565 | //OculusManager::getEulerAngles(yaw, pitch, roll); |
| 566 | glm::quat orientation(glm::vec3(pitch, yaw, roll)); | 566 | glm::quat orientation = qApp->getHeadOrientation(); // (glm::vec3(pitch, yaw, roll)); |
| 567 | glm::vec3 result; | 567 | glm::vec3 result; |
| 568 | 568 | ||
| 569 | MyAvatar* myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar(); | 569 | MyAvatar* myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar(); |
| @@ -574,7 +574,8 @@ void ApplicationOverlay::renderPointers() { · 4 unmodified lines | |||
| 574 | glm::vec2 spericalPos = directionToSpherical(glm::normalize(lookAtDirection)); | 574 | glm::vec2 spericalPos = directionToSpherical(glm::normalize(lookAtDirection)); |
| 575 | glm::vec2 screenPos = sphericalToScreen(spericalPos); | 575 | glm::vec2 screenPos = sphericalToScreen(spericalPos); |
| 576 | position = QPoint(screenPos.x, screenPos.y); | 576 | position = QPoint(screenPos.x, screenPos.y); |
| 577 | glCanvas->cursor().setPos(glCanvas->mapToGlobal(position)); | 577 | // FIXME |
| 578 | //glCanvas->cursor().setPos(glCanvas->mapToGlobal(position)); | ||
| 578 | } else { | 579 | } else { |
| 579 | qDebug() << "No collision point"; | 580 | qDebug() << "No collision point"; |
| 580 | } | 581 | } |
| @@ -597,7 +598,6 @@ void ApplicationOverlay::renderPointers() { · 16 unmodified lines | |||
| 597 | } | 598 | } |
| 598 | 599 | ||
| 599 | void ApplicationOverlay::renderControllerPointers() { | 600 | void ApplicationOverlay::renderControllerPointers() { |
| 600 | auto glCanvas = Application::getInstance()->getGLWidget(); | ||
| 601 | MyAvatar* myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar(); | 601 | MyAvatar* myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar(); |
| 602 | 602 | ||
| 603 | //Static variables used for storing controller state | 603 | //Static variables used for storing controller state |
| @@ -646,7 +646,7 @@ void ApplicationOverlay::renderControllerPointers() { · 42 unmodified lines | |||
| 646 | 646 | ||
| 647 | //if we have the oculus, we should make the cursor smaller since it will be | 647 | //if we have the oculus, we should make the cursor smaller since it will be |
| 648 | //magnified | 648 | //magnified |
| 649 | if (OculusManager::isConnected()) { | 649 | if (qApp->isHMDMode()) { |
| 650 | 650 | ||
| 651 | QPoint point = getPalmClickLocation(palmData); | 651 | QPoint point = getPalmClickLocation(palmData); |
| 652 | 652 | ||
| @@ -661,6 +661,7 @@ void ApplicationOverlay::renderControllerPointers() { · 8 unmodified lines | |||
| 661 | continue; | 661 | continue; |
| 662 | } | 662 | } |
| 663 | 663 | ||
| 664 | auto canvasSize = qApp->getCanvasSize(); | ||
| 664 | int mouseX, mouseY; | 665 | int mouseX, mouseY; |
| 665 | if (Menu::getInstance()->isOptionChecked(MenuOption::SixenseLasers)) { | 666 | if (Menu::getInstance()->isOptionChecked(MenuOption::SixenseLasers)) { |
| 666 | QPoint res = getPalmClickLocation(palmData); | 667 | QPoint res = getPalmClickLocation(palmData); |
| @@ -675,14 +676,14 @@ void ApplicationOverlay::renderControllerPointers() { · 8 unmodified lines | |||
| 675 | float yAngle = 0.5f - ((atan2(direction.z, direction.y) + M_PI_2)); | 676 | float yAngle = 0.5f - ((atan2(direction.z, direction.y) + M_PI_2)); |
| 676 | 677 | ||
| 677 | // Get the pixel range over which the xAngle and yAngle are scaled | 678 | // Get the pixel range over which the xAngle and yAngle are scaled |
| 678 | float cursorRange = glCanvas->width() * SixenseManager::getInstance().getCursorPixelRangeMult(); | 679 | float cursorRange = canvasSize.x * SixenseManager::getInstance().getCursorPixelRangeMult(); |
| 679 | 680 | ||
| 680 | mouseX = (glCanvas->width() / 2.0f + cursorRange * xAngle); | 681 | mouseX = (canvasSize.x / 2.0f + cursorRange * xAngle); |
| 681 | mouseY = (glCanvas->height() / 2.0f + cursorRange * yAngle); | 682 | mouseY = (canvasSize.y / 2.0f + cursorRange * yAngle); |
| 682 | } | 683 | } |
| 683 | 684 | ||
| 684 | //If the cursor is out of the screen then don't render it | 685 | //If the cursor is out of the screen then don't render it |
| 685 | if (mouseX < 0 || mouseX >= glCanvas->width() || mouseY < 0 || mouseY >= glCanvas->height()) { | 686 | if (mouseX < 0 || mouseX >= canvasSize.x || mouseY < 0 || mouseY >= canvasSize.y) { |
| 686 | _reticleActive[index] = false; | 687 | _reticleActive[index] = false; |
| 687 | continue; | 688 | continue; |
| 688 | } | 689 | } |
| @@ -707,7 +708,7 @@ void ApplicationOverlay::renderControllerPointers() { · 18 unmodified lines | |||
| 707 | } | 708 | } |
| 708 | 709 | ||
| 709 | void ApplicationOverlay::renderPointersOculus(const glm::vec3& eyePos) { | 710 | void ApplicationOverlay::renderPointersOculus(const glm::vec3& eyePos) { |
| 710 | glBindTexture(GL_TEXTURE_2D, _crosshairTexture); | 711 | glBindTexture(GL_TEXTURE_2D, gpu::GLBackend::getTextureID(_crosshairTexture)); |
| 711 | glDisable(GL_DEPTH_TEST); | 712 | glDisable(GL_DEPTH_TEST); |
| 712 | glMatrixMode(GL_MODELVIEW); | 713 | glMatrixMode(GL_MODELVIEW); |
| 713 | 714 | ||
| @@ -744,10 +745,10 @@ void ApplicationOverlay::renderMagnifier(glm::vec2 magPos, float sizeMult, bool · 30 unmodified lines | |||
| 744 | if (!_magnifier) { | 745 | if (!_magnifier) { |
| 745 | return; | 746 | return; |
| 746 | } | 747 | } |
| 747 | auto glCanvas = Application::getInstance()->getGLWidget(); | 748 | auto canvasSize = qApp->getCanvasSize(); |
| 748 | 749 | ||
| 749 | const int widgetWidth = glCanvas->width(); | 750 | const int widgetWidth = canvasSize.x; |
| 750 | const int widgetHeight = glCanvas->height(); | 751 | const int widgetHeight = canvasSize.y; |
| 751 | 752 | ||
| 752 | const float halfWidth = (MAGNIFY_WIDTH / _textureAspectRatio) * sizeMult / 2.0f; | 753 | const float halfWidth = (MAGNIFY_WIDTH / _textureAspectRatio) * sizeMult / 2.0f; |
| 753 | const float halfHeight = MAGNIFY_HEIGHT * sizeMult / 2.0f; | 754 | const float halfHeight = MAGNIFY_HEIGHT * sizeMult / 2.0f; |
| @@ -809,7 +810,6 @@ void ApplicationOverlay::renderMagnifier(glm::vec2 magPos, float sizeMult, bool · 55 unmodified lines | |||
| 809 | } | 810 | } |
| 810 | 811 | ||
| 811 | void ApplicationOverlay::renderAudioMeter() { | 812 | void ApplicationOverlay::renderAudioMeter() { |
| 812 | auto glCanvas = Application::getInstance()->getGLWidget(); | ||
| 813 | auto audio = DependencyManager::get<AudioClient>(); | 813 | auto audio = DependencyManager::get<AudioClient>(); |
| 814 | 814 | ||
| 815 | // Audio VU Meter and Mute Icon | 815 | // Audio VU Meter and Mute Icon |
| @@ -822,7 +822,7 @@ void ApplicationOverlay::renderAudioMeter() { · 6 unmodified lines | |||
| 822 | const int AUDIO_METER_X = MIRROR_VIEW_LEFT_PADDING + MUTE_ICON_SIZE + AUDIO_METER_GAP; | 822 | const int AUDIO_METER_X = MIRROR_VIEW_LEFT_PADDING + MUTE_ICON_SIZE + AUDIO_METER_GAP; |
| 823 | 823 | ||
| 824 | int audioMeterY; | 824 | int audioMeterY; |
| 825 | bool smallMirrorVisible = Menu::getInstance()->isOptionChecked(MenuOption::Mirror) && !OculusManager::isConnected(); | 825 | bool smallMirrorVisible = Menu::getInstance()->isOptionChecked(MenuOption::Mirror) && !qApp->isHMDMode(); |
| 826 | bool boxed = smallMirrorVisible && | 826 | bool boxed = smallMirrorVisible && |
| 827 | !Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror); | 827 | !Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror); |
| 828 | if (boxed) { | 828 | if (boxed) { |
| @@ -857,16 +857,17 @@ void ApplicationOverlay::renderAudioMeter() { · 28 unmodified lines | |||
| 857 | } | 857 | } |
| 858 | bool isClipping = ((audio->getTimeSinceLastClip() > 0.0f) && (audio->getTimeSinceLastClip() < CLIPPING_INDICATOR_TIME)); | 858 | bool isClipping = ((audio->getTimeSinceLastClip() > 0.0f) && (audio->getTimeSinceLastClip() < CLIPPING_INDICATOR_TIME)); |
| 859 | 859 | ||
| 860 | auto canvasSize = qApp->getCanvasSize(); | ||
| 860 | if ((audio->getTimeSinceLastClip() > 0.0f) && (audio->getTimeSinceLastClip() < CLIPPING_INDICATOR_TIME)) { | 861 | if ((audio->getTimeSinceLastClip() > 0.0f) && (audio->getTimeSinceLastClip() < CLIPPING_INDICATOR_TIME)) { |
| 861 | const float MAX_MAGNITUDE = 0.7f; | 862 | const float MAX_MAGNITUDE = 0.7f; |
| 862 | float magnitude = MAX_MAGNITUDE * (1 - audio->getTimeSinceLastClip() / CLIPPING_INDICATOR_TIME); | 863 | float magnitude = MAX_MAGNITUDE * (1 - audio->getTimeSinceLastClip() / CLIPPING_INDICATOR_TIME); |
| 863 | renderCollisionOverlay(glCanvas->width(), glCanvas->height(), magnitude, 1.0f); | 864 | renderCollisionOverlay(canvasSize.x, canvasSize.y, magnitude, 1.0f); |
| 864 | } | 865 | } |
| 865 | 866 | ||
| 866 | DependencyManager::get<AudioToolBox>()->render(MIRROR_VIEW_LEFT_PADDING + AUDIO_METER_GAP, audioMeterY, boxed); | 867 | DependencyManager::get<AudioToolBox>()->render(MIRROR_VIEW_LEFT_PADDING + AUDIO_METER_GAP, audioMeterY, boxed); |
| 867 | 868 | ||
| 868 | DependencyManager::get<AudioScope>()->render(glCanvas->width(), glCanvas->height()); | 869 | DependencyManager::get<AudioScope>()->render(canvasSize.x, canvasSize.y); |
| 869 | DependencyManager::get<AudioIOStatsRenderer>()->render(WHITE_TEXT, glCanvas->width(), glCanvas->height()); | 870 | DependencyManager::get<AudioIOStatsRenderer>()->render(WHITE_TEXT, canvasSize.x, canvasSize.y); |
| 870 | 871 | ||
| 871 | audioMeterY += AUDIO_METER_HEIGHT; | 872 | audioMeterY += AUDIO_METER_HEIGHT; |
| 872 | 873 | ||
| @@ -927,7 +928,6 @@ void ApplicationOverlay::renderStatsAndLogs() { · 54 unmodified lines | |||
| 927 | Application* application = Application::getInstance(); | 928 | Application* application = Application::getInstance(); |
| 928 | QSharedPointer<BandwidthRecorder> bandwidthRecorder = DependencyManager::get<BandwidthRecorder>(); | 929 | QSharedPointer<BandwidthRecorder> bandwidthRecorder = DependencyManager::get<BandwidthRecorder>(); |
| 929 | 930 | ||
| 930 | auto glCanvas = Application::getInstance()->getGLWidget(); | ||
| 931 | const OctreePacketProcessor& octreePacketProcessor = application->getOctreePacketProcessor(); | 931 | const OctreePacketProcessor& octreePacketProcessor = application->getOctreePacketProcessor(); |
| 932 | NodeBounds& nodeBoundsDisplay = application->getNodeBoundsDisplay(); | 932 | NodeBounds& nodeBoundsDisplay = application->getNodeBoundsDisplay(); |
| 933 | 933 | ||
| @@ -950,12 +950,13 @@ void ApplicationOverlay::renderStatsAndLogs() { · 16 unmodified lines | |||
| 950 | 950 | ||
| 951 | // Show on-screen msec timer | 951 | // Show on-screen msec timer |
| 952 | if (Menu::getInstance()->isOptionChecked(MenuOption::FrameTimer)) { | 952 | if (Menu::getInstance()->isOptionChecked(MenuOption::FrameTimer)) { |
| 953 | auto canvasSize = qApp->getCanvasSize(); | ||
| 953 | quint64 mSecsNow = floor(usecTimestampNow() / 1000.0 + 0.5); | 954 | quint64 mSecsNow = floor(usecTimestampNow() / 1000.0 + 0.5); |
| 954 | QString frameTimer = QString("%1\n").arg((int)(mSecsNow % 1000)); | 955 | QString frameTimer = QString("%1\n").arg((int)(mSecsNow % 1000)); |
| 955 | int timerBottom = | 956 | int timerBottom = |
| 956 | (Menu::getInstance()->isOptionChecked(MenuOption::Stats)) | 957 | (Menu::getInstance()->isOptionChecked(MenuOption::Stats)) |
| 957 | ? 80 : 20; | 958 | ? 80 : 20; |
| 958 | drawText(glCanvas->width() - 100, glCanvas->height() - timerBottom, | 959 | drawText(canvasSize.x - 100, canvasSize.y - timerBottom, |
| 959 | 0.30f, 0.0f, 0, frameTimer.toUtf8().constData(), WHITE_TEXT); | 960 | 0.30f, 0.0f, 0, frameTimer.toUtf8().constData(), WHITE_TEXT); |
| 960 | } | 961 | } |
| 961 | nodeBoundsDisplay.drawOverlay(); | 962 | nodeBoundsDisplay.drawOverlay(); |
| @@ -965,25 +966,22 @@ void ApplicationOverlay::renderDomainConnectionStatusBorder() { · 3 unmodified lines | |||
| 965 | auto nodeList = DependencyManager::get<NodeList>(); | 966 | auto nodeList = DependencyManager::get<NodeList>(); |
| 966 | 967 | ||
| 967 | if (nodeList && !nodeList->getDomainHandler().isConnected()) { | 968 | if (nodeList && !nodeList->getDomainHandler().isConnected()) { |
| 968 | auto glCanvas = Application::getInstance()->getGLWidget(); | ||
| 969 | auto geometryCache = DependencyManager::get<GeometryCache>(); | 969 | auto geometryCache = DependencyManager::get<GeometryCache>(); |
| 970 | int width = glCanvas->width(); | 970 | auto canvasSize = qApp->getCanvasSize(); |
| 971 | int height = glCanvas->height(); | 971 | if (canvasSize.x != _previousBorderWidth || canvasSize.y != _previousBorderHeight) { |
| 972 | |||
| 973 | if (width != _previousBorderWidth || height != _previousBorderHeight) { | ||
| 974 | glm::vec4 color(CONNECTION_STATUS_BORDER_COLOR[0], | 972 | glm::vec4 color(CONNECTION_STATUS_BORDER_COLOR[0], |
| 975 | CONNECTION_STATUS_BORDER_COLOR[1], | 973 | CONNECTION_STATUS_BORDER_COLOR[1], |
| 976 | CONNECTION_STATUS_BORDER_COLOR[2], 1.0f); | 974 | CONNECTION_STATUS_BORDER_COLOR[2], 1.0f); |
| 977 | 975 | ||
| 978 | QVector<glm::vec2> border; | 976 | QVector<glm::vec2> border; |
| 979 | border << glm::vec2(0, 0); | 977 | border << glm::vec2(0, 0); |
| 980 | border << glm::vec2(0, height); | 978 | border << glm::vec2(0, canvasSize.y); |
| 981 | border << glm::vec2(width, height); | 979 | border << glm::vec2(canvasSize.x, canvasSize.y); |
| 982 | border << glm::vec2(width, 0); | 980 | border << glm::vec2(canvasSize.x, 0); |
| 983 | border << glm::vec2(0, 0); | 981 | border << glm::vec2(0, 0); |
| 984 | geometryCache->updateVertices(_domainStatusBorder, border, color); | 982 | geometryCache->updateVertices(_domainStatusBorder, border, color); |
| 985 | _previousBorderWidth = width; | 983 | _previousBorderWidth = canvasSize.x; |
| 986 | _previousBorderHeight = height; | 984 | _previousBorderHeight = canvasSize.y; |
| 987 | } | 985 | } |
| 988 | 986 | ||
| 989 | glLineWidth(CONNECTION_STATUS_BORDER_LINE_WIDTH); | 987 | glLineWidth(CONNECTION_STATUS_BORDER_LINE_WIDTH); |
| @@ -1101,8 +1099,8 @@ void ApplicationOverlay::TexturedHemisphere::cleanupVBO() { · 111 unmodified lines | |||
| 1101 | } | 1099 | } |
| 1102 | 1100 | ||
| 1103 | void ApplicationOverlay::TexturedHemisphere::buildFramebufferObject() { | 1101 | void ApplicationOverlay::TexturedHemisphere::buildFramebufferObject() { |
| 1104 | QSize size = Application::getInstance()->getGLWidget()->getDeviceSize(); | 1102 | auto deviceSize = qApp->getDeviceSize(); |
| 1105 | if (_framebufferObject != NULL && size == _framebufferObject->size()) { | 1103 | if (_framebufferObject != NULL && deviceSize == _framebufferObject->size()) { |
| 1106 | // Already build | 1104 | // Already build |
| 1107 | return; | 1105 | return; |
| 1108 | } | 1106 | } |
| @@ -1111,7 +1109,7 @@ void ApplicationOverlay::TexturedHemisphere::buildFramebufferObject() { · 2 unmodified lines | |||
| 1111 | delete _framebufferObject; | 1109 | delete _framebufferObject; |
| 1112 | } | 1110 | } |
| 1113 | 1111 | ||
| 1114 | _framebufferObject = new QOpenGLFramebufferObject(size, QOpenGLFramebufferObject::Depth); | 1112 | _framebufferObject = new QOpenGLFramebufferObject(deviceSize, QOpenGLFramebufferObject::Depth); |
| 1115 | glBindTexture(GL_TEXTURE_2D, getTexture()); | 1113 | glBindTexture(GL_TEXTURE_2D, getTexture()); |
| 1116 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); | 1114 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
| 1117 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); | 1115 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
| @@ -1154,7 +1152,7 @@ GLuint ApplicationOverlay::TexturedHemisphere::getTexture() { · 36 unmodified lines | |||
| 1154 | return _framebufferObject->texture(); | 1152 | return _framebufferObject->texture(); |
| 1155 | } | 1153 | } |
| 1156 | 1154 | ||
| 1157 | glm::vec2 ApplicationOverlay::directionToSpherical(glm::vec3 direction) const { | 1155 | glm::vec2 ApplicationOverlay::directionToSpherical(const glm::vec3& direction) { |
| 1158 | glm::vec2 result; | 1156 | glm::vec2 result; |
| 1159 | // Compute yaw | 1157 | // Compute yaw |
| 1160 | glm::vec3 normalProjection = glm::normalize(glm::vec3(direction.x, 0.0f, direction.z)); | 1158 | glm::vec3 normalProjection = glm::normalize(glm::vec3(direction.x, 0.0f, direction.z)); |
| @@ -1170,47 +1168,57 @@ glm::vec2 ApplicationOverlay::directionToSpherical(glm::vec3 direction) const { · 9 unmodified lines | |||
| 1170 | return result; | 1168 | return result; |
| 1171 | } | 1169 | } |
| 1172 | 1170 | ||
| 1173 | glm::vec3 ApplicationOverlay::sphericalToDirection(glm::vec2 sphericalPos) const { | 1171 | glm::vec3 ApplicationOverlay::sphericalToDirection(const glm::vec2& sphericalPos) { |
| 1174 | glm::quat rotation(glm::vec3(sphericalPos.y, sphericalPos.x, 0.0f)); | 1172 | glm::quat rotation(glm::vec3(sphericalPos.y, sphericalPos.x, 0.0f)); |
| 1175 | return rotation * IDENTITY_FRONT; | 1173 | return rotation * IDENTITY_FRONT; |
| 1176 | } | 1174 | } |
| 1177 | 1175 | ||
| 1178 | glm::vec2 ApplicationOverlay::screenToSpherical(glm::vec2 screenPos) const { | 1176 | glm::vec2 ApplicationOverlay::screenToSpherical(const glm::vec2& screenPos) { |
| 1179 | QSize screenSize = Application::getInstance()->getGLWidget()->getDeviceSize(); | 1177 | auto screenSize = qApp->getCanvasSize(); |
| 1180 | float yaw = -(screenPos.x / screenSize.width() - 0.5f) * MOUSE_YAW_RANGE; | 1178 | glm::vec2 result; |
| 1181 | float pitch = (screenPos.y / screenSize.height() - 0.5f) * MOUSE_PITCH_RANGE; | 1179 | result.x = -(screenPos.x / screenSize.x - 0.5f); |
| 1180 | result.y = (screenPos.y / screenSize.y - 0.5f); | ||
| 1181 | result.x *= MOUSE_YAW_RANGE; | ||
| 1182 | result.y *= MOUSE_PITCH_RANGE; | ||
| 1182 | 1183 | ||
| 1183 | return glm::vec2(yaw, pitch); | 1184 | return result; |
| 1184 | } | 1185 | } |
| 1185 | 1186 | ||
| 1186 | glm::vec2 ApplicationOverlay::sphericalToScreen(glm::vec2 sphericalPos) const { | 1187 | glm::vec2 ApplicationOverlay::sphericalToScreen(const glm::vec2& sphericalPos) { |
| 1187 | QSize screenSize = Application::getInstance()->getGLWidget()->getDeviceSize(); | 1188 | glm::vec2 result = sphericalPos; |
| 1188 | float x = (-sphericalPos.x / MOUSE_YAW_RANGE + 0.5f) * screenSize.width(); | 1189 | result.x *= -1.0; |
| 1189 | float y = (sphericalPos.y / MOUSE_PITCH_RANGE + 0.5f) * screenSize.height(); | 1190 | result /= MOUSE_RANGE; |
| 1190 | 1191 | result += 0.5f; | |
| 1191 | return glm::vec2(x, y); | 1192 | result *= qApp->getCanvasSize(); |
| 1193 | return result; | ||
| 1192 | } | 1194 | } |
| 1193 | 1195 | ||
| 1194 | glm::vec2 ApplicationOverlay::sphericalToOverlay(glm::vec2 sphericalPos) const { | 1196 | glm::vec2 ApplicationOverlay::sphericalToOverlay(const glm::vec2& sphericalPos) const { |
| 1195 | QSize screenSize = Application::getInstance()->getGLWidget()->getDeviceSize(); | 1197 | glm::vec2 result = sphericalPos; |
| 1196 | float x = (-sphericalPos.x / (_textureFov * _textureAspectRatio) + 0.5f) * screenSize.width(); | 1198 | result.x *= -1.0; |
| 1197 | float y = (sphericalPos.y / _textureFov + 0.5f) * screenSize.height(); | 1199 | result /= _textureFov; |
| 1198 | 1200 | result.x /= _textureAspectRatio; | |
| 1199 | return glm::vec2(x, y); | 1201 | result += 0.5f; |
| 1202 | result.x = (-sphericalPos.x / (_textureFov * _textureAspectRatio) + 0.5f); | ||
| 1203 | result.y = (sphericalPos.y / _textureFov + 0.5f); | ||
| 1204 | result *= qApp->getCanvasSize(); | ||
| 1205 | return result; | ||
| 1200 | } | 1206 | } |
| 1201 | 1207 | ||
| 1202 | glm::vec2 ApplicationOverlay::overlayToSpherical(glm::vec2 overlayPos) const { | 1208 | glm::vec2 ApplicationOverlay::overlayToSpherical(const glm::vec2& overlayPos) const { |
| 1203 | QSize screenSize = Application::getInstance()->getGLWidget()->getDeviceSize(); | 1209 | glm::vec2 result = overlayPos; |
| 1204 | float yaw = -(overlayPos.x / screenSize.width() - 0.5f) * _textureFov * _textureAspectRatio; | 1210 | result.x *= -1.0; |
| 1205 | float pitch = (overlayPos.y / screenSize.height() - 0.5f) * _textureFov; | 1211 | result /= qApp->getCanvasSize(); |
| 1206 | 1212 | result -= 0.5f; | |
| 1207 | return glm::vec2(yaw, pitch); | 1213 | result *= _textureFov; |
| 1214 | result.x *= _textureAspectRatio; | ||
| 1215 | return result; | ||
| 1208 | } | 1216 | } |
| 1209 | 1217 | ||
| 1210 | glm::vec2 ApplicationOverlay::screenToOverlay(glm::vec2 screenPos) const { | 1218 | glm::vec2 ApplicationOverlay::screenToOverlay(const glm::vec2& screenPos) const { |
| 1211 | return sphericalToOverlay(screenToSpherical(screenPos)); | 1219 | return sphericalToOverlay(screenToSpherical(screenPos)); |
| 1212 | } | 1220 | } |
| 1213 | 1221 | ||
| 1214 | glm::vec2 ApplicationOverlay::overlayToScreen(glm::vec2 overlayPos) const { | 1222 | glm::vec2 ApplicationOverlay::overlayToScreen(const glm::vec2& overlayPos) const { |
| 1215 | return sphericalToScreen(overlayToSpherical(overlayPos)); | 1223 | return sphericalToScreen(overlayToSpherical(overlayPos)); |
| 1216 | } | 1224 | } |