diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 188ae6eaf9..1763623fa6 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -524,6 +524,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); @@ -1891,8 +1892,6 @@ void Application::setEnableVRMode(bool enableVRMode) { } resizeGL(); - - updateCursorVisibility(); } void Application::setLowVelocityFilter(bool lowVelocityFilter) { @@ -2401,19 +2400,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 b74b3a0355..f63802ce24 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -475,8 +475,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 e51522bb7f..bc8047fc98 100644 --- a/interface/src/ui/ApplicationOverlay.cpp +++ b/interface/src/ui/ApplicationOverlay.cpp @@ -267,9 +267,8 @@ void ApplicationOverlay::displayOverlayTexture() { glLoadIdentity(); glDisable(GL_DEPTH_TEST); glDisable(GL_LIGHTING); - if (_alpha < 1.0) { - glEnable(GL_BLEND); - } + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glViewport(0, 0, qApp->getDeviceSize().width(), qApp->getDeviceSize().height()); static const glm::vec2 topLeft(-1, 1); @@ -277,9 +276,38 @@ 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); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + 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); + glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_CONSTANT_ALPHA, GL_ONE); + glDisable(GL_TEXTURE_2D); } glPopMatrix(); } @@ -428,6 +456,9 @@ void ApplicationOverlay::displayOverlayTextureStereo(Camera& whichCamera, float } //draw the mouse pointer + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, gpu::GLBackend::getTextureID(_crosshairTexture)); glm::vec2 canvasSize = qApp->getCanvasSize(); const float reticleSize = 40.0f / canvasSize.x * quadWidth; @@ -557,7 +588,9 @@ void ApplicationOverlay::renderPointers() { _crosshairTexture = TextureCache::getImageTexture(PathUtils::resourcesPath() + "images/sixense-reticle.png"); } glEnable(GL_TEXTURE_2D); - + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, gpu::GLBackend::getTextureID(_crosshairTexture)); @@ -719,8 +752,14 @@ void ApplicationOverlay::renderControllerPointers() { } void ApplicationOverlay::renderPointersOculus() { + + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_TEXTURE_2D); + glBindTexture(GL_TEXTURE_2D, gpu::GLBackend::getTextureID(_crosshairTexture)); glDisable(GL_DEPTH_TEST); + glMatrixMode(GL_MODELVIEW); //Controller Pointers @@ -745,6 +784,8 @@ void ApplicationOverlay::renderPointersOculus() { } glEnable(GL_DEPTH_TEST); + glDisable(GL_TEXTURE_2D); + glDisable(GL_BLEND); } //Renders a small magnification of the currently bound texture at the coordinates