简体中文 English

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 301|回复: 0

[SDK] 怎么编译OpenXR的HelloXR例子

[复制链接]

[SDK] 怎么编译OpenXR的HelloXR例子

[复制链接]
DavidChen

主题

0

回帖

415

积分

版主

积分
415
2023-10-18 09:30:55 | 显示全部楼层 |阅读模式
本帖最后由 DavidChen 于 2024-5-31 09:40 编辑

首先下载HelloXR的官方代码:

git@github.com:KhronosGroup/OpenXR-SDK-Source.git


可以通过git clone git@github.com:KhronosGroup/OpenXR-SDK-Source.git下载代码(我们的runtime是基于1.0.30这个版本编译的)

helloxr的app代码在路径:OpenXR-SDK-Source/src/tests/hello_xr


因为我们已经适配了Openxr,所以只需要做一个分体式开启应用的适配即可,修改AndroidManifest.xml即可:
1、在application标签下添加
  1. <meta-data
  2.             android:name="yyss.xrapplication"
  3.             android:value="app" />
复制代码
2、将acitivity标签中的android:resizeableActivity设置成true
3、删除 tools:ignore="NonResizeableActivity"


整体AndroidManifest.xml如下:
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <manifest xmlns:android="http://schemas.android.com/apk/res/android"
  3.     xmlns:tools="http://schemas.android.com/tools"
  4.     android:installLocation="auto"
  5.     android:versionCode="1"
  6.     android:versionName="1.0">
  7.     <!--
  8.     Copyright (c) 2017-2023, The Khronos Group Inc.

  9.     SPDX-License-Identifier: Apache-2.0
  10.     -->
  11.     <!-- Tell the system this app requires OpenGL ES 3.2. -->
  12.     <uses-feature
  13.         android:glEsVersion="0x00030002"
  14.         android:required="true" />
  15.     <!-- Tell the system this app works in either 3dof or 6dof mode -->
  16.     <uses-feature
  17.         android:name="android.hardware.vr.headtracking"
  18.         android:required="false"
  19.         android:version="1" />

  20.     <!-- Recommended for haptic feedback -->
  21.     <uses-permission android:name="android.permission.VIBRATE" />

  22.     <!-- If building externally with the OpenXR loader AAR, this would be merged in automatically. -->
  23.     <uses-permission android:name="org.khronos.openxr.permission.OPENXR" />
  24.     <uses-permission android:name="org.khronos.openxr.permission.OPENXR_SYSTEM" />

  25.     <queries>
  26.         <!-- to talk to the broker -->
  27.         <provider android:authorities="org.khronos.openxr.runtime_broker;org.khronos.openxr.system_runtime_broker" />

  28.         <!-- so client-side code of runtime/layers can talk to their service sides -->
  29.         <intent>
  30.             <action android:name="org.khronos.openxr.OpenXRRuntimeService" />
  31.         </intent>
  32.         <intent>
  33.             <action android:name="org.khronos.openxr.OpenXRApiLayerService" />
  34.         </intent>
  35.     </queries>
  36.     <!-- end of elements normally merged from the OpenXR loader AAR -->

  37.     <application
  38.         android:allowBackup="true"
  39.         android:hasCode="false"
  40.         android:icon="@mipmap/ic_helloxr_launcher"
  41.         android:label="@string/app_name"
  42.         android:roundIcon="@mipmap/ic_helloxr_launcher">

  43.         <meta-data
  44.             android:name="yyss.xrapplication"
  45.             android:value="app" />

  46.         <!-- The activity is the built-in NativeActivity framework class. -->
  47.         <!-- launchMode is set to singleTask because there should never be multiple copies of the app running. -->
  48.         <!-- Theme.Black.NoTitleBar.Fullscreen gives solid black instead of a (bad stereoscopic) gradient on app transition. -->
  49.         <activity
  50.             android:name="android.app.NativeActivity"
  51.             android:configChanges="screenSize|screenLayout|orientation|keyboardHidden|keyboard|navigation|uiMode|density"
  52.             android:excludeFromRecents="false"
  53.             android:exported="true"
  54.             android:launchMode="singleTask"
  55.             android:resizeableActivity="true"
  56.             android:screenOrientation="landscape"
  57.             android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen">
  58.             <!-- Tell NativeActivity the name of the .so -->
  59.             <meta-data
  60.                 android:name="android.app.lib_name"
  61.                 android:value="hello_xr" />
  62.             <!-- This filter lets the apk show up as a launchable icon. -->
  63.             <intent-filter>
  64.                 <action android:name="android.intent.action.MAIN" />

  65.                 <category android:name="android.intent.category.LAUNCHER" />
  66.                 <category android:name="org.khronos.openxr.intent.category.IMMERSIVE_HMD" />
  67.             </intent-filter>
  68.         </activity>
  69.     </application>
  70. </manifest>
复制代码


另外,将OpenXR的runtime apk安装到机器就可以运行了
runtime apk (提取码:2vwj)



您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|小黑屋|耀宇视芯论坛 | 苏ICP备2023041931号|苏公网安备32010502010808

GMT+8, 2024-9-20 05:34 , Processed in 0.052622 second(s), 16 queries .

快速回复