1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-15 23:19:56 +00:00
openmw-tes3mp/apps/openmw/mwvr/openxrmanager.cpp

159 lines
3.6 KiB
C++
Raw Normal View History

#include "openxrmanager.hpp"
#include "openxrdebug.hpp"
#include "vrenvironment.hpp"
#include "openxrmanagerimpl.hpp"
#include "../mwinput/inputmanagerimp.hpp"
#include <components/debug/debuglog.hpp>
namespace MWVR
{
OpenXRManager::OpenXRManager()
: mPrivate(nullptr)
, mMutex()
{
}
OpenXRManager::~OpenXRManager()
{
}
bool
OpenXRManager::realized() const
{
return !!mPrivate;
}
void OpenXRManager::handleEvents()
{
if (realized())
return impl().handleEvents();
}
FrameInfo OpenXRManager::waitFrame()
{
return impl().waitFrame();
}
void OpenXRManager::beginFrame()
{
return impl().beginFrame();
}
void OpenXRManager::endFrame(FrameInfo frameInfo, const std::array<CompositionLayerProjectionView, 2>* layerStack)
{
return impl().endFrame(frameInfo, layerStack);
}
bool OpenXRManager::appShouldSyncFrameLoop() const
{
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;
}
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);
}
catch (std::exception& e)
{
std::string error = std::string("Exception thrown while initializing OpenXR: ") + e.what();
Log(Debug::Error) << error;
throw std::runtime_error(error);
}
}
}
void OpenXRManager::enablePredictions()
{
return impl().enablePredictions();
}
void OpenXRManager::disablePredictions()
{
return impl().disablePredictions();
}
2020-02-14 21:11:19 +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)
{
return impl().getPredictedViews(predictedDisplayTime, space);
}
2020-06-24 19:26:11 +00:00
MWVR::Pose OpenXRManager::getPredictedHeadPose(int64_t predictedDisplayTime, ReferenceSpace space)
{
return impl().getPredictedHeadPose(predictedDisplayTime, space);
}
2020-06-24 19:26:11 +00:00
long long OpenXRManager::getLastPredictedDisplayTime()
{
return impl().getLastPredictedDisplayTime();
}
long long OpenXRManager::getLastPredictedDisplayPeriod()
{
return impl().getLastPredictedDisplayPeriod();
}
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();
}
void
OpenXRManager::CleanupOperation::operator()(
osg::GraphicsContext* gc)
{
2020-06-28 09:33:01 +00:00
// TODO: Use this to make proper cleanup such as cleaning up VRFramebuffers.
}
}