mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 03:17:02 +02:00
Simulating Oculus interaction on legacy platforms
This commit is contained in:
parent
e0e1ae43f5
commit
79d8b20637
2 changed files with 21 additions and 45 deletions
|
@ -26,7 +26,7 @@
|
||||||
|
|
||||||
using namespace oglplus;
|
using namespace oglplus;
|
||||||
|
|
||||||
const QString OculusLegacyDisplayPlugin::NAME("Oculus Rift (0.5)");
|
const QString OculusLegacyDisplayPlugin::NAME("Oculus Rift (0.5) (Simulated)");
|
||||||
|
|
||||||
const QString & OculusLegacyDisplayPlugin::getName() const {
|
const QString & OculusLegacyDisplayPlugin::getName() const {
|
||||||
return NAME;
|
return NAME;
|
||||||
|
@ -56,12 +56,11 @@ glm::mat4 OculusLegacyDisplayPlugin::getHeadPose(uint32_t frameIndex) const {
|
||||||
static uint32_t lastFrameSeen = 0;
|
static uint32_t lastFrameSeen = 0;
|
||||||
if (frameIndex > lastFrameSeen) {
|
if (frameIndex > lastFrameSeen) {
|
||||||
Lock lock(_mutex);
|
Lock lock(_mutex);
|
||||||
// auto trackingState = ovr_GetTrackingState(_session, displayTime, frameIndex > lastFrameSeen);
|
_trackingState = ovrHmd_GetTrackingState(_hmd, ovr_GetTimeInSeconds());
|
||||||
// ovrHmd_GetEyePoses(_hmd, frameIndex, _eyeOffsets, _eyePoses, &_trackingState);
|
ovrHmd_GetEyePoses(_hmd, frameIndex, _eyeOffsets, _eyePoses, &_trackingState);
|
||||||
lastFrameSeen = frameIndex;
|
lastFrameSeen = frameIndex;
|
||||||
}
|
}
|
||||||
// return toGlm(trackingState.HeadPose.ThePose);
|
return toGlm(_trackingState.HeadPose.ThePose);
|
||||||
return glm::mat4();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OculusLegacyDisplayPlugin::isSupported() const {
|
bool OculusLegacyDisplayPlugin::isSupported() const {
|
||||||
|
@ -93,7 +92,6 @@ bool OculusLegacyDisplayPlugin::isSupported() const {
|
||||||
|
|
||||||
void OculusLegacyDisplayPlugin::activate() {
|
void OculusLegacyDisplayPlugin::activate() {
|
||||||
WindowOpenGLDisplayPlugin::activate();
|
WindowOpenGLDisplayPlugin::activate();
|
||||||
|
|
||||||
|
|
||||||
if (!(ovr_Initialize(nullptr))) {
|
if (!(ovr_Initialize(nullptr))) {
|
||||||
Q_ASSERT(false);
|
Q_ASSERT(false);
|
||||||
|
@ -135,37 +133,26 @@ void OculusLegacyDisplayPlugin::activate() {
|
||||||
ovrTrackingCap_Orientation | ovrTrackingCap_Position | ovrTrackingCap_MagYawCorrection, 0)) {
|
ovrTrackingCap_Orientation | ovrTrackingCap_Position | ovrTrackingCap_MagYawCorrection, 0)) {
|
||||||
qFatal("Could not attach to sensor device");
|
qFatal("Could not attach to sensor device");
|
||||||
}
|
}
|
||||||
|
|
||||||
int screen = getHmdScreen();
|
|
||||||
if (screen != -1) {
|
|
||||||
_container->setFullscreen(qApp->screens()[screen]);
|
|
||||||
}
|
|
||||||
|
|
||||||
_window->installEventFilter(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OculusLegacyDisplayPlugin::deactivate() {
|
void OculusLegacyDisplayPlugin::deactivate() {
|
||||||
_window->removeEventFilter(this);
|
|
||||||
WindowOpenGLDisplayPlugin::deactivate();
|
WindowOpenGLDisplayPlugin::deactivate();
|
||||||
|
|
||||||
QScreen* riftScreen = nullptr;
|
|
||||||
if (_hmdScreen >= 0) {
|
|
||||||
riftScreen = qApp->screens()[_hmdScreen];
|
|
||||||
}
|
|
||||||
_container->unsetFullscreen(riftScreen);
|
|
||||||
|
|
||||||
ovrHmd_Destroy(_hmd);
|
ovrHmd_Destroy(_hmd);
|
||||||
_hmd = nullptr;
|
_hmd = nullptr;
|
||||||
ovr_Shutdown();
|
ovr_Shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// DLL based display plugins MUST initialize GLEW inside the DLL code.
|
// DLL based display plugins MUST initialize GLEW inside the DLL code.
|
||||||
void OculusLegacyDisplayPlugin::customizeContext() {
|
void OculusLegacyDisplayPlugin::customizeContext() {
|
||||||
glewExperimental = true;
|
static std::once_flag once;
|
||||||
glewInit();
|
std::call_once(once, []{
|
||||||
glGetError();
|
glewExperimental = true;
|
||||||
|
glewInit();
|
||||||
|
glGetError();
|
||||||
|
});
|
||||||
WindowOpenGLDisplayPlugin::customizeContext();
|
WindowOpenGLDisplayPlugin::customizeContext();
|
||||||
|
#if 0
|
||||||
ovrGLConfig config; memset(&config, 0, sizeof(ovrRenderAPIConfig));
|
ovrGLConfig config; memset(&config, 0, sizeof(ovrRenderAPIConfig));
|
||||||
auto& header = config.Config.Header;
|
auto& header = config.Config.Header;
|
||||||
header.API = ovrRenderAPI_OpenGL;
|
header.API = ovrRenderAPI_OpenGL;
|
||||||
|
@ -190,8 +177,11 @@ void OculusLegacyDisplayPlugin::customizeContext() {
|
||||||
#endif
|
#endif
|
||||||
ovrHmd_ConfigureRendering(_hmd, &config.Config, distortionCaps, _eyeFovs, _eyeRenderDescs);
|
ovrHmd_ConfigureRendering(_hmd, &config.Config, distortionCaps, _eyeFovs, _eyeRenderDescs);
|
||||||
assert(result);
|
assert(result);
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
void OculusLegacyDisplayPlugin::uncustomizeContext() {
|
void OculusLegacyDisplayPlugin::uncustomizeContext() {
|
||||||
WindowOpenGLDisplayPlugin::uncustomizeContext();
|
WindowOpenGLDisplayPlugin::uncustomizeContext();
|
||||||
}
|
}
|
||||||
|
@ -204,21 +194,7 @@ void OculusLegacyDisplayPlugin::internalPresent() {
|
||||||
ovrHmd_EndFrame(_hmd, _eyePoses, _eyeTextures);
|
ovrHmd_EndFrame(_hmd, _eyePoses, _eyeTextures);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
#endif
|
||||||
// Pass input events on to the application
|
|
||||||
bool OculusLegacyDisplayPlugin::eventFilter(QObject* receiver, QEvent* event) {
|
|
||||||
if (!_hswDismissed && (event->type() == QEvent::KeyPress)) {
|
|
||||||
static ovrHSWDisplayState hswState;
|
|
||||||
ovrHmd_GetHSWDisplayState(_hmd, &hswState);
|
|
||||||
if (hswState.Displayed) {
|
|
||||||
ovrHmd_DismissHSWDisplay(_hmd);
|
|
||||||
} else {
|
|
||||||
_hswDismissed = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return WindowOpenGLDisplayPlugin::eventFilter(receiver, event);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
int OculusLegacyDisplayPlugin::getHmdScreen() const {
|
int OculusLegacyDisplayPlugin::getHmdScreen() const {
|
||||||
return _hmdScreen;
|
return _hmdScreen;
|
||||||
|
|
|
@ -24,7 +24,6 @@ public:
|
||||||
virtual void activate() override;
|
virtual void activate() override;
|
||||||
virtual void deactivate() override;
|
virtual void deactivate() override;
|
||||||
|
|
||||||
// virtual bool eventFilter(QObject* receiver, QEvent* event) override;
|
|
||||||
virtual int getHmdScreen() const override;
|
virtual int getHmdScreen() const override;
|
||||||
|
|
||||||
// Stereo specific methods
|
// Stereo specific methods
|
||||||
|
@ -40,17 +39,18 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void customizeContext() override;
|
virtual void customizeContext() override;
|
||||||
|
#if 0
|
||||||
virtual void uncustomizeContext() override;
|
virtual void uncustomizeContext() override;
|
||||||
virtual void internalPresent() override;
|
virtual void internalPresent() override;
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const QString NAME;
|
static const QString NAME;
|
||||||
|
|
||||||
ovrHmd _hmd;
|
ovrHmd _hmd;
|
||||||
std::mutex _statelock;
|
mutable ovrTrackingState _trackingState;
|
||||||
ovrTrackingState _trackingState;
|
|
||||||
ovrEyeRenderDesc _eyeRenderDescs[2];
|
ovrEyeRenderDesc _eyeRenderDescs[2];
|
||||||
ovrPosef _eyePoses[2];
|
mutable ovrPosef _eyePoses[2];
|
||||||
ovrVector3f _eyeOffsets[2];
|
ovrVector3f _eyeOffsets[2];
|
||||||
ovrFovPort _eyeFovs[2];
|
ovrFovPort _eyeFovs[2];
|
||||||
mat4 _eyeProjections[3];
|
mat4 _eyeProjections[3];
|
||||||
|
|
Loading…
Reference in a new issue