mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-06-03 10:21:15 +02:00
35 lines
943 B
C++
35 lines
943 B
C++
//
|
|
// Created by Bradley Austin Davis on 2015/06/12
|
|
// Copyright 2015 High Fidelity, Inc.
|
|
//
|
|
// Distributed under the Apache License, Version 2.0.
|
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
|
//
|
|
#pragma once
|
|
|
|
#include <openvr.h>
|
|
#include <GLMHelpers.h>
|
|
#include <glm/gtc/type_ptr.hpp>
|
|
#include <glm/gtc/matrix_transform.hpp>
|
|
|
|
vr::IVRSystem* acquireOpenVrSystem();
|
|
void releaseOpenVrSystem();
|
|
|
|
template<typename F>
|
|
void openvr_for_each_eye(F f) {
|
|
f(vr::Hmd_Eye::Eye_Left);
|
|
f(vr::Hmd_Eye::Eye_Right);
|
|
}
|
|
|
|
inline mat4 toGlm(const vr::HmdMatrix44_t& m) {
|
|
return glm::transpose(glm::make_mat4(&m.m[0][0]));
|
|
}
|
|
|
|
inline mat4 toGlm(const vr::HmdMatrix34_t& m) {
|
|
mat4 result = mat4(
|
|
m.m[0][0], m.m[1][0], m.m[2][0], 0.0,
|
|
m.m[0][1], m.m[1][1], m.m[2][1], 0.0,
|
|
m.m[0][2], m.m[1][2], m.m[2][2], 0.0,
|
|
m.m[0][3], m.m[1][3], m.m[2][3], 1.0f);
|
|
return result;
|
|
}
|