include ovr mobile sdk and test it

This commit is contained in:
Stephen Birarda 2015-01-26 11:32:24 -08:00
parent 4198d1d5ca
commit c269ee6b94
4 changed files with 78 additions and 12 deletions

View file

@ -6,12 +6,12 @@
<application android:hardwareAccelerated="true" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="@string/AppDisplayName" android:icon="@drawable/icon">
<!-- 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"
android:name="org.qtproject.qt5.android.bindings.QtActivity"
android:label="@string/AppDisplayName"
android:screenOrientation="unspecified"
android:screenOrientation="landscape"
android:launchMode="singleTop"
${ANDROID_APK_THEME}>
<intent-filter>
@ -44,15 +44,15 @@
<!--
<meta-data android:name="android.app.splash_screen_drawable" android:resource="@drawable/logo"/>
-->
<!-- Splash screen -->
</activity>
<!-- <activity android:name="com.oculusvr.vrlib.PlatformActivity"
<activity android:name="com.oculusvr.vrlib.PlatformActivity"
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"
android:launchMode="singleTask"
android:screenOrientation="landscape"
android:configChanges="screenSize|orientation|keyboardHidden|keyboard"> -->
<!-- </activity> -->
android:configChanges="screenSize|orientation|keyboardHidden|keyboard">
</activity>
</application>
<uses-sdk android:minSdkVersion="${ANDROID_API_LEVEL}" android:targetSdkVersion="${ANDROID_API_LEVEL}"/>

View file

@ -19,12 +19,17 @@ set(ANDROID_API_LEVEL 19)
set(ANDROID_APK_PACKAGE io.highfidelity.gvrinterface)
# 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/")
# if (NOT _OCULUS_VRLIB_DIR)
# message(FATAL_ERROR "Could not find Oculus Mobile SDK VRLib.")
# endif()
find_path(_OCULUS_VRLIB_DIR NAME VRLib.vcxproj HINTS "/ovr_mobile_sdk/VRLib/")
if (NOT _OCULUS_VRLIB_DIR)
message(FATAL_ERROR "Could not find Oculus Mobile SDK VRLib.")
endif()
# 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}")
file(RELATIVE_PATH RELATIVE_VRLIB_PATH ${ANDROID_APK_OUTPUT_DIR} "${_OCULUS_VRLIB_DIR}")
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()

View file

@ -11,6 +11,11 @@
#include <QtWidgets/QMenuBar>
#include <OVR.h>
#include <VrApi/VrApi.h>
#include <VrApi/VrApi_local.h>
#include <VrApi/LocalPreferences.h>
#include "GVRMainWindow.h"
#include "RenderingClient.h"
@ -20,4 +25,55 @@ GVRInterface::GVRInterface(int argc, char* argv[]) :
QApplication(argc, argv)
{
_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);
}

View file

@ -28,7 +28,12 @@ public:
RenderingClient* getClient() { return _client; }
private slots:
void handleApplicationStateChange(Qt::ApplicationState state);
private:
void resumeOVR();
void pauseOVR();
RenderingClient* _client;
};