mirror of
https://github.com/lubosz/overte.git
synced 2025-08-08 03:48:38 +02:00
don't explicitly require LibOVR for android build
This commit is contained in:
parent
067ffad122
commit
f1c6d26ed1
5 changed files with 35 additions and 12 deletions
|
@ -7,10 +7,13 @@ You will need the following tools to build our Android targets.
|
||||||
* [Android NDK](https://developer.android.com/tools/sdk/ndk/index.html) = r10c
|
* [Android NDK](https://developer.android.com/tools/sdk/ndk/index.html) = r10c
|
||||||
* [Android SDK](http://developer.android.com/sdk/installing/index.html) ~> 24.0.2
|
* [Android SDK](http://developer.android.com/sdk/installing/index.html) ~> 24.0.2
|
||||||
* Be sure to install SDK Platform for API Level 19
|
* Be sure to install SDK Platform for API Level 19
|
||||||
* [Oculus Mobile SDK](https://developer.oculus.com/downloads/#sdk=mobile) ~> 0.4.2
|
|
||||||
|
|
||||||
You will also need to cross-compile the dependencies required for all platforms for Android, and help CMake find these compiled libraries on your machine.
|
You will also need to cross-compile the dependencies required for all platforms for Android, and help CMake find these compiled libraries on your machine.
|
||||||
|
|
||||||
|
####Optional Components
|
||||||
|
|
||||||
|
* [Oculus Mobile SDK](https://developer.oculus.com/downloads/#sdk=mobile) ~> 0.4.2
|
||||||
|
|
||||||
####ANDROID_LIB_DIR
|
####ANDROID_LIB_DIR
|
||||||
|
|
||||||
Since you won't be installing Android dependencies to system paths on your development machine, CMake will need a little help tracking down your Android dependencies.
|
Since you won't be installing Android dependencies to system paths on your development machine, CMake will need a little help tracking down your Android dependencies.
|
||||||
|
@ -97,6 +100,8 @@ This will create the `lib` and `include` folders inside `ANDROID_LIB_DIR/soxr` t
|
||||||
|
|
||||||
####Oculus Mobile SDK
|
####Oculus Mobile SDK
|
||||||
|
|
||||||
|
The Oculus Mobile SDK is optional, for Gear VR support. It is not required to compile gvr-interface.
|
||||||
|
|
||||||
Download the [Oculus Mobile SDK](https://developer.oculus.com/downloads/#sdk=mobile) and extract the archive inside your `ANDROID_LIB_DIR` folder. Rename the extracted folder to `libovr`.
|
Download the [Oculus Mobile SDK](https://developer.oculus.com/downloads/#sdk=mobile) and extract the archive inside your `ANDROID_LIB_DIR` folder. Rename the extracted folder to `libovr`.
|
||||||
|
|
||||||
From the VrLib directory, use ndk-build to build VrLib. This will create the liboculus.a archive that our FindLibOVR module will look for when cmake is run.
|
From the VrLib directory, use ndk-build to build VrLib. This will create the liboculus.a archive that our FindLibOVR module will look for when cmake is run.
|
||||||
|
|
|
@ -24,15 +24,18 @@ set(ANDROID_APK_VERSION_NAME "0.1")
|
||||||
set(ANDROID_APK_VERSION_CODE 1)
|
set(ANDROID_APK_VERSION_CODE 1)
|
||||||
set(ANDROID_DEPLOY_QT_INSTALL "--install")
|
set(ANDROID_DEPLOY_QT_INSTALL "--install")
|
||||||
|
|
||||||
find_package(LibOVR REQUIRED)
|
find_package(LibOVR)
|
||||||
target_link_libraries(${TARGET_NAME} ${LIBOVR_LIBRARIES} ${LIBOVR_ANDROID_LIBRARIES})
|
if (LIBOVR_FOUND)
|
||||||
include_directories(SYSTEM ${LIBOVR_INCLUDE_DIRS})
|
add_definitions(-DHAVE_LIBOVR)
|
||||||
|
target_link_libraries(${TARGET_NAME} ${LIBOVR_LIBRARIES} ${LIBOVR_ANDROID_LIBRARIES})
|
||||||
|
include_directories(SYSTEM ${LIBOVR_INCLUDE_DIRS})
|
||||||
|
|
||||||
# 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
|
||||||
file(RELATIVE_PATH RELATIVE_VRLIB_PATH ${ANDROID_APK_OUTPUT_DIR} "${LIBOVR_VRLIB_DIR}")
|
file(RELATIVE_PATH RELATIVE_VRLIB_PATH ${ANDROID_APK_OUTPUT_DIR} "${LIBOVR_VRLIB_DIR}")
|
||||||
file(WRITE "${ANDROID_APK_BUILD_DIR}/project.properties" "android.library.reference.1=${RELATIVE_VRLIB_PATH}")
|
file(WRITE "${ANDROID_APK_BUILD_DIR}/project.properties" "android.library.reference.1=${RELATIVE_VRLIB_PATH}")
|
||||||
|
|
||||||
list(APPEND IGNORE_COPY_LIBS ${LIBOVR_ANDROID_LIBRARIES})
|
list(APPEND IGNORE_COPY_LIBS ${LIBOVR_ANDROID_LIBRARIES})
|
||||||
|
endif ()
|
||||||
|
|
||||||
# the presence of a HOCKEY_APP_ID means we are making a beta build
|
# the presence of a HOCKEY_APP_ID means we are making a beta build
|
||||||
if (HOCKEY_APP_ID)
|
if (HOCKEY_APP_ID)
|
||||||
|
|
|
@ -15,11 +15,15 @@
|
||||||
#include <qpa/qplatformnativeinterface.h>
|
#include <qpa/qplatformnativeinterface.h>
|
||||||
#include <QtWidgets/QMenuBar>
|
#include <QtWidgets/QMenuBar>
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBOVR
|
||||||
|
|
||||||
#include <GlUtils.h>
|
#include <GlUtils.h>
|
||||||
#include <VrApi/LocalPreferences.h>
|
#include <VrApi/LocalPreferences.h>
|
||||||
#include <VrApi/VrApi.h>
|
#include <VrApi/VrApi.h>
|
||||||
#include <VrApi/VrApi_local.h>
|
#include <VrApi/VrApi_local.h>
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "GVRMainWindow.h"
|
#include "GVRMainWindow.h"
|
||||||
#include "RenderingClient.h"
|
#include "RenderingClient.h"
|
||||||
|
|
||||||
|
@ -32,13 +36,16 @@ GVRInterface::GVRInterface(int argc, char* argv[]) :
|
||||||
_client = new RenderingClient(this);
|
_client = new RenderingClient(this);
|
||||||
|
|
||||||
connect(this, &QGuiApplication::applicationStateChanged, this, &GVRInterface::handleApplicationStateChange);
|
connect(this, &QGuiApplication::applicationStateChanged, this, &GVRInterface::handleApplicationStateChange);
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBOVR
|
||||||
QAndroidJniEnvironment jniEnv;
|
QAndroidJniEnvironment jniEnv;
|
||||||
|
|
||||||
QPlatformNativeInterface* interface = QApplication::platformNativeInterface();
|
QPlatformNativeInterface* interface = QApplication::platformNativeInterface();
|
||||||
jobject activity = (jobject) interface->nativeResourceForIntegration("QtActivity");
|
jobject activity = (jobject) interface->nativeResourceForIntegration("QtActivity");
|
||||||
|
|
||||||
|
|
||||||
ovr_RegisterHmtReceivers(&*jniEnv, activity);
|
ovr_RegisterHmtReceivers(&*jniEnv, activity);
|
||||||
|
#endif
|
||||||
|
|
||||||
// call our idle function whenever we can
|
// call our idle function whenever we can
|
||||||
QTimer* idleTimer = new QTimer(this);
|
QTimer* idleTimer = new QTimer(this);
|
||||||
|
@ -60,10 +67,12 @@ GVRInterface::GVRInterface(int argc, char* argv[]) :
|
||||||
}
|
}
|
||||||
|
|
||||||
void GVRInterface::idle() {
|
void GVRInterface::idle() {
|
||||||
|
#ifdef HAVE_LIBOVR
|
||||||
if (!_inVRMode && ovr_IsHeadsetDocked()) {
|
if (!_inVRMode && ovr_IsHeadsetDocked()) {
|
||||||
qDebug() << "The headset just got docked - assume we are in VR mode.";
|
qDebug() << "The headset just got docked - assume we are in VR mode.";
|
||||||
_inVRMode = true;
|
_inVRMode = true;
|
||||||
} else if (_inVRMode) {
|
} else if (_inVRMode) {
|
||||||
|
|
||||||
if (ovr_IsHeadsetDocked()) {
|
if (ovr_IsHeadsetDocked()) {
|
||||||
static int counter = 0;
|
static int counter = 0;
|
||||||
|
|
||||||
|
@ -90,6 +99,7 @@ void GVRInterface::idle() {
|
||||||
_inVRMode = false;
|
_inVRMode = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void GVRInterface::handleApplicationStateChange(Qt::ApplicationState state) {
|
void GVRInterface::handleApplicationStateChange(Qt::ApplicationState state) {
|
||||||
|
|
|
@ -15,8 +15,11 @@
|
||||||
#include <QtWidgets/QApplication>
|
#include <QtWidgets/QApplication>
|
||||||
|
|
||||||
class RenderingClient;
|
class RenderingClient;
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBOVR
|
||||||
class ovrMobile;
|
class ovrMobile;
|
||||||
class ovrHmdInfo;
|
class ovrHmdInfo;
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(qApp)
|
#if defined(qApp)
|
||||||
#undef qApp
|
#undef qApp
|
||||||
|
@ -37,8 +40,10 @@ private:
|
||||||
RenderingClient* _client;
|
RenderingClient* _client;
|
||||||
bool _inVRMode;
|
bool _inVRMode;
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBOVR
|
||||||
ovrMobile* _ovr;
|
ovrMobile* _ovr;
|
||||||
ovrHmdInfo* _hmdInfo;
|
ovrHmdInfo* _hmdInfo;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_GVRInterface_h
|
#endif // hifi_GVRInterface_h
|
||||||
|
|
|
@ -328,7 +328,7 @@ bool sampleChannelConversion(const int16_t* sourceSamples, int16_t* destinationS
|
||||||
const QAudioFormat& sourceAudioFormat, const QAudioFormat& destinationAudioFormat) {
|
const QAudioFormat& sourceAudioFormat, const QAudioFormat& destinationAudioFormat) {
|
||||||
if (sourceAudioFormat.channelCount() == 2 && destinationAudioFormat.channelCount() == 1) {
|
if (sourceAudioFormat.channelCount() == 2 && destinationAudioFormat.channelCount() == 1) {
|
||||||
// loop through the stereo input audio samples and average every two samples
|
// loop through the stereo input audio samples and average every two samples
|
||||||
for (int i = 0; i < numSourceSamples; i += 2) {
|
for (uint i = 0; i < numSourceSamples; i += 2) {
|
||||||
destinationSamples[i / 2] = (sourceSamples[i] / 2) + (sourceSamples[i + 1] / 2);
|
destinationSamples[i / 2] = (sourceSamples[i] / 2) + (sourceSamples[i + 1] / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -336,7 +336,7 @@ bool sampleChannelConversion(const int16_t* sourceSamples, int16_t* destinationS
|
||||||
} else if (sourceAudioFormat.channelCount() == 1 && destinationAudioFormat.channelCount() == 2) {
|
} else if (sourceAudioFormat.channelCount() == 1 && destinationAudioFormat.channelCount() == 2) {
|
||||||
|
|
||||||
// loop through the mono input audio and repeat each sample twice
|
// loop through the mono input audio and repeat each sample twice
|
||||||
for (int i = 0; i < numSourceSamples; ++i) {
|
for (uint i = 0; i < numSourceSamples; ++i) {
|
||||||
destinationSamples[i * 2] = destinationSamples[(i * 2) + 1] = sourceSamples[i];
|
destinationSamples[i * 2] = destinationSamples[(i * 2) + 1] = sourceSamples[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue