]> git.tdb.fi Git - libs/vr.git/commitdiff
Work around a calling convention mismatch between MinGW and VC++
authorMikko Rasa <tdb@tdb.fi>
Tue, 20 Sep 2016 23:37:53 +0000 (02:37 +0300)
committerMikko Rasa <tdb@tdb.fi>
Tue, 20 Sep 2016 23:41:02 +0000 (02:41 +0300)
source/openvr/openvrdevice.cpp

index 466a71fea6645c9ed6fe4f6dfd11b5d67ba6eda5..f6f0bf1cf796cd18c1781e26100c9d68bfe601ba 100644 (file)
@@ -50,8 +50,22 @@ OpenVRDevice::~OpenVRDevice()
 void OpenVRDevice::configure_view(StereoView &view) const
 {
        vr::IVRSystem *vr_sys = vr::VRSystem();
+
+#if defined(__GNUC__) && defined(_WIN32)
+       /* Visual C++ passes the return value address as first stack parameter and
+       the this pointer in ecx.  MinGW does the other way around.  This trick
+       forces the function signature to match at machine code level. */
+       typedef void (vr::IVRSystem::*FuncPtr)(vr::HmdMatrix34_t *, vr::EVREye);
+       FuncPtr get_eye_to_head_transform = reinterpret_cast<FuncPtr>(&vr::IVRSystem::GetEyeToHeadTransform);
+
+       vr::HmdMatrix34_t left, right;
+       (vr_sys->*get_eye_to_head_transform)(&left, vr::Eye_Left);
+       (vr_sys->*get_eye_to_head_transform)(&right, vr::Eye_Right);
+#else
        vr::HmdMatrix34_t left = vr_sys->GetEyeToHeadTransform(vr::Eye_Left);
        vr::HmdMatrix34_t right = vr_sys->GetEyeToHeadTransform(vr::Eye_Right);
+#endif
+       
        view.set_eye_matrices(convert_matrix(left), convert_matrix(right));
 }