2020-01-09 23:10:09 +00:00
|
|
|
#include "openxrmanager.hpp"
|
2020-10-17 19:11:31 +00:00
|
|
|
#include "openxrdebug.hpp"
|
2020-06-26 21:02:48 +00:00
|
|
|
#include "vrenvironment.hpp"
|
2020-01-09 23:10:09 +00:00
|
|
|
#include "openxrmanagerimpl.hpp"
|
|
|
|
#include "../mwinput/inputmanagerimp.hpp"
|
|
|
|
|
|
|
|
#include <components/debug/debuglog.hpp>
|
|
|
|
|
|
|
|
namespace MWVR
|
|
|
|
{
|
|
|
|
OpenXRManager::OpenXRManager()
|
|
|
|
: mPrivate(nullptr)
|
|
|
|
, mMutex()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
OpenXRManager::~OpenXRManager()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-02-02 12:12:53 +00:00
|
|
|
bool
|
2020-10-18 12:22:03 +00:00
|
|
|
OpenXRManager::realized() const
|
2020-01-09 23:10:09 +00:00
|
|
|
{
|
|
|
|
return !!mPrivate;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OpenXRManager::handleEvents()
|
|
|
|
{
|
|
|
|
if (realized())
|
2020-01-23 23:14:23 +00:00
|
|
|
return impl().handleEvents();
|
2020-01-09 23:10:09 +00:00
|
|
|
}
|
|
|
|
|
2020-08-02 10:34:46 +00:00
|
|
|
FrameInfo OpenXRManager::waitFrame()
|
2020-01-09 23:10:09 +00:00
|
|
|
{
|
2020-08-02 10:34:46 +00:00
|
|
|
return impl().waitFrame();
|
2020-01-09 23:10:09 +00:00
|
|
|
}
|
|
|
|
|
2020-01-26 19:06:47 +00:00
|
|
|
void OpenXRManager::beginFrame()
|
2020-01-09 23:10:09 +00:00
|
|
|
{
|
2020-08-02 10:34:46 +00:00
|
|
|
return impl().beginFrame();
|
2020-01-09 23:10:09 +00:00
|
|
|
}
|
|
|
|
|
2020-10-18 12:22:03 +00:00
|
|
|
void OpenXRManager::endFrame(FrameInfo frameInfo, const std::array<CompositionLayerProjectionView, 2>* layerStack)
|
|
|
|
{
|
|
|
|
return impl().endFrame(frameInfo, layerStack);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool OpenXRManager::appShouldSyncFrameLoop() const
|
2020-01-09 23:10:09 +00:00
|
|
|
{
|
2020-10-18 12:22:03 +00:00
|
|
|
if (realized())
|
|
|
|
return impl().appShouldSyncFrameLoop();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool OpenXRManager::appShouldRender() const
|
|
|
|
{
|
|
|
|
if (realized())
|
|
|
|
return impl().appShouldRender();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool OpenXRManager::appShouldReadInput() const
|
|
|
|
{
|
|
|
|
if (realized())
|
|
|
|
return impl().appShouldReadInput();
|
|
|
|
return false;
|
2020-01-09 23:10:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
OpenXRManager::realize(
|
|
|
|
osg::GraphicsContext* gc)
|
|
|
|
{
|
|
|
|
lock_guard lock(mMutex);
|
|
|
|
if (!realized())
|
|
|
|
{
|
|
|
|
gc->makeCurrent();
|
|
|
|
try {
|
2020-12-30 14:03:40 +00:00
|
|
|
mPrivate = std::make_shared<OpenXRManagerImpl>(gc);
|
2020-01-09 23:10:09 +00:00
|
|
|
}
|
2020-06-26 21:02:48 +00:00
|
|
|
catch (std::exception& e)
|
2020-01-09 23:10:09 +00:00
|
|
|
{
|
2020-12-30 10:02:12 +00:00
|
|
|
std::string error = std::string("Exception thrown while initializing OpenXR: ") + e.what();
|
|
|
|
Log(Debug::Error) << error;
|
|
|
|
throw std::runtime_error(error);
|
2020-01-09 23:10:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-21 21:40:07 +00:00
|
|
|
void OpenXRManager::enablePredictions()
|
2020-01-09 23:10:09 +00:00
|
|
|
{
|
2020-06-21 21:40:07 +00:00
|
|
|
return impl().enablePredictions();
|
2020-01-09 23:10:09 +00:00
|
|
|
}
|
|
|
|
|
2020-06-21 21:40:07 +00:00
|
|
|
void OpenXRManager::disablePredictions()
|
2020-01-09 23:10:09 +00:00
|
|
|
{
|
2020-06-21 21:40:07 +00:00
|
|
|
return impl().disablePredictions();
|
2020-01-09 23:10:09 +00:00
|
|
|
}
|
2020-02-14 21:11:19 +00:00
|
|
|
|
2020-07-21 10:28:39 +00:00
|
|
|
void OpenXRManager::xrResourceAcquired()
|
|
|
|
{
|
|
|
|
return impl().xrResourceAcquired();
|
|
|
|
}
|
|
|
|
|
|
|
|
void OpenXRManager::xrResourceReleased()
|
|
|
|
{
|
|
|
|
return impl().xrResourceReleased();
|
|
|
|
}
|
|
|
|
|
2020-06-24 19:26:11 +00:00
|
|
|
std::array<View, 2> OpenXRManager::getPredictedViews(int64_t predictedDisplayTime, ReferenceSpace space)
|
2020-05-01 19:37:01 +00:00
|
|
|
{
|
2020-06-21 21:40:07 +00:00
|
|
|
return impl().getPredictedViews(predictedDisplayTime, space);
|
2020-05-01 19:37:01 +00:00
|
|
|
}
|
2020-05-24 16:00:42 +00:00
|
|
|
|
2020-06-24 19:26:11 +00:00
|
|
|
MWVR::Pose OpenXRManager::getPredictedHeadPose(int64_t predictedDisplayTime, ReferenceSpace space)
|
2020-05-01 19:37:01 +00:00
|
|
|
{
|
2020-06-21 21:40:07 +00:00
|
|
|
return impl().getPredictedHeadPose(predictedDisplayTime, space);
|
2020-05-01 19:37:01 +00:00
|
|
|
}
|
2020-05-24 16:00:42 +00:00
|
|
|
|
2020-06-24 19:26:11 +00:00
|
|
|
long long OpenXRManager::getLastPredictedDisplayTime()
|
|
|
|
{
|
|
|
|
return impl().getLastPredictedDisplayTime();
|
|
|
|
}
|
|
|
|
|
2020-06-21 21:40:07 +00:00
|
|
|
long long OpenXRManager::getLastPredictedDisplayPeriod()
|
2020-05-24 16:00:42 +00:00
|
|
|
{
|
2020-06-21 21:40:07 +00:00
|
|
|
return impl().getLastPredictedDisplayPeriod();
|
2020-05-24 16:00:42 +00:00
|
|
|
}
|
|
|
|
|
2020-06-24 19:26:11 +00:00
|
|
|
std::array<SwapchainConfig, 2> OpenXRManager::getRecommendedSwapchainConfig() const
|
|
|
|
{
|
|
|
|
return impl().getRecommendedSwapchainConfig();
|
|
|
|
}
|
|
|
|
|
2020-07-15 21:17:16 +00:00
|
|
|
bool OpenXRManager::xrExtensionIsEnabled(const char* extensionName) const
|
|
|
|
{
|
|
|
|
return impl().xrExtensionIsEnabled(extensionName);
|
|
|
|
}
|
|
|
|
|
2020-12-30 14:03:40 +00:00
|
|
|
int64_t OpenXRManager::selectColorFormat()
|
|
|
|
{
|
|
|
|
return impl().selectColorFormat();
|
|
|
|
}
|
|
|
|
|
|
|
|
int64_t OpenXRManager::selectDepthFormat()
|
|
|
|
{
|
|
|
|
return impl().selectDepthFormat();
|
|
|
|
}
|
|
|
|
|
2020-06-21 21:40:07 +00:00
|
|
|
void
|
|
|
|
OpenXRManager::CleanupOperation::operator()(
|
|
|
|
osg::GraphicsContext* gc)
|
2020-06-02 19:45:18 +00:00
|
|
|
{
|
2020-06-28 09:33:01 +00:00
|
|
|
// TODO: Use this to make proper cleanup such as cleaning up VRFramebuffers.
|
2020-06-02 19:45:18 +00:00
|
|
|
}
|
2020-01-09 23:10:09 +00:00
|
|
|
}
|
2020-01-23 23:14:23 +00:00
|
|
|
|