Merge branch 'android' of git://github.com/birarda/hifi into android

This commit is contained in:
Atlante45 2015-01-30 13:30:17 -08:00
commit 0cc4f5b226
10 changed files with 49 additions and 20 deletions

View file

@ -17,6 +17,8 @@ if (ANDROID)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${ANDROID_APK_OUTPUT_DIR}/libs/${ANDROID_ABI}")
setup_hifi_library(Gui Widgets AndroidExtras)
add_definitions(-DANDROID)
else ()
setup_hifi_project(Gui Widgets)
endif ()
@ -28,19 +30,21 @@ include_glm()
link_hifi_libraries(shared networking audio-client avatars)
include_dependency_includes()
find_package(LibOVR)
if (LIBOVR_FOUND)
add_definitions(-DHAVE_LIBOVR)
target_link_libraries(${TARGET_NAME} ${LIBOVR_LIBRARIES} ${LIBOVR_ANDROID_LIBRARIES})
include_directories(SYSTEM ${LIBOVR_INCLUDE_DIRS})
if (ANDROID)
find_package(LibOVR)
if (LIBOVR_FOUND)
add_definitions(-DHAVE_LIBOVR)
target_link_libraries(${TARGET_NAME} ${LIBOVR_LIBRARIES} ${LIBOVR_ANDROID_LIBRARIES})
include_directories(SYSTEM ${LIBOVR_INCLUDE_DIRS})
if (ANDROID)
# 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(WRITE "${ANDROID_APK_BUILD_DIR}/project.properties" "android.library.reference.1=${RELATIVE_VRLIB_PATH}")
list(APPEND IGNORE_COPY_LIBS ${LIBOVR_ANDROID_LIBRARIES})
endif (ANDROID)
endif ()
endif ()
# the presence of a HOCKEY_APP_ID means we are making a beta build

Binary file not shown.

Before

Width:  |  Height:  |  Size: 88 KiB

After

Width:  |  Height:  |  Size: 9.7 KiB

View file

@ -13,13 +13,13 @@
#include <jni.h>
#include <qpa/qplatformnativeinterface.h>
#include <QtAndroidExtras/QAndroidJniEnvironment>
#include <QtAndroidExtras/QAndroidJniObject>
#endif
#include <QtCore/QTimer>
#include <qpa/qplatformnativeinterface.h>
#include <QtWidgets/QMenuBar>
#ifdef HAVE_LIBOVR
@ -53,13 +53,12 @@ GVRInterface::GVRInterface(int argc, char* argv[]) :
connect(this, &QGuiApplication::applicationStateChanged, this, &GVRInterface::handleApplicationStateChange);
#if defined(Q_WS_ANDROID) && defined(HAVE_LIBOVR)
#if defined(ANDROID) && defined(HAVE_LIBOVR)
QAndroidJniEnvironment jniEnv;
QPlatformNativeInterface* interface = QApplication::platformNativeInterface();
jobject activity = (jobject) interface->nativeResourceForIntegration("QtActivity");
ovr_RegisterHmtReceivers(&*jniEnv, activity);
#endif

View file

@ -30,7 +30,7 @@ class GVRInterface : public QApplication {
Q_OBJECT
public:
GVRInterface(int argc, char* argv[]);
RenderingClient* getClient() { return _client; }
private slots:

View file

@ -14,7 +14,7 @@
#include <QtWidgets/QInputDialog>
#include <QtWidgets/QMenuBar>
#ifndef Q_OS_ANDROID
#ifndef ANDROID
#include <QtWidgets/QDesktopWidget>
#endif
@ -42,13 +42,18 @@ GVRMainWindow::GVRMainWindow(QWidget* parent) :
menuBar()->addMenu(helpMenu);
QAction* goToAddress = new QAction("Go to Address", fileMenu);
QAction* aboutQt = new QAction("About Qt", helpMenu);
fileMenu->addAction(goToAddress);
helpMenu->addAction(aboutQt);
connect(goToAddress, &QAction::triggered, this, &GVRMainWindow::showAddressBar);
fileMenu->addAction(goToAddress);
#ifdef ANDROID
QAction* goFullScreen = new QAction("Enter Full Screen", fileMenu);
connect(goFullScreen, &QAction::triggered, this, &GVRMainWindow::goFullScreen);
fileMenu->addAction(goFullScreen);
#endif
QAction* aboutQt = new QAction("About Qt", helpMenu);
connect(aboutQt, &QAction::triggered, qApp, &QApplication::aboutQt);
helpMenu->addAction(aboutQt);
QWidget* baseWidget = new QWidget(this);
@ -62,7 +67,15 @@ GVRMainWindow::GVRMainWindow(QWidget* parent) :
setCentralWidget(baseWidget);
// add the interface view
InterfaceView* interfaceView = new InterfaceView(baseWidget);
new InterfaceView(baseWidget);
}
void GVRMainWindow::goFullScreen() {
#ifdef ANDROID
menuBar()->hide();
#else
showFullScreen();
#endif
}
void GVRMainWindow::showAddressBar() {

View file

@ -22,6 +22,7 @@ public:
GVRMainWindow(QWidget* parent = 0);
public slots:
void showAddressBar();
void goFullScreen();
private:
QVBoxLayout* _mainLayout;
};

View file

@ -16,7 +16,11 @@ int main(int argc, char* argv[]) {
GVRInterface app(argc, argv);
GVRMainWindow mainWindow;
#ifdef ANDROID
mainWindow.showFullScreen();
#else
mainWindow.showMaximized();
#endif
return app.exec();
}

View file

@ -31,6 +31,8 @@ elseif (WIN32)
add_definitions(-DNSIGHT_FOUND)
target_link_libraries(${TARGET_NAME} "${NSIGHT_LIBRARIES}")
endif ()
elseif (ANDROID)
target_link_libraries(${TARGET_NAME} "-lGLESv3" "-lEGL")
else ()
find_package(OpenGL REQUIRED)

View file

@ -23,6 +23,8 @@
#include <GL/glew.h>
#include <GL/wglew.h>
#elif defined(ANDROID)
#else
#include <GL/gl.h>
#include <GL/glext.h>

View file

@ -57,7 +57,11 @@ const QUrl AddressManager::currentAddress() const {
void AddressManager::loadSettings(const QString& lookupString) {
if (lookupString.isEmpty()) {
handleLookupString(SettingHandles::currentAddress.get().toString());
const QString& lastAddress = SettingHandles::currentAddress.get().toString();
if (lastAddress.isEmpty()) {
handleLookupString(lastAddress);
}
} else {
handleLookupString(lookupString);
}