mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 23:09:52 +02:00
include ovr mobile sdk and test it
This commit is contained in:
parent
4198d1d5ca
commit
c269ee6b94
4 changed files with 78 additions and 12 deletions
|
@ -6,12 +6,12 @@
|
||||||
<application android:hardwareAccelerated="true" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="@string/AppDisplayName" android:icon="@drawable/icon">
|
<application android:hardwareAccelerated="true" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="@string/AppDisplayName" android:icon="@drawable/icon">
|
||||||
|
|
||||||
<!-- VR MODE -->
|
<!-- VR MODE -->
|
||||||
<!-- <meta-data android:name="com.samsung.android.vr.application.mode" android:value="vr_dual"/> -->
|
<meta-data android:name="com.samsung.android.vr.application.mode" android:value="vr_dual"/>
|
||||||
|
|
||||||
<activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|locale|fontScale|keyboard|keyboardHidden|navigation"
|
<activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|locale|fontScale|keyboard|keyboardHidden|navigation"
|
||||||
android:name="org.qtproject.qt5.android.bindings.QtActivity"
|
android:name="org.qtproject.qt5.android.bindings.QtActivity"
|
||||||
android:label="@string/AppDisplayName"
|
android:label="@string/AppDisplayName"
|
||||||
android:screenOrientation="unspecified"
|
android:screenOrientation="landscape"
|
||||||
android:launchMode="singleTop"
|
android:launchMode="singleTop"
|
||||||
${ANDROID_APK_THEME}>
|
${ANDROID_APK_THEME}>
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
|
@ -44,15 +44,15 @@
|
||||||
<!--
|
<!--
|
||||||
<meta-data android:name="android.app.splash_screen_drawable" android:resource="@drawable/logo"/>
|
<meta-data android:name="android.app.splash_screen_drawable" android:resource="@drawable/logo"/>
|
||||||
-->
|
-->
|
||||||
<!-- Splash screen -->
|
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<!-- <activity android:name="com.oculusvr.vrlib.PlatformActivity"
|
<activity android:name="com.oculusvr.vrlib.PlatformActivity"
|
||||||
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"
|
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"
|
||||||
android:launchMode="singleTask"
|
android:launchMode="singleTask"
|
||||||
android:screenOrientation="landscape"
|
android:screenOrientation="landscape"
|
||||||
android:configChanges="screenSize|orientation|keyboardHidden|keyboard"> -->
|
android:configChanges="screenSize|orientation|keyboardHidden|keyboard">
|
||||||
<!-- </activity> -->
|
</activity>
|
||||||
|
|
||||||
</application>
|
</application>
|
||||||
<uses-sdk android:minSdkVersion="${ANDROID_API_LEVEL}" android:targetSdkVersion="${ANDROID_API_LEVEL}"/>
|
<uses-sdk android:minSdkVersion="${ANDROID_API_LEVEL}" android:targetSdkVersion="${ANDROID_API_LEVEL}"/>
|
||||||
|
|
|
@ -19,12 +19,17 @@ set(ANDROID_API_LEVEL 19)
|
||||||
set(ANDROID_APK_PACKAGE io.highfidelity.gvrinterface)
|
set(ANDROID_APK_PACKAGE io.highfidelity.gvrinterface)
|
||||||
|
|
||||||
# we need VRLib, so add a project.properties to our apk build folder that says that
|
# we need VRLib, so add a project.properties to our apk build folder that says that
|
||||||
# find_path(_OCULUS_VRLIB_DIR NAME VRLib.vcxproj HINTS "/ovr_mobile_sdk/VRLib/")
|
find_path(_OCULUS_VRLIB_DIR NAME VRLib.vcxproj HINTS "/ovr_mobile_sdk/VRLib/")
|
||||||
# if (NOT _OCULUS_VRLIB_DIR)
|
if (NOT _OCULUS_VRLIB_DIR)
|
||||||
# message(FATAL_ERROR "Could not find Oculus Mobile SDK VRLib.")
|
message(FATAL_ERROR "Could not find Oculus Mobile SDK VRLib.")
|
||||||
# endif()
|
endif()
|
||||||
|
|
||||||
# file(RELATIVE_PATH RELATIVE_VRLIB_PATH ${ANDROID_APK_OUTPUT_DIR} "${_OCULUS_VRLIB_DIR}")
|
file(RELATIVE_PATH RELATIVE_VRLIB_PATH ${ANDROID_APK_OUTPUT_DIR} "${_OCULUS_VRLIB_DIR}")
|
||||||
# file(WRITE "${ANDROID_APK_BUILD_DIR}/project.properties" "android.library.reference.1=${RELATIVE_VRLIB_PATH}")
|
|
||||||
|
include_directories(SYSTEM "${_OCULUS_VRLIB_DIR}/jni")
|
||||||
|
include_directories(SYSTEM "${_OCULUS_VRLIB_DIR}/jni/LibOVR/Include")
|
||||||
|
include_directories(SYSTEM "${_OCULUS_VRLIB_DIR}/jni/LibOVR/Src")
|
||||||
|
|
||||||
|
file(WRITE "${ANDROID_APK_BUILD_DIR}/project.properties" "android.library.reference.1=${RELATIVE_VRLIB_PATH}")
|
||||||
|
|
||||||
qt_create_apk()
|
qt_create_apk()
|
|
@ -11,6 +11,11 @@
|
||||||
|
|
||||||
#include <QtWidgets/QMenuBar>
|
#include <QtWidgets/QMenuBar>
|
||||||
|
|
||||||
|
#include <OVR.h>
|
||||||
|
#include <VrApi/VrApi.h>
|
||||||
|
#include <VrApi/VrApi_local.h>
|
||||||
|
#include <VrApi/LocalPreferences.h>
|
||||||
|
|
||||||
#include "GVRMainWindow.h"
|
#include "GVRMainWindow.h"
|
||||||
#include "RenderingClient.h"
|
#include "RenderingClient.h"
|
||||||
|
|
||||||
|
@ -20,4 +25,55 @@ GVRInterface::GVRInterface(int argc, char* argv[]) :
|
||||||
QApplication(argc, argv)
|
QApplication(argc, argv)
|
||||||
{
|
{
|
||||||
_client = new RenderingClient(this);
|
_client = new RenderingClient(this);
|
||||||
|
|
||||||
|
connect(this, &QGuiApplication::applicationStateChanged, this, &GVRInterface::handleApplicationStateChange);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GVRInterface::handleApplicationStateChange(Qt::ApplicationState state) {
|
||||||
|
switch(state) {
|
||||||
|
case Qt::ApplicationActive:
|
||||||
|
qDebug() << "The application is active.";
|
||||||
|
resumeOVR();
|
||||||
|
break;
|
||||||
|
case Qt::ApplicationSuspended:
|
||||||
|
qDebug() << "The application is being suspended.";
|
||||||
|
pauseOVR();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GVRInterface::resumeOVR() {
|
||||||
|
// Reload local preferences, in case we are coming back from a
|
||||||
|
// switch to the dashboard that changed them.
|
||||||
|
ovr_UpdateLocalPreferences();
|
||||||
|
|
||||||
|
// Default vrModeParms
|
||||||
|
ovrModeParms vrModeParms;
|
||||||
|
ovrHmdInfo hmdInfo;
|
||||||
|
|
||||||
|
vrModeParms.AsynchronousTimeWarp = true;
|
||||||
|
vrModeParms.AllowPowerSave = true;
|
||||||
|
vrModeParms.DistortionFileName = NULL;
|
||||||
|
vrModeParms.EnableImageServer = false;
|
||||||
|
vrModeParms.CpuLevel = 2;
|
||||||
|
vrModeParms.GpuLevel = 2;
|
||||||
|
vrModeParms.GameThreadTid = 0;
|
||||||
|
|
||||||
|
const char* cpuLevelStr = ovr_GetLocalPreferenceValueForKey( LOCAL_PREF_DEV_CPU_LEVEL, "-1" );
|
||||||
|
const int cpuLevel = atoi( cpuLevelStr );
|
||||||
|
if ( cpuLevel >= 0 ) {
|
||||||
|
vrModeParms.CpuLevel = cpuLevel;
|
||||||
|
qDebug() << "Local Preferences: Setting cpuLevel" << vrModeParms.CpuLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* gpuLevelStr = ovr_GetLocalPreferenceValueForKey( LOCAL_PREF_DEV_GPU_LEVEL, "-1" );
|
||||||
|
const int gpuLevel = atoi( gpuLevelStr );
|
||||||
|
if ( gpuLevel >= 0 ) {
|
||||||
|
vrModeParms.GpuLevel = gpuLevel;
|
||||||
|
qDebug() << "Local Preferences: Setting gpuLevel" << vrModeParms.GpuLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
ovr_EnterVrMode(vrModeParms, &hmdInfo);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,12 @@ public:
|
||||||
|
|
||||||
RenderingClient* getClient() { return _client; }
|
RenderingClient* getClient() { return _client; }
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void handleApplicationStateChange(Qt::ApplicationState state);
|
||||||
private:
|
private:
|
||||||
|
void resumeOVR();
|
||||||
|
void pauseOVR();
|
||||||
|
|
||||||
RenderingClient* _client;
|
RenderingClient* _client;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue