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