first commit

This commit is contained in:
Your Name
2022-10-20 20:29:11 +08:00
commit 4d531f8044
3238 changed files with 1387862 additions and 0 deletions

122
3rdparty/osgXR/src/OpenXR/System.cpp vendored Normal file
View File

@@ -0,0 +1,122 @@
// SPDX-License-Identifier: LGPL-2.1-only
// Copyright (C) 2021 James Hogan <james@albanarts.com>
#include "System.h"
#include <cstring>
using namespace osgXR::OpenXR;
void System::getProperties() const
{
XrSystemProperties properties;
properties.type = XR_TYPE_SYSTEM_PROPERTIES;
properties.next = nullptr;
if (check(xrGetSystemProperties(getXrInstance(), _systemId, &properties),
"Failed to get OpenXR system properties"))
{
memcpy(_systemName, properties.systemName, sizeof(_systemName));
_orientationTracking = properties.trackingProperties.orientationTracking;
_positionTracking = properties.trackingProperties.positionTracking;
}
_readProperties = true;
}
const System::ViewConfiguration::Views &System::ViewConfiguration::getViews() const
{
if (!_readViews)
{
uint32_t viewCount = 0;
if (check(xrEnumerateViewConfigurationViews(_system->getXrInstance(),
_system->getXrSystemId(),
_type,
0, &viewCount, nullptr),
"Failed to count OpenXR view configuration views"))
{
if (viewCount)
{
std::vector<XrViewConfigurationView> views(viewCount,
{ XR_TYPE_VIEW_CONFIGURATION_VIEW });
if (check(xrEnumerateViewConfigurationViews(_system->getXrInstance(),
_system->getXrSystemId(),
_type,
views.size(), &viewCount,
views.data()),
"Failed to enumerate OpenXR view configuration views"))
{
for (auto &view: views)
_views.push_back(View(view));
}
}
}
_readViews = true;
}
return _views;
}
const System::ViewConfiguration::EnvBlendModes &System::ViewConfiguration::getEnvBlendModes() const
{
if (!_readEnvBlendModes)
{
uint32_t blendModeCount = 0;
if (check(xrEnumerateEnvironmentBlendModes(_system->getXrInstance(),
_system->getXrSystemId(),
_type,
0, &blendModeCount, nullptr),
"Failed to count OpenXR environment blend modes"))
{
if (blendModeCount)
{
_envBlendModes.resize(blendModeCount);
if (!check(xrEnumerateEnvironmentBlendModes(_system->getXrInstance(),
_system->getXrSystemId(),
_type,
_envBlendModes.size(),
&blendModeCount,
_envBlendModes.data()),
"Failed to enumerate OpenXR environment blend modes"))
{
_envBlendModes.resize(0);
}
}
}
_readEnvBlendModes = true;
}
return _envBlendModes;
}
const System::ViewConfigurations &System::getViewConfigurations() const
{
if (!_readViewConfigurations)
{
uint32_t viewConfigCount = 0;
if (check(xrEnumerateViewConfigurations(getXrInstance(), getXrSystemId(),
0, &viewConfigCount, nullptr),
"Failed to count OpenXR view configuration types"))
{
if (viewConfigCount)
{
std::vector<XrViewConfigurationType> types(viewConfigCount);
if (check(xrEnumerateViewConfigurations(getXrInstance(), getXrSystemId(),
types.size(), &viewConfigCount,
types.data()),
"Failed to enumerate OpenXR view configuration types"))
{
_viewConfigurations.reserve(viewConfigCount);
for (auto type: types)
_viewConfigurations.push_back(ViewConfiguration(this, type));
}
}
}
_readViewConfigurations = true;
}
return _viewConfigurations;
}