mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 02:19:58 +02:00
Re-enable OpenVR plugin
* Enabled preview window * rendering is only mono for some-reason.
This commit is contained in:
parent
e61636e8a7
commit
b9a16cec25
6 changed files with 41 additions and 10 deletions
4
cmake/externals/openvr/CMakeLists.txt
vendored
4
cmake/externals/openvr/CMakeLists.txt
vendored
|
@ -7,8 +7,8 @@ string(TOUPPER ${EXTERNAL_NAME} EXTERNAL_NAME_UPPER)
|
||||||
|
|
||||||
ExternalProject_Add(
|
ExternalProject_Add(
|
||||||
${EXTERNAL_NAME}
|
${EXTERNAL_NAME}
|
||||||
URL https://github.com/ValveSoftware/openvr/archive/v0.9.12.zip
|
URL https://github.com/ValveSoftware/openvr/archive/v0.9.15.zip
|
||||||
URL_MD5 c08dced68ce4e341e1467e6814ae419d
|
URL_MD5 0ff8560b49b6da1150fcc47360e8ceca
|
||||||
CONFIGURE_COMMAND ""
|
CONFIGURE_COMMAND ""
|
||||||
BUILD_COMMAND ""
|
BUILD_COMMAND ""
|
||||||
INSTALL_COMMAND ""
|
INSTALL_COMMAND ""
|
||||||
|
|
|
@ -6,10 +6,7 @@
|
||||||
# See the accompanying file LICENSE or http:#www.apache.org/licenses/LICENSE-2.0.html
|
# See the accompanying file LICENSE or http:#www.apache.org/licenses/LICENSE-2.0.html
|
||||||
#
|
#
|
||||||
|
|
||||||
# OpenVR is disabled until a) it works with threaded present and
|
if (WIN32)
|
||||||
# b) it doesn't interfere with Oculus SDK 0.8
|
|
||||||
if (FALSE)
|
|
||||||
#if (WIN32)
|
|
||||||
# we're using static GLEW, so define GLEW_STATIC
|
# we're using static GLEW, so define GLEW_STATIC
|
||||||
add_definitions(-DGLEW_STATIC)
|
add_definitions(-DGLEW_STATIC)
|
||||||
set(TARGET_NAME openvr)
|
set(TARGET_NAME openvr)
|
||||||
|
|
|
@ -115,6 +115,10 @@ void OpenVrDisplayPlugin::customizeContext() {
|
||||||
glGetError();
|
glGetError();
|
||||||
});
|
});
|
||||||
WindowOpenGLDisplayPlugin::customizeContext();
|
WindowOpenGLDisplayPlugin::customizeContext();
|
||||||
|
|
||||||
|
enableVsync(false);
|
||||||
|
// Only enable mirroring if we know vsync is disabled
|
||||||
|
_enablePreview = !isVsyncEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
uvec2 OpenVrDisplayPlugin::getRecommendedRenderSize() const {
|
uvec2 OpenVrDisplayPlugin::getRecommendedRenderSize() const {
|
||||||
|
@ -156,6 +160,22 @@ void OpenVrDisplayPlugin::internalPresent() {
|
||||||
// Flip y-axis since GL UV coords are backwards.
|
// Flip y-axis since GL UV coords are backwards.
|
||||||
static vr::VRTextureBounds_t leftBounds{ 0, 0, 0.5f, 1 };
|
static vr::VRTextureBounds_t leftBounds{ 0, 0, 0.5f, 1 };
|
||||||
static vr::VRTextureBounds_t rightBounds{ 0.5f, 0, 1, 1 };
|
static vr::VRTextureBounds_t rightBounds{ 0.5f, 0, 1, 1 };
|
||||||
|
|
||||||
|
// screen preview mirroring
|
||||||
|
if (_enablePreview) {
|
||||||
|
auto windowSize = toGlm(_window->size());
|
||||||
|
if (_monoPreview) {
|
||||||
|
glViewport(0, 0, windowSize.x * 2, windowSize.y);
|
||||||
|
glScissor(0, windowSize.y, windowSize.x, windowSize.y);
|
||||||
|
} else {
|
||||||
|
glViewport(0, 0, windowSize.x, windowSize.y);
|
||||||
|
}
|
||||||
|
glBindTexture(GL_TEXTURE_2D, _currentSceneTexture);
|
||||||
|
GLenum err = glGetError();
|
||||||
|
Q_ASSERT(0 == err);
|
||||||
|
drawUnitQuad();
|
||||||
|
}
|
||||||
|
|
||||||
vr::Texture_t texture{ (void*)_currentSceneTexture, vr::API_OpenGL, vr::ColorSpace_Auto };
|
vr::Texture_t texture{ (void*)_currentSceneTexture, vr::API_OpenGL, vr::ColorSpace_Auto };
|
||||||
{
|
{
|
||||||
Lock lock(_mutex);
|
Lock lock(_mutex);
|
||||||
|
@ -174,5 +194,9 @@ void OpenVrDisplayPlugin::internalPresent() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_enablePreview) {
|
||||||
|
swapBuffers();
|
||||||
|
}
|
||||||
|
|
||||||
//WindowOpenGLDisplayPlugin::internalPresent();
|
//WindowOpenGLDisplayPlugin::internalPresent();
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,5 +45,7 @@ protected:
|
||||||
private:
|
private:
|
||||||
vr::IVRSystem* _hmd { nullptr };
|
vr::IVRSystem* _hmd { nullptr };
|
||||||
static const QString NAME;
|
static const QString NAME;
|
||||||
|
bool _enablePreview { false };
|
||||||
|
bool _monoPreview { true };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,8 @@ vr::IVRSystem* acquireOpenVrSystem() {
|
||||||
qCDebug(displayplugins) << "openvr: incrementing refcount";
|
qCDebug(displayplugins) << "openvr: incrementing refcount";
|
||||||
++refCount;
|
++refCount;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
qCDebug(displayplugins) << "openvr: no hmd present";
|
||||||
}
|
}
|
||||||
return activeHmd;
|
return activeHmd;
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,10 +66,12 @@ void ViveControllerManager::activate() {
|
||||||
}
|
}
|
||||||
Q_ASSERT(_hmd);
|
Q_ASSERT(_hmd);
|
||||||
|
|
||||||
|
// OpenVR provides 3d mesh representations of the controllers
|
||||||
|
// Disabled controller rendering code
|
||||||
|
/*
|
||||||
auto renderModels = vr::VRRenderModels();
|
auto renderModels = vr::VRRenderModels();
|
||||||
|
|
||||||
vr::RenderModel_t model;
|
vr::RenderModel_t model;
|
||||||
/*
|
|
||||||
if (!_hmd->LoadRenderModel(CONTROLLER_MODEL_STRING, &model)) {
|
if (!_hmd->LoadRenderModel(CONTROLLER_MODEL_STRING, &model)) {
|
||||||
qDebug() << QString("Unable to load render model %1\n").arg(CONTROLLER_MODEL_STRING);
|
qDebug() << QString("Unable to load render model %1\n").arg(CONTROLLER_MODEL_STRING);
|
||||||
} else {
|
} else {
|
||||||
|
@ -145,6 +147,7 @@ void ViveControllerManager::deactivate() {
|
||||||
void ViveControllerManager::updateRendering(RenderArgs* args, render::ScenePointer scene, render::PendingChanges pendingChanges) {
|
void ViveControllerManager::updateRendering(RenderArgs* args, render::ScenePointer scene, render::PendingChanges pendingChanges) {
|
||||||
PerformanceTimer perfTimer("ViveControllerManager::updateRendering");
|
PerformanceTimer perfTimer("ViveControllerManager::updateRendering");
|
||||||
|
|
||||||
|
/*
|
||||||
if (_modelLoaded) {
|
if (_modelLoaded) {
|
||||||
//auto controllerPayload = new render::Payload<ViveControllerManager>(this);
|
//auto controllerPayload = new render::Payload<ViveControllerManager>(this);
|
||||||
//auto controllerPayloadPointer = ViveControllerManager::PayloadPointer(controllerPayload);
|
//auto controllerPayloadPointer = ViveControllerManager::PayloadPointer(controllerPayload);
|
||||||
|
@ -175,9 +178,11 @@ void ViveControllerManager::updateRendering(RenderArgs* args, render::ScenePoint
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViveControllerManager::renderHand(const controller::Pose& pose, gpu::Batch& batch, int sign) {
|
void ViveControllerManager::renderHand(const controller::Pose& pose, gpu::Batch& batch, int sign) {
|
||||||
|
/*
|
||||||
auto userInputMapper = DependencyManager::get<controller::UserInputMapper>();
|
auto userInputMapper = DependencyManager::get<controller::UserInputMapper>();
|
||||||
Transform transform(userInputMapper->getSensorToWorldMat());
|
Transform transform(userInputMapper->getSensorToWorldMat());
|
||||||
transform.postTranslate(pose.getTranslation() + pose.getRotation() * glm::vec3(0, 0, CONTROLLER_LENGTH_OFFSET));
|
transform.postTranslate(pose.getTranslation() + pose.getRotation() * glm::vec3(0, 0, CONTROLLER_LENGTH_OFFSET));
|
||||||
|
@ -199,6 +204,7 @@ void ViveControllerManager::renderHand(const controller::Pose& pose, gpu::Batch&
|
||||||
// mesh->getVertexBuffer()._stride);
|
// mesh->getVertexBuffer()._stride);
|
||||||
batch.setIndexBuffer(gpu::UINT16, mesh->getIndexBuffer()._buffer, 0);
|
batch.setIndexBuffer(gpu::UINT16, mesh->getIndexBuffer()._buffer, 0);
|
||||||
batch.drawIndexed(gpu::TRIANGLES, mesh->getNumIndices(), 0);
|
batch.drawIndexed(gpu::TRIANGLES, mesh->getNumIndices(), 0);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue