mirror of
https://github.com/overte-org/overte.git
synced 2025-08-04 11:57:58 +02:00
Always use GL rendered cursor
This commit is contained in:
parent
94cd0762bd
commit
b3534210e4
3 changed files with 31 additions and 18 deletions
|
@ -515,6 +515,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
||||||
_window->setVisible(true);
|
_window->setVisible(true);
|
||||||
_glWidget->setFocusPolicy(Qt::StrongFocus);
|
_glWidget->setFocusPolicy(Qt::StrongFocus);
|
||||||
_glWidget->setFocus();
|
_glWidget->setFocus();
|
||||||
|
_glWidget->setCursor(Qt::BlankCursor);
|
||||||
|
|
||||||
// enable mouse tracking; otherwise, we only get drag events
|
// enable mouse tracking; otherwise, we only get drag events
|
||||||
_glWidget->setMouseTracking(true);
|
_glWidget->setMouseTracking(true);
|
||||||
|
@ -1873,8 +1874,6 @@ void Application::setEnableVRMode(bool enableVRMode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
resizeGL();
|
resizeGL();
|
||||||
|
|
||||||
updateCursorVisibility();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::setLowVelocityFilter(bool lowVelocityFilter) {
|
void Application::setLowVelocityFilter(bool lowVelocityFilter) {
|
||||||
|
@ -2384,19 +2383,8 @@ void Application::updateCursor(float deltaTime) {
|
||||||
lastMousePos = QCursor::pos();
|
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) {
|
void Application::setCursorVisible(bool visible) {
|
||||||
_cursorVisible = visible;
|
_cursorVisible = visible;
|
||||||
updateCursorVisibility();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::update(float deltaTime) {
|
void Application::update(float deltaTime) {
|
||||||
|
|
|
@ -470,8 +470,6 @@ private:
|
||||||
void updateProjectionMatrix();
|
void updateProjectionMatrix();
|
||||||
void updateProjectionMatrix(Camera& camera, bool updateViewFrustum = true);
|
void updateProjectionMatrix(Camera& camera, bool updateViewFrustum = true);
|
||||||
|
|
||||||
void updateCursorVisibility();
|
|
||||||
|
|
||||||
void sendPingPackets();
|
void sendPingPackets();
|
||||||
|
|
||||||
void initDisplay();
|
void initDisplay();
|
||||||
|
|
|
@ -277,9 +277,36 @@ void ApplicationOverlay::displayOverlayTexture() {
|
||||||
static const glm::vec2 texCoordTopLeft(0.0f, 1.0f);
|
static const glm::vec2 texCoordTopLeft(0.0f, 1.0f);
|
||||||
static const glm::vec2 texCoordBottomRight(1.0f, 0.0f);
|
static const glm::vec2 texCoordBottomRight(1.0f, 0.0f);
|
||||||
with_each_texture(_overlays.getTexture(), _newUiTexture, [&] {
|
with_each_texture(_overlays.getTexture(), _newUiTexture, [&] {
|
||||||
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight, texCoordTopLeft, texCoordBottomRight,
|
DependencyManager::get<GeometryCache>()->renderQuad(
|
||||||
|
topLeft, bottomRight,
|
||||||
|
texCoordTopLeft, texCoordBottomRight,
|
||||||
glm::vec4(1.0f, 1.0f, 1.0f, _alpha));
|
glm::vec4(1.0f, 1.0f, 1.0f, _alpha));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (!_crosshairTexture) {
|
||||||
|
_crosshairTexture = DependencyManager::get<TextureCache>()->
|
||||||
|
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<GeometryCache>()->renderQuad(
|
||||||
|
mouseTopLeft + mousePosition, mouseBottomRight + mousePosition,
|
||||||
|
texCoordTopLeft, texCoordBottomRight,
|
||||||
|
reticleColor);
|
||||||
|
glDisable(GL_TEXTURE_2D);
|
||||||
} glPopMatrix();
|
} glPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue