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