From b3534210e44c189c334468761622e7cd55f5eda6 Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Mon, 8 Jun 2015 11:51:35 -0700 Subject: [PATCH] Always use GL rendered cursor --- interface/src/Application.cpp | 18 +++------------ interface/src/Application.h | 2 -- interface/src/ui/ApplicationOverlay.cpp | 29 ++++++++++++++++++++++++- 3 files changed, 31 insertions(+), 18 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index dbdcaa122a..e8c3fc9dbe 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -515,6 +515,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : _window->setVisible(true); _glWidget->setFocusPolicy(Qt::StrongFocus); _glWidget->setFocus(); + _glWidget->setCursor(Qt::BlankCursor); // enable mouse tracking; otherwise, we only get drag events _glWidget->setMouseTracking(true); @@ -1865,16 +1866,14 @@ void Application::setEnableVRMode(bool enableVRMode) { OculusManager::recalibrate(); } else { OculusManager::abandonCalibration(); - + _mirrorCamera.setHmdPosition(glm::vec3()); _mirrorCamera.setHmdRotation(glm::quat()); _myCamera.setHmdPosition(glm::vec3()); _myCamera.setHmdRotation(glm::quat()); } - + resizeGL(); - - updateCursorVisibility(); } void Application::setLowVelocityFilter(bool lowVelocityFilter) { @@ -2384,19 +2383,8 @@ void Application::updateCursor(float deltaTime) { lastMousePos = QCursor::pos(); } -void Application::updateCursorVisibility() { - if (!_cursorVisible || - Menu::getInstance()->isOptionChecked(MenuOption::EnableVRMode) || - Menu::getInstance()->isOptionChecked(MenuOption::Enable3DTVMode)) { - _window->setCursor(Qt::BlankCursor); - } else { - _window->unsetCursor(); - } -} - void Application::setCursorVisible(bool visible) { _cursorVisible = visible; - updateCursorVisibility(); } void Application::update(float deltaTime) { diff --git a/interface/src/Application.h b/interface/src/Application.h index b6efb6420b..68aba747aa 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -470,8 +470,6 @@ private: void updateProjectionMatrix(); void updateProjectionMatrix(Camera& camera, bool updateViewFrustum = true); - void updateCursorVisibility(); - void sendPingPackets(); void initDisplay(); diff --git a/interface/src/ui/ApplicationOverlay.cpp b/interface/src/ui/ApplicationOverlay.cpp index d9d2a1d971..5f629a5a6a 100644 --- a/interface/src/ui/ApplicationOverlay.cpp +++ b/interface/src/ui/ApplicationOverlay.cpp @@ -277,9 +277,36 @@ void ApplicationOverlay::displayOverlayTexture() { static const glm::vec2 texCoordTopLeft(0.0f, 1.0f); static const glm::vec2 texCoordBottomRight(1.0f, 0.0f); with_each_texture(_overlays.getTexture(), _newUiTexture, [&] { - DependencyManager::get()->renderQuad(topLeft, bottomRight, texCoordTopLeft, texCoordBottomRight, + DependencyManager::get()->renderQuad( + topLeft, bottomRight, + texCoordTopLeft, texCoordBottomRight, glm::vec4(1.0f, 1.0f, 1.0f, _alpha)); }); + + if (!_crosshairTexture) { + _crosshairTexture = DependencyManager::get()-> + getImageTexture(PathUtils::resourcesPath() + "images/sixense-reticle.png"); + } + + //draw the mouse pointer + glm::vec2 canvasSize = qApp->getCanvasSize(); + glm::vec2 mouseSize = 32.0f / canvasSize; + auto mouseTopLeft = topLeft * mouseSize; + auto mouseBottomRight = bottomRight * mouseSize; + vec2 mousePosition = vec2(qApp->getMouseX(), qApp->getMouseY()); + mousePosition /= canvasSize; + mousePosition *= 2.0f; + mousePosition -= 1.0f; + mousePosition.y *= -1.0f; + + glEnable(GL_TEXTURE_2D); + glBindTexture(GL_TEXTURE_2D, gpu::GLBackend::getTextureID(_crosshairTexture)); + glm::vec4 reticleColor = { RETICLE_COLOR[0], RETICLE_COLOR[1], RETICLE_COLOR[2], 1.0f }; + DependencyManager::get()->renderQuad( + mouseTopLeft + mousePosition, mouseBottomRight + mousePosition, + texCoordTopLeft, texCoordBottomRight, + reticleColor); + glDisable(GL_TEXTURE_2D); } glPopMatrix(); }