Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ViroRenderer/VROInputControllerBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,9 @@ void VROInputControllerBase::onScroll(int source, float x, float y) {
}

void VROInputControllerBase::processGazeEvent(int source) {
if (_hitResult == nullptr) {
return;
}
std::shared_ptr<VRONode> newNode = getNodeToHandleEvent(VROEventDelegate::EventAction::OnHover,
_hitResult->getNode());
for (std::shared_ptr<VROEventDelegate> delegate : _delegates) {
Expand Down
14 changes: 11 additions & 3 deletions ViroRenderer/VROInputType.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,17 @@ namespace ViroCardBoard{

namespace ViroOculus{
enum InputSource{
Controller = 1,
TouchPad = 2,
BackButton = 3
Controller = 1, // right controller primary ray (legacy alias for RightController)
TouchPad = 2,
BackButton = 3, // menu (left) and B (right) buttons — navigation / back
LeftController = 4, // left controller primary ray
AButton = 5, // right-hand A button
XButton = 6, // left-hand X button
YButton = 7, // left-hand Y button
LeftGrip = 8, // left grip / squeeze
RightGrip = 9, // right grip / squeeze
LeftThumbstick = 10, // left thumbstick scroll axis
RightThumbstick = 11, // right thumbstick scroll axis
};
}
#endif
36 changes: 32 additions & 4 deletions ViroRenderer/VROPlatformUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ std::string VROPlatformDownloadURLToFile(std::string url, bool *temp, bool *succ
JNIEnv *env = VROPlatformGetJNIEnv();
VRO_STRING jurl = VRO_NEW_STRING(url.c_str());

jclass cls = env->FindClass("com/viro/core/internal/PlatformUtil");
jclass cls = env->GetObjectClass(sPlatformUtil);
jmethodID jmethod = env->GetMethodID(cls, "downloadURLToTempFile", "(Ljava/lang/String;)Ljava/lang/String;");
VRO_STRING jpath = (VRO_STRING) env->CallObjectMethod(sPlatformUtil, jmethod, jurl);

Expand Down Expand Up @@ -1069,14 +1069,42 @@ void VROPlatformDispatchAsyncBackground(std::function<void()> fcn) {
JNIEnv *env;
getJNIEnv(&env);

jclass cls = env->FindClass("com/viro/core/internal/PlatformUtil");
// GetObjectClass works on any thread (no class-loader dependency).
// FindClass("com/viro/core/...") fails on pure-native threads that only
// have the bootstrap class loader (e.g. the OpenXR render thread).
jclass cls = env->GetObjectClass(sPlatformUtil);
jmethodID jmethod = env->GetMethodID(cls, "dispatchAsyncBackground", "(I)V");
env->CallVoidMethod(sPlatformUtil, jmethod, task);

env->DeleteLocalRef(cls);
}

// ── Direct renderer queue (for OpenXR / renderers without GLSurfaceView) ──────
static std::atomic<bool> sUseDirectRendererQueue { false };
static std::mutex sDirectRendererQueueMutex;
static std::vector<std::function<void()>> sDirectRendererQueue;

void VROPlatformSetUseDirectRendererQueue(bool use) {
sUseDirectRendererQueue.store(use);
}

void VROPlatformDrainRendererQueue() {
std::vector<std::function<void()>> tasks;
{
std::lock_guard<std::mutex> guard(sDirectRendererQueueMutex);
tasks.swap(sDirectRendererQueue);
}
for (auto &task : tasks) {
task();
}
}

void VROPlatformDispatchAsyncRenderer(std::function<void()> fcn) {
if (sUseDirectRendererQueue.load()) {
std::lock_guard<std::mutex> guard(sDirectRendererQueueMutex);
sDirectRendererQueue.push_back(std::move(fcn));
return;
}
int task = VROPlatformGenerateTask(fcn);
if (!sPlatformUtil) {
std::lock_guard<std::mutex> guard(sRendererQueueMutex);
Expand Down Expand Up @@ -1105,7 +1133,7 @@ void VROPlatformFlushTaskQueues() {
JNIEnv *env;
getJNIEnv(&env);

jclass cls = env->FindClass("com/viro/core/internal/PlatformUtil");
jclass cls = env->GetObjectClass(sPlatformUtil);
jmethodID jmethod = env->GetMethodID(cls, "dispatchAsyncBackground", "(I)V");
env->CallVoidMethod(sPlatformUtil, jmethod, task);

Expand Down Expand Up @@ -1299,7 +1327,7 @@ std::string VROPlatformGetCacheDirectory() {
JNIEnv *env;
getJNIEnv(&env);

jclass cls = env->FindClass("com/viro/core/internal/PlatformUtil");
jclass cls = env->GetObjectClass(sPlatformUtil);
jmethodID jmethod = env->GetMethodID(cls, "getCacheDirectory", "()Ljava/lang/String;");
VRO_STRING jpath = (VRO_STRING) env->CallObjectMethod(sPlatformUtil, jmethod);

Expand Down
13 changes: 13 additions & 0 deletions ViroRenderer/VROPlatformUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ enum class VROPlatformType {
Unknown,
AndroidGVR,
AndroidOVR,
AndroidOpenXR,
AndroidARCore,
AndroidSceneView,
iOSCardboard,
Expand Down Expand Up @@ -163,6 +164,18 @@ VROTextureFormat VROPlatformGetBitmapFormat(jobject jbitmap);
*/
void VROPlatformDispatchAsyncRenderer(std::function<void()> fcn);

/*
OpenXR / headless-GL renderers that own their own render thread should call
VROPlatformSetUseDirectRendererQueue(true) during initialisation. All
subsequent VROPlatformDispatchAsyncRenderer calls will enqueue into a C++
queue instead of going through the GLSurfaceView Java path.

The render thread must call VROPlatformDrainRendererQueue() every frame to
execute queued work (e.g. setSceneController, texture uploads).
*/
void VROPlatformSetUseDirectRendererQueue(bool use);
void VROPlatformDrainRendererQueue();

/*
Run the given function on a background thread. The thread can be pooled,
or spun up fresh. The caller should make no assumptions.
Expand Down
8 changes: 8 additions & 0 deletions ViroRenderer/VRORenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,14 @@ class VRORenderer {

#pragma mark - Camera

/*
Returns true if the render context has been initialized (initRenderer called).
Safe to call before any scene is set.
*/
bool hasRenderContext() const {
return _context != nullptr;
}

/*
Get the camera used in the last frame.
*/
Expand Down
2 changes: 2 additions & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ allprojects {
mavenCentral()
google()
maven { url 'https://jitpack.io' }
// OpenXR loader — downloaded from Khronos GitHub releases (not on Maven Central)
maven { url "${rootProject.projectDir}/openxr_sdk/maven" }
}
}

Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>org.khronos.openxr</groupId>
<artifactId>openxr_loader_for_android</artifactId>
<version>1.1.38</version>
<packaging>aar</packaging>
<name>OpenXR Loader for Android</name>
<description>The AAR for the OpenXR Loader as used on Android.</description>
<url>https://github.com/KhronosGroup/OpenXR-SDK-Source</url>
<licenses>
<license>
<name>Apache-2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
</license>
</licenses>
<developers>
<developer>
<name>The Khronos Group, Inc. OpenXR Working Group</name>
<email>openxr-speceditor AT khronos DOT org</email>
<url>https://khronos.org/openxr</url>
</developer>
</developers>
<scm>
<connection>scm:git:https://github.com/KhronosGroup/OpenXR-SDK-Source.git</connection>
<developerConnection>scm:git:https://github.com/KhronosGroup/OpenXR-SDK-Source.git</developerConnection>
<url>https://github.com/KhronosGroup/OpenXR-SDK-Source</url>
</scm>
<issueManagement>
<system>GitHub Issues</system>
<url>https://github.com/KhronosGroup/OpenXR-SDK-Source/issues</url>
</issueManagement>
</project>
Binary file not shown.
34 changes: 34 additions & 0 deletions android/openxr_sdk/openxr_loader_for_android-1.1.38.pom
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>org.khronos.openxr</groupId>
<artifactId>openxr_loader_for_android</artifactId>
<version>1.1.38</version>
<packaging>aar</packaging>
<name>OpenXR Loader for Android</name>
<description>The AAR for the OpenXR Loader as used on Android.</description>
<url>https://github.com/KhronosGroup/OpenXR-SDK-Source</url>
<licenses>
<license>
<name>Apache-2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
</license>
</licenses>
<developers>
<developer>
<name>The Khronos Group, Inc. OpenXR Working Group</name>
<email>openxr-speceditor AT khronos DOT org</email>
<url>https://khronos.org/openxr</url>
</developer>
</developers>
<scm>
<connection>scm:git:https://github.com/KhronosGroup/OpenXR-SDK-Source.git</connection>
<developerConnection>scm:git:https://github.com/KhronosGroup/OpenXR-SDK-Source.git</developerConnection>
<url>https://github.com/KhronosGroup/OpenXR-SDK-Source</url>
</scm>
<issueManagement>
<system>GitHub Issues</system>
<url>https://github.com/KhronosGroup/OpenXR-SDK-Source/issues</url>
</issueManagement>
</project>
37 changes: 37 additions & 0 deletions android/openxrtest/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 33
namespace "com.viro.openxrtest"

compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

defaultConfig {
applicationId "com.viro.openxrtest"
minSdkVersion 26 // OpenXR requires API 26+
targetSdkVersion 33
versionCode 1
versionName "1.0"

ndk {
abiFilters "arm64-v8a" // Quest is arm64 only
}
}

buildTypes {
debug {
minifyEnabled false
}
release {
minifyEnabled false
}
}
}

dependencies {
implementation project(':viroreact')
implementation "androidx.appcompat:appcompat:1.6.1"
}
36 changes: 36 additions & 0 deletions android/openxrtest/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.VIBRATE" />

<!-- Quest VR requirements -->
<uses-feature android:name="android.hardware.vr.headtracking"
android:required="true" android:version="1" />
<uses-permission android:name="com.oculus.permission.HAND_TRACKING" />

<!-- Optional: hand tracking and eye tracking -->
<uses-feature android:name="oculus.software.handtracking" android:required="false" />

<application
android:label="OpenXR Test"
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"
android:allowBackup="false">

<activity
android:name=".MainActivity"
android:screenOrientation="landscape"
android:configChanges="orientation|screenSize|keyboardHidden"
android:exported="true">

<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<!-- Required for Quest to recognize this as a VR app -->
<category android:name="com.oculus.intent.category.VR" />
</intent-filter>
</activity>

</application>

</manifest>
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file added android/openxrtest/src/main/assets/shiba.glb
Binary file not shown.
Loading
Loading