-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add java api to access the OpenXR config preferences.
- Loading branch information
Showing
3 changed files
with
207 additions
and
0 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,42 @@ | ||
#include <jni.h> | ||
|
||
#include "jni/jni_util.h" | ||
#include "openxr/extensions/xr_fb_color_space_extension_wrapper.h" | ||
#include "openxr/extensions/xr_fb_display_refresh_rate_extension_wrapper.h" | ||
#include <core/Array.hpp> | ||
#include <core/Dictionary.hpp> | ||
|
||
#undef JNI_PACKAGE_NAME | ||
#define JNI_PACKAGE_NAME org_godotengine_plugin_vr_openxr_api | ||
|
||
#undef JNI_CLASS_NAME | ||
#define JNI_CLASS_NAME OpenXRConfig | ||
|
||
extern "C" { | ||
JNIEXPORT jint JNICALL JNI_METHOD(nativeGetXrColorSpace)(JNIEnv *, jclass) { | ||
return XRFbColorSpaceExtensionWrapper::get_singleton()->get_color_space(); | ||
} | ||
|
||
JNIEXPORT void JNICALL JNI_METHOD(nativeSetXrColorSpace)(JNIEnv *, jclass, jint color_space) { | ||
XRFbColorSpaceExtensionWrapper::get_singleton()->set_color_space(color_space); | ||
} | ||
|
||
JNIEXPORT jintArray JNICALL JNI_METHOD(nativeGetAvailableXrColorSpaces)(JNIEnv *env, jclass) { | ||
godot::Dictionary color_spaces = XRFbColorSpaceExtensionWrapper::get_singleton()->get_available_color_spaces(); | ||
godot::Array color_spaces_values = color_spaces.keys(); | ||
return array_to_jintArray(env, color_spaces_values); | ||
} | ||
|
||
JNIEXPORT jdouble JNICALL JNI_METHOD(getRefreshRate)(JNIEnv *, jclass, jobject) { | ||
return XRFbDisplayRefreshRateExtensionWrapper::get_singleton()->get_refresh_rate(); | ||
} | ||
|
||
JNIEXPORT void JNICALL JNI_METHOD(setRefreshRate)(JNIEnv *, jclass, jobject, jdouble refresh_rate) { | ||
XRFbDisplayRefreshRateExtensionWrapper::get_singleton()->set_refresh_rate(refresh_rate); | ||
} | ||
|
||
JNIEXPORT jdoubleArray JNICALL JNI_METHOD(getAvailableRefreshRates)(JNIEnv *env, jclass, jobject) { | ||
godot::Array refresh_rates = XRFbDisplayRefreshRateExtensionWrapper::get_singleton()->get_available_refresh_rates(); | ||
return array_to_jdoubleArray(env, refresh_rates); | ||
} | ||
}; |
126 changes: 126 additions & 0 deletions
126
android/src/main/java/org/godotengine/plugin/vr/openxr/api/OpenXRConfig.kt
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,126 @@ | ||
@file:JvmName("OpenXRConfig") | ||
|
||
package org.godotengine.plugin.vr.openxr.api | ||
|
||
import org.godotengine.plugin.vr.openxr.OpenXRPlugin | ||
|
||
/** | ||
* See https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#XrColorSpaceFB for reference. | ||
*/ | ||
enum class XrColorSpace(internal val value: Int) { | ||
/** | ||
* No color correction, not recommended for production use. | ||
*/ | ||
XR_COLOR_SPACE_UNMANAGED(0), | ||
|
||
/** | ||
* Standard Rec. 2020 chromacities. | ||
* This is the preferred color space for standardized color across all Oculus HMDs | ||
* with D65 white point. | ||
*/ | ||
XR_COLOR_SPACE_REC2020(1), | ||
|
||
/** | ||
* Standard Rec. 709 chromaticities, similar to sRGB. | ||
*/ | ||
XR_COLOR_SPACE_REC709(2), | ||
|
||
/** | ||
* Unique color space, between P3 and Adobe RGB using D75 white point. | ||
* | ||
* Color Space Details with Chromacity Primaries in CIE 1931 xy: | ||
* Red: (0.666, 0.334) | ||
* Green: (0.238, 0.714) | ||
* Blue: (0.139, 0.053) | ||
* White: (0.298, 0.318) | ||
*/ | ||
XR_COLOR_SPACE_RIFT_CV1(3), | ||
|
||
/** | ||
* Unique color space. Similar to Rec 709 using D75. | ||
* | ||
* Color Space Details with Chromacity Primaries in CIE 1931 xy: | ||
* Red: (0.640, 0.330) | ||
* Green: (0.292, 0.586) | ||
* Blue: (0.156, 0.058) | ||
* White: (0.298, 0.318) | ||
*/ | ||
XR_COLOR_SPACE_RIFT_S(4), | ||
|
||
/** | ||
* Unique color space. Similar to Rift CV1 using D75 white point | ||
* | ||
* Color Space Details with Chromacity Primaries in CIE 1931 xy: | ||
* Red: (0.661, 0.338) | ||
* Green: (0.228, 0.718) | ||
* Blue: (0.142, 0.042) | ||
* White: (0.298, 0.318) | ||
*/ | ||
XR_COLOR_SPACE_QUEST(5), | ||
|
||
/** | ||
* Similar to DCI-P3, but uses D65 white point instead. | ||
* | ||
* Color Space Details with Chromacity Primaries in CIE 1931 xy: | ||
* Red: (0.680, 0.320) | ||
* Green: (0.265, 0.690) | ||
* Blue: (0.150, 0.060) | ||
* White: (0.313, 0.329) | ||
*/ | ||
XR_COLOR_SPACE_P3(6), | ||
|
||
/** | ||
* Standard Adobe chromacities. | ||
*/ | ||
XR_COLOR_SPACE_ADOBE_RGB(7); | ||
|
||
companion object { | ||
fun toXrColorSpace(value: Int): XrColorSpace { | ||
for (colorSpace in values()) { | ||
if (colorSpace.value == value) { | ||
return colorSpace | ||
} | ||
} | ||
return XR_COLOR_SPACE_UNMANAGED | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Used to retrieve the device color space. | ||
*/ | ||
fun OpenXRPlugin.getColorSpace() = XrColorSpace.toXrColorSpace(nativeGetXrColorSpace()) | ||
|
||
private external fun nativeGetXrColorSpace(): Int | ||
|
||
/** | ||
* Update the device color space. | ||
*/ | ||
fun OpenXRPlugin.setColorSpace(colorSpace: XrColorSpace) = nativeSetXrColorSpace(colorSpace.value) | ||
|
||
private external fun nativeSetXrColorSpace(colorSpace: Int) | ||
|
||
/** | ||
* Retrieve the list of color spaces supported on this device. | ||
*/ | ||
fun OpenXRPlugin.getAvailableColorSpaces() : Array<XrColorSpace> { | ||
val colorSpaces = nativeGetAvailableXrColorSpaces() | ||
return Array(colorSpaces.size) { XrColorSpace.toXrColorSpace(colorSpaces[it]) } | ||
} | ||
|
||
private external fun nativeGetAvailableXrColorSpaces(): IntArray | ||
|
||
/** | ||
* Retrieve the device current refresh rate. | ||
*/ | ||
external fun OpenXRPlugin.getRefreshRate(): Double | ||
|
||
/** | ||
* Update the device's refresh rate. | ||
*/ | ||
external fun OpenXRPlugin.setRefreshRate(refreshRate: Double) | ||
|
||
/** | ||
* Retrieve the list of refresh rates supported by this device. | ||
*/ | ||
external fun OpenXRPlugin.getAvailableRefreshRates(): DoubleArray |