mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-06-17 08:00:22 +02:00
Working on 0.6
This commit is contained in:
parent
6a60da2a6c
commit
de268c47b3
3 changed files with 98 additions and 84 deletions
|
@ -1860,8 +1860,7 @@ void Application::setEnableVRMode(bool enableVRMode) {
|
||||||
// attempt to reconnect the Oculus manager - it's possible this was a workaround
|
// attempt to reconnect the Oculus manager - it's possible this was a workaround
|
||||||
// for the sixense crash
|
// for the sixense crash
|
||||||
OculusManager::disconnect();
|
OculusManager::disconnect();
|
||||||
_glWidget->makeCurrent();
|
OculusManager::connect(_glWidget->context()->contextHandle());
|
||||||
OculusManager::connect();
|
|
||||||
}
|
}
|
||||||
OculusManager::recalibrate();
|
OculusManager::recalibrate();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include <avatar/AvatarManager.h>
|
#include <avatar/AvatarManager.h>
|
||||||
#include <avatar/MyAvatar.h>
|
#include <avatar/MyAvatar.h>
|
||||||
#include <GlowEffect.h>
|
#include <GlowEffect.h>
|
||||||
|
#include <GlWindow.h>
|
||||||
#include <gpu/GLBackend.h>
|
#include <gpu/GLBackend.h>
|
||||||
#include <OglplusHelpers.h>
|
#include <OglplusHelpers.h>
|
||||||
#include <PathUtils.h>
|
#include <PathUtils.h>
|
||||||
|
@ -177,6 +178,7 @@ ovrLayerEyeFov OculusManager::_sceneLayer;
|
||||||
#else
|
#else
|
||||||
|
|
||||||
ovrTexture OculusManager::_eyeTextures[ovrEye_Count];
|
ovrTexture OculusManager::_eyeTextures[ovrEye_Count];
|
||||||
|
GlWindow* OculusManager::_outputWindow{ nullptr };
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -197,12 +199,12 @@ float OculusManager::CALIBRATION_DELTA_MINIMUM_LENGTH = 0.02f;
|
||||||
float OculusManager::CALIBRATION_DELTA_MINIMUM_ANGLE = 5.0f * RADIANS_PER_DEGREE;
|
float OculusManager::CALIBRATION_DELTA_MINIMUM_ANGLE = 5.0f * RADIANS_PER_DEGREE;
|
||||||
float OculusManager::CALIBRATION_ZERO_MAXIMUM_LENGTH = 0.01f;
|
float OculusManager::CALIBRATION_ZERO_MAXIMUM_LENGTH = 0.01f;
|
||||||
float OculusManager::CALIBRATION_ZERO_MAXIMUM_ANGLE = 2.0f * RADIANS_PER_DEGREE;
|
float OculusManager::CALIBRATION_ZERO_MAXIMUM_ANGLE = 2.0f * RADIANS_PER_DEGREE;
|
||||||
quint64 OculusManager::CALIBRATION_ZERO_HOLD_TIME = 3000000; // usec
|
uint64_t OculusManager::CALIBRATION_ZERO_HOLD_TIME = 3000000; // usec
|
||||||
float OculusManager::CALIBRATION_MESSAGE_DISTANCE = 2.5f;
|
float OculusManager::CALIBRATION_MESSAGE_DISTANCE = 2.5f;
|
||||||
OculusManager::CalibrationState OculusManager::_calibrationState;
|
OculusManager::CalibrationState OculusManager::_calibrationState;
|
||||||
glm::vec3 OculusManager::_calibrationPosition;
|
glm::vec3 OculusManager::_calibrationPosition;
|
||||||
glm::quat OculusManager::_calibrationOrientation;
|
glm::quat OculusManager::_calibrationOrientation;
|
||||||
quint64 OculusManager::_calibrationStartTime;
|
uint64_t OculusManager::_calibrationStartTime;
|
||||||
int OculusManager::_calibrationMessage = 0;
|
int OculusManager::_calibrationMessage = 0;
|
||||||
glm::vec3 OculusManager::_eyePositions[ovrEye_Count];
|
glm::vec3 OculusManager::_eyePositions[ovrEye_Count];
|
||||||
// TODO expose this as a developer toggle
|
// TODO expose this as a developer toggle
|
||||||
|
@ -218,13 +220,15 @@ void OculusManager::init() {
|
||||||
void OculusManager::deinit() {
|
void OculusManager::deinit() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void OculusManager::connect() {
|
void OculusManager::connect(QOpenGLContext* shareContext) {
|
||||||
qCDebug(interfaceapp) << "Oculus SDK" << OVR_VERSION_STRING;
|
qCDebug(interfaceapp) << "Oculus SDK" << OVR_VERSION_STRING;
|
||||||
|
|
||||||
ovrInitParams initParams; memset(&initParams, 0, sizeof(initParams));
|
ovrInitParams initParams; memset(&initParams, 0, sizeof(initParams));
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
//initParams.Flags |= ovrInit_Debug;
|
initParams.Flags |= ovrInit_Debug;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ovr_Initialize(&initParams);
|
ovr_Initialize(&initParams);
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
|
@ -246,12 +250,16 @@ void OculusManager::connect() {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
_isConnected = false;
|
#endif
|
||||||
|
|
||||||
|
if (!_ovrHmd) {
|
||||||
|
_isConnected = false;
|
||||||
// we're definitely not in "VR mode" so tell the menu that
|
// we're definitely not in "VR mode" so tell the menu that
|
||||||
Menu::getInstance()->getActionForOption(MenuOption::EnableVRMode)->setChecked(false);
|
Menu::getInstance()->getActionForOption(MenuOption::EnableVRMode)->setChecked(false);
|
||||||
|
ovr_Shutdown();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
_calibrationState = UNCALIBRATED;
|
_calibrationState = UNCALIBRATED;
|
||||||
if (!_isConnected) {
|
if (!_isConnected) {
|
||||||
UserActivityLogger::getInstance().connectedDevice("hmd", "oculus");
|
UserActivityLogger::getInstance().connectedDevice("hmd", "oculus");
|
||||||
|
@ -283,12 +291,21 @@ void OculusManager::connect() {
|
||||||
_sceneLayer.Fov[eye] = _eyeFov[eye];
|
_sceneLayer.Fov[eye] = _eyeFov[eye];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
_outputWindow = new GlWindow(shareContext);
|
||||||
|
_outputWindow->show();
|
||||||
|
_outputWindow->setFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
|
||||||
|
_outputWindow->resize(_ovrHmd->Resolution.w, _ovrHmd->Resolution.h);
|
||||||
|
// _outputWindow->setPosition(_ovrHmd->Position.x, _ovrHmd->Position.y);
|
||||||
|
_outputWindow->makeCurrent();
|
||||||
|
|
||||||
ovrGLConfig cfg;
|
ovrGLConfig cfg;
|
||||||
memset(&cfg, 0, sizeof(cfg));
|
memset(&cfg, 0, sizeof(cfg));
|
||||||
cfg.OGL.Header.API = ovrRenderAPI_OpenGL;
|
cfg.OGL.Header.API = ovrRenderAPI_OpenGL;
|
||||||
cfg.OGL.Header.BackBufferSize = _ovrHmd->Resolution;
|
cfg.OGL.Header.BackBufferSize = _ovrHmd->Resolution;
|
||||||
cfg.OGL.Header.Multisample = 1;
|
cfg.OGL.Header.Multisample = 0;
|
||||||
|
|
||||||
int distortionCaps = 0
|
int distortionCaps = 0
|
||||||
| ovrDistortionCap_Vignette
|
| ovrDistortionCap_Vignette
|
||||||
|
@ -314,22 +331,17 @@ void OculusManager::connect() {
|
||||||
});
|
});
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ovrHmd_SetEnabledCaps(_ovrHmd, ovrHmdCap_LowPersistence | ovrHmdCap_DynamicPrediction);
|
ovrHmd_SetEnabledCaps(_ovrHmd,
|
||||||
|
ovrHmdCap_LowPersistence | ovrHmdCap_DynamicPrediction);
|
||||||
|
|
||||||
ovrHmd_ConfigureTracking(_ovrHmd, ovrTrackingCap_Orientation | ovrTrackingCap_Position |
|
ovrHmd_ConfigureTracking(_ovrHmd,
|
||||||
ovrTrackingCap_MagYawCorrection,
|
ovrTrackingCap_Orientation | ovrTrackingCap_Position | ovrTrackingCap_MagYawCorrection,
|
||||||
ovrTrackingCap_Orientation);
|
ovrTrackingCap_Orientation);
|
||||||
|
|
||||||
if (!_camera) {
|
if (!_camera) {
|
||||||
_camera = new Camera;
|
_camera = new Camera;
|
||||||
configureCamera(*_camera); // no need to use screen dimensions; they're ignored
|
configureCamera(*_camera); // no need to use screen dimensions; they're ignored
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
_isConnected = false;
|
|
||||||
|
|
||||||
// we're definitely not in "VR mode" so tell the menu that
|
|
||||||
Menu::getInstance()->getActionForOption(MenuOption::EnableVRMode)->setChecked(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Disconnects and deallocates the OR
|
//Disconnects and deallocates the OR
|
||||||
|
@ -460,7 +472,6 @@ void OculusManager::calibrate(glm::vec3 position, glm::quat orientation) {
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -713,16 +724,17 @@ void OculusManager::display(QGLWidget * glCanvas, const glm::quat &bodyOrientati
|
||||||
glEyeTexture.OGL.TexId = textureId;
|
glEyeTexture.OGL.TexId = textureId;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
_outputWindow->makeCurrent();
|
||||||
// restore our normal viewport
|
// restore our normal viewport
|
||||||
glViewport(0, 0, deviceSize.width(), deviceSize.height());
|
|
||||||
ovrHmd_EndFrame(_ovrHmd, eyeRenderPose, _eyeTextures);
|
ovrHmd_EndFrame(_ovrHmd, eyeRenderPose, _eyeTextures);
|
||||||
|
|
||||||
|
//auto outputSize = _outputWindow->size();
|
||||||
//glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
//glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
//auto srcFboSize = finalFbo->getSize();
|
//auto srcFboSize = finalFbo->getSize();
|
||||||
//glBindFramebuffer(GL_READ_FRAMEBUFFER, gpu::GLBackend::getFramebufferID(finalFbo));
|
//glBindFramebuffer(GL_READ_FRAMEBUFFER, gpu::GLBackend::getFramebufferID(finalFbo));
|
||||||
//glBlitFramebuffer(
|
//glBlitFramebuffer(
|
||||||
// 0, 0, srcFboSize.x, srcFboSize.y,
|
// 0, 0, srcFboSize.x, srcFboSize.y,
|
||||||
// 0, 0, deviceSize.width(), deviceSize.height(),
|
// 0, 0, outputSize.width(), outputSize.height(),
|
||||||
// GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
// GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
||||||
//glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
|
//glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
|
||||||
//glCanvas->swapBuffers();
|
//glCanvas->swapBuffers();
|
||||||
|
|
|
@ -20,7 +20,9 @@
|
||||||
#include <glm/gtc/matrix_transform.hpp>
|
#include <glm/gtc/matrix_transform.hpp>
|
||||||
#include <glm/gtc/type_ptr.hpp>
|
#include <glm/gtc/type_ptr.hpp>
|
||||||
|
|
||||||
|
class QOpenGLContext;
|
||||||
class Camera;
|
class Camera;
|
||||||
|
class GlWindow;
|
||||||
class PalmData;
|
class PalmData;
|
||||||
class Text3DOverlay;
|
class Text3DOverlay;
|
||||||
|
|
||||||
|
@ -35,7 +37,7 @@ class OculusManager {
|
||||||
public:
|
public:
|
||||||
static void init();
|
static void init();
|
||||||
static void deinit();
|
static void deinit();
|
||||||
static void connect();
|
static void connect(QOpenGLContext* shareContext);
|
||||||
static void disconnect();
|
static void disconnect();
|
||||||
static bool isConnected();
|
static bool isConnected();
|
||||||
static void recalibrate();
|
static void recalibrate();
|
||||||
|
@ -113,6 +115,7 @@ private:
|
||||||
static ovrLayerEyeFov _sceneLayer;
|
static ovrLayerEyeFov _sceneLayer;
|
||||||
#else
|
#else
|
||||||
static ovrTexture _eyeTextures[ovrEye_Count];
|
static ovrTexture _eyeTextures[ovrEye_Count];
|
||||||
|
static GlWindow* _outputWindow;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue