-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add standard extensions code with cmake options to disable each one
- Loading branch information
Showing
24 changed files
with
1,879 additions
and
236 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* Copyright 2023-24 Beyond Reality Labs Ltd (https://beyondreality.io) | ||
* Copyright 2021-24 Rune Berg (GitHub: https://github.com/1runeberg, YT: https://www.youtube.com/@1RuneBerg, X: https://twitter.com/1runeberg, BSky: https://runeberg.social) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#pragma once | ||
#include <stdint.h> | ||
|
||
namespace xrlib | ||
{ | ||
struct Flag8 | ||
{ | ||
uint8_t flag = 0; | ||
|
||
// True | ||
void Set( int nflag ) { flag |= nflag; } | ||
|
||
// False | ||
void Reset( int nflag ) { flag &= ~nflag; } | ||
|
||
// Flip flop flag value | ||
void Flip( int nflag ) { flag ^= nflag; } | ||
|
||
// Check flag | ||
bool IsSet( int nflag ) { return ( flag & nflag ) == nflag; } | ||
|
||
// Checks for any flag set | ||
bool IsAnySet( int nflags ) { return ( flag & nflags ) != 0; } | ||
|
||
}; | ||
|
||
struct Flag16 | ||
{ | ||
uint16_t flag = 0; | ||
|
||
// True | ||
void Set( int nflag ) { flag |= nflag; } | ||
|
||
// False | ||
void Reset( int nflag ) { flag &= ~nflag; } | ||
|
||
// Flip flop flag value | ||
void Flip( int nflag ) { flag ^= nflag; } | ||
|
||
// Check flag | ||
bool IsSet( int nflag ) { return ( flag & nflag ) == nflag; } | ||
|
||
// Checks for any flag set | ||
bool IsAnySet( int nflags ) { return ( flag & nflags ) != 0; } | ||
}; | ||
} // namespace xrlib |
134 changes: 67 additions & 67 deletions
134
include/xrlib/ext/EXT_hand_tracking.hpp → include/xrlib/ext/EXT/hand_tracking.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,67 @@ | ||
/* | ||
* Copyright 2024 Rune Berg (http://runeberg.io | https://github.com/1runeberg) | ||
* Licensed under Apache 2.0 (https://www.apache.org/licenses/LICENSE-2.0) | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <vector> | ||
#include <array> | ||
#include <xrlib/ext/ext_base.hpp> | ||
|
||
namespace xrlib::EXT | ||
{ | ||
class CHandTracking : public ExtBase | ||
{ | ||
public: | ||
CHandTracking( XrInstance xrInstance ); | ||
~CHandTracking(); | ||
|
||
XrResult Init( XrSession xrSession, | ||
XrHandJointSetEXT leftHandJointSet = XR_HAND_JOINT_SET_DEFAULT_EXT, | ||
void *pNextLeft = nullptr, | ||
XrHandJointSetEXT rightHandJointSet = XR_HAND_JOINT_SET_DEFAULT_EXT, | ||
void *pNextRight = nullptr ); | ||
|
||
struct SJointVelocities | ||
{ | ||
XrHandJointVelocitiesEXT left { XR_TYPE_HAND_JOINT_VELOCITIES_EXT }; | ||
XrHandJointVelocitiesEXT right { XR_TYPE_HAND_JOINT_VELOCITIES_EXT }; | ||
|
||
std::array< XrHandJointVelocityEXT, XR_HAND_JOINT_COUNT_EXT > leftVelocities; | ||
std::array< XrHandJointVelocityEXT, XR_HAND_JOINT_COUNT_EXT > rightVelocities; | ||
|
||
SJointVelocities( void *pNextLeft = nullptr, void *pNextRight = nullptr ); | ||
~SJointVelocities() {}; | ||
}; | ||
|
||
struct SJointLocations | ||
{ | ||
XrHandJointLocationsEXT left { XR_TYPE_HAND_JOINT_LOCATIONS_EXT }; | ||
XrHandJointLocationsEXT right { XR_TYPE_HAND_JOINT_LOCATIONS_EXT }; | ||
|
||
std::array< XrHandJointLocationEXT, XR_HAND_JOINT_COUNT_EXT > leftJointLocations; | ||
std::array< XrHandJointLocationEXT, XR_HAND_JOINT_COUNT_EXT > rightJointLocations; | ||
|
||
SJointLocations( SJointVelocities &jointVelocities ); | ||
SJointLocations( void *pNextLeft = nullptr, void *pNextRight = nullptr ); | ||
~SJointLocations() {}; | ||
}; | ||
|
||
XrResult LocateHandJoints( SJointLocations *outHandJointLocations, XrSpace baseSpace, XrTime time, void *pNextLeft = nullptr, void *pNextRight = nullptr ); | ||
XrResult LocateHandJoints( XrHandJointLocationsEXT *outHandJointLocations, XrHandEXT hand, XrSpace baseSpace, XrTime time, void *pNext = nullptr ); | ||
|
||
XrSystemHandTrackingPropertiesEXT GenerateSystemProperties( void *pNext = nullptr ); | ||
|
||
XrHandTrackerEXT *GetHandTracker( XrHandEXT hand ); | ||
std::vector< XrHandTrackerEXT > &GetHandTrackers() { return m_vecHandTrackers; } | ||
|
||
private: | ||
XrSession m_xrSession = XR_NULL_HANDLE; | ||
PFN_xrLocateHandJointsEXT xrLocateHandJointsEXT = nullptr; | ||
std::vector< XrHandTrackerEXT > m_vecHandTrackers = { XR_NULL_HANDLE, XR_NULL_HANDLE }; | ||
|
||
}; | ||
|
||
} // namespace xrlib | ||
/* | ||
* Copyright 2024 Rune Berg (http://runeberg.io | https://github.com/1runeberg) | ||
* Licensed under Apache 2.0 (https://www.apache.org/licenses/LICENSE-2.0) | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <vector> | ||
#include <array> | ||
#include <xrlib/ext/ext_base.hpp> | ||
|
||
namespace xrlib::EXT | ||
{ | ||
class CHandTracking : public ExtBase | ||
{ | ||
public: | ||
CHandTracking( XrInstance xrInstance ); | ||
~CHandTracking(); | ||
|
||
XrResult Init( XrSession xrSession, | ||
XrHandJointSetEXT leftHandJointSet = XR_HAND_JOINT_SET_DEFAULT_EXT, | ||
void *pNextLeft = nullptr, | ||
XrHandJointSetEXT rightHandJointSet = XR_HAND_JOINT_SET_DEFAULT_EXT, | ||
void *pNextRight = nullptr ); | ||
|
||
struct SJointVelocities | ||
{ | ||
XrHandJointVelocitiesEXT left { XR_TYPE_HAND_JOINT_VELOCITIES_EXT }; | ||
XrHandJointVelocitiesEXT right { XR_TYPE_HAND_JOINT_VELOCITIES_EXT }; | ||
|
||
std::array< XrHandJointVelocityEXT, XR_HAND_JOINT_COUNT_EXT > leftVelocities; | ||
std::array< XrHandJointVelocityEXT, XR_HAND_JOINT_COUNT_EXT > rightVelocities; | ||
|
||
SJointVelocities( void *pNextLeft = nullptr, void *pNextRight = nullptr ); | ||
~SJointVelocities() {}; | ||
}; | ||
|
||
struct SJointLocations | ||
{ | ||
XrHandJointLocationsEXT left { XR_TYPE_HAND_JOINT_LOCATIONS_EXT }; | ||
XrHandJointLocationsEXT right { XR_TYPE_HAND_JOINT_LOCATIONS_EXT }; | ||
|
||
std::array< XrHandJointLocationEXT, XR_HAND_JOINT_COUNT_EXT > leftJointLocations; | ||
std::array< XrHandJointLocationEXT, XR_HAND_JOINT_COUNT_EXT > rightJointLocations; | ||
|
||
SJointLocations( SJointVelocities &jointVelocities ); | ||
SJointLocations( void *pNextLeft = nullptr, void *pNextRight = nullptr ); | ||
~SJointLocations() {}; | ||
}; | ||
|
||
XrResult LocateHandJoints( SJointLocations *outHandJointLocations, XrSpace baseSpace, XrTime time, void *pNextLeft = nullptr, void *pNextRight = nullptr ); | ||
XrResult LocateHandJoints( XrHandJointLocationsEXT *outHandJointLocations, XrHandEXT hand, XrSpace baseSpace, XrTime time, void *pNext = nullptr ); | ||
|
||
XrSystemHandTrackingPropertiesEXT GenerateSystemProperties( void *pNext = nullptr ); | ||
|
||
XrHandTrackerEXT *GetHandTracker( XrHandEXT hand ); | ||
std::vector< XrHandTrackerEXT > &GetHandTrackers() { return m_vecHandTrackers; } | ||
|
||
private: | ||
XrSession m_xrSession = XR_NULL_HANDLE; | ||
PFN_xrLocateHandJointsEXT xrLocateHandJointsEXT = nullptr; | ||
std::vector< XrHandTrackerEXT > m_vecHandTrackers = { XR_NULL_HANDLE, XR_NULL_HANDLE }; | ||
|
||
}; | ||
|
||
} // namespace xrlib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* Copyright 2023-24 Beyond Reality Labs Ltd (https://beyondreality.io) | ||
* Copyright 2021-24 Rune Berg (GitHub: https://github.com/1runeberg, YT: https://www.youtube.com/@1RuneBerg, X: https://twitter.com/1runeberg, BSky: https://runeberg.social) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <xrlib/ext/ext_base.hpp> | ||
|
||
#include <vector> | ||
|
||
namespace xrlib::FB | ||
{ | ||
class DisplayRefreshRate : public ExtBase | ||
{ | ||
public: | ||
|
||
DisplayRefreshRate( XrInstance xrInstance ); | ||
|
||
/// <summary> | ||
/// Retrieve all supported display refresh rates from the openxr runtime that is valid for the running session and hardware | ||
/// </summary> | ||
/// <param name="outSupportedRefreshRates">vector fo floats to put the supported refresh rates in</param> | ||
/// <returns>Result from the openxr runtime of retrieving all supported refresh rates</returns> | ||
XrResult GetSupportedRefreshRates( XrSession xrSession, std::vector< float > &outSupportedRefreshRates ); | ||
|
||
/// <summary> | ||
/// Retrieves the currently active display refresh rate | ||
/// </summary> | ||
/// <returns>The active display refresh rate, 0.0f if an error is encountered (check logs) - you can also check for event XR_TYPE_EVENT_DATA_DISPLAY_REFRESH_RATE_CHANGED_FB</returns> | ||
float GetCurrentRefreshRate( XrSession xrSession ); | ||
|
||
/// <summary> | ||
/// Request a refresh rate from the openxr runtime. Provided refresh rate must be a supported refresh rate via GetSupportedRefreshRates() | ||
/// </summary> | ||
/// <param name="fRequestedRefreshRate">The requested refresh rate. This must be a valid refresh rate from GetSupportedRefreshRates(). Use 0.0f to indicate no prefrence and let the runtime | ||
/// choose the most appropriate one for the session.</param> | ||
/// <returns>Result from the openxr runtime of requesting a refresh rate</returns> | ||
XrResult RequestRefreshRate( XrSession xrSession, float fRequestedRefreshRate ); | ||
|
||
// Below are all the new functions (pointers to them from the runtime) for this spec | ||
// https://registry.khronos.org/OpenXR/specs/1.0/html/xrspec.html#XR_FB_display_refresh_rate | ||
PFN_xrEnumerateDisplayRefreshRatesFB xrEnumerateDisplayRefreshRatesFB = nullptr; | ||
PFN_xrGetDisplayRefreshRateFB xrGetDisplayRefreshRateFB = nullptr; | ||
PFN_xrRequestDisplayRefreshRateFB xrRequestDisplayRefreshRateFB = nullptr; | ||
|
||
private: | ||
|
||
}; | ||
|
||
} |
Oops, something went wrong.