Working on merging in master

This commit is contained in:
Brad Davis 2015-04-30 22:01:03 -07:00
parent 031b294ae5
commit ba4ae3762d
14 changed files with 111 additions and 119 deletions

View file

@ -176,6 +176,7 @@ option(GET_GVERB "Get Gverb library automatically as external project" 1)
option(GET_SOXR "Get Soxr library automatically as external project" 1)
option(GET_TBB "Get Threading Building Blocks library automatically as external project" 1)
option(GET_LIBOVR "Get LibOVR library automatically as external project" 1)
option(GET_OPENVR "Get OpenVR library automatically as external project" 1)
option(USE_NSIGHT "Attempt to find the nSight libraries" 1)
option(GET_VHACD "Get V-HACD library automatically as external project" 1)

38
cmake/externals/openvr/CMakeLists.txt vendored Normal file
View file

@ -0,0 +1,38 @@
include(ExternalProject)
include(SelectLibraryConfigurations)
set(EXTERNAL_NAME OpenVR)
string(TOUPPER ${EXTERNAL_NAME} EXTERNAL_NAME_UPPER)
ExternalProject_Add(
${EXTERNAL_NAME}
URL https://github.com/ValveSoftware/openvr/archive/0.9.0.zip
URL_MD5 4fbde7759f604aaa68b9c40d628cc34a
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
LOG_DOWNLOAD 1
)
ExternalProject_Get_Property(${EXTERNAL_NAME} SOURCE_DIR)
set(${EXTERNAL_NAME_UPPER}_INCLUDE_DIRS ${SOURCE_DIR}/openvr-0.9.0/headers CACHE TYPE INTERNAL)
if (WIN32)
# FIXME need to account for different architectures
set(${EXTERNAL_NAME_UPPER}_LIBRARIES ${SOURCE_DIR}/openvr-0.9.0/lib/win32/openvr_api.lib CACHE TYPE INTERNAL)
elseif(APPLE)
# FIXME need to account for different architectures
set(${EXTERNAL_NAME_UPPER}_LIBRARIES ${SOURCE_DIR}/openvr-0.9.0/lib/osx32/libopenvr_api.dylib CACHE TYPE INTERNAL)
elseif(NOT ANDROID)
# FIXME need to account for different architectures
set(${EXTERNAL_NAME_UPPER}_LIBRARIES ${SOURCE_DIR}/openvr-0.9.0/lib/linux32/libopenvr_api.so CACHE TYPE INTERNAL)
endif()

View file

@ -0,0 +1,24 @@
#
# FindLibOVR.cmake
#
# Try to find the LibOVR library to use the Oculus
# Once done this will define
#
# OPENVR_FOUND - system found LibOVR
# OPENVR_INCLUDE_DIRS - the LibOVR include directory
# OPENVR_LIBRARIES - Link this to use LibOVR
#
# Distributed under the Apache License, Version 2.0.
# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
#
if (NOT ANDROID)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(OPENVR DEFAULT_MSG OPENVR_INCLUDE_DIRS OPENVR_LIBRARIES)
endif (NOT ANDROID)
mark_as_advanced(OPENVR_INCLUDE_DIRS OPENVR_LIBRARIES OPENVR_SEARCH_DIRS)

View file

@ -136,6 +136,11 @@ find_package(LibOVR REQUIRED)
target_include_directories(${TARGET_NAME} PRIVATE ${LIBOVR_INCLUDE_DIRS})
target_link_libraries(${TARGET_NAME} ${LIBOVR_LIBRARIES})
add_dependency_external_projects(OpenVR)
find_package(OpenVR REQUIRED)
target_include_directories(${TARGET_NAME} PRIVATE ${LIBOVR_INCLUDE_DIRS})
target_link_libraries(${TARGET_NAME} ${LIBOVR_LIBRARIES})
find_package(Bullet REQUIRED)
target_include_directories(${TARGET_NAME} SYSTEM PRIVATE ${BULLET_INCLUDE_DIRS})
target_link_libraries(${TARGET_NAME} ${BULLET_LIBRARIES})

View file

@ -114,6 +114,8 @@
#include "gpu/Batch.h"
#include "gpu/GLBackend.h"
#include "plugins/render/RenderPlugin.h"
#include "scripting/AccountScriptingInterface.h"
#include "scripting/AudioDeviceScriptingInterface.h"
#include "scripting/ClipboardScriptingInterface.h"
@ -584,7 +586,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
this->installEventFilter(this);
// The offscreen UI needs to intercept the mouse and keyboard
// events coming from the onscreen window
_glWidget->installEventFilter(DependencyManager::get<OffscreenUi>().data());
//_glWidget->installEventFilter(DependencyManager::get<OffscreenUi>().data());
}
@ -726,7 +728,7 @@ void Application::initializeGL() {
// texture resources
initializeUi();
qCDebug(interfaceapp, "Initialized Offscreen UI.");
_glWidget->makeCurrent();
_offscreenContext->makeCurrent();
// call Menu getInstance static method to set up the menu
// Needs to happen AFTER the QML UI initialization
@ -770,30 +772,24 @@ void Application::initializeUi() {
VrMenu::registerType();
auto offscreenUi = DependencyManager::get<OffscreenUi>();
offscreenUi->create(_glWidget->context()->contextHandle());
offscreenUi->resize(_glWidget->size());
offscreenUi->create(_offscreenContext->getContext());
offscreenUi->resize(fromGlm(getActiveRenderPlugin()->getCanvasSize()));
offscreenUi->setProxyWindow(_window->windowHandle());
offscreenUi->setBaseUrl(QUrl::fromLocalFile(PathUtils::resourcesPath() + "/qml/"));
offscreenUi->load("Root.qml");
offscreenUi->load("RootMenu.qml");
VrMenu::load();
VrMenu::executeQueuedLambdas();
offscreenUi->setMouseTranslator([this](const QPointF& p){
if (OculusManager::isConnected()) {
glm::vec2 pos = _applicationOverlay.screenToOverlay(toGlm(p));
return QPointF(pos.x, pos.y);
}
return QPointF(p);
});
offscreenUi->setMouseTranslator(getActiveRenderPlugin()->getMouseTranslator());
offscreenUi->resume();
connect(_window, &MainWindow::windowGeometryChanged, [this](const QRect & r){
static qreal oldDevicePixelRatio = 0;
qreal devicePixelRatio = _glWidget->devicePixelRatio();
qreal devicePixelRatio = getActiveRenderPlugin()->devicePixelRatio();
if (devicePixelRatio != oldDevicePixelRatio) {
oldDevicePixelRatio = devicePixelRatio;
qDebug() << "Device pixel ratio changed, triggering GL resize";
resizeGL(_glWidget->width(),
_glWidget->height());
auto canvasSize = getActiveRenderPlugin()->getCanvasSize();
resizeGL(canvasSize.x, canvasSize.y);
}
});
}
@ -846,8 +842,9 @@ void Application::paintGL() {
DependencyManager::get<GlowEffect>()->prepare();
// Primary rendering pass
auto primaryFbo = DependencyManager::get<TextureCache>()->getPrimaryFramebufferObject();
primaryFbo->bind();
auto primaryFbo = DependencyManager::get<TextureCache>()->getPrimaryFramebuffer();
auto finalFbo = primaryFbo;
glBindFramebuffer(GL_FRAMEBUFFER, gpu::GLBackend::getFramebufferID(primaryFbo));
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
@ -864,32 +861,18 @@ void Application::paintGL() {
if (Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) {
_rearMirrorTools->render(true);
} else if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) {
<<<<<<< HEAD
renderRearViewMirror(_mirrorViewRect);
=======
renderRearViewMirror(_mirrorViewRect);
}
DependencyManager::get<GlowEffect>()->render();
finalFbo = DependencyManager::get<GlowEffect>()->render();
{
PerformanceTimer perfTimer("renderOverlay");
_applicationOverlay.renderOverlay();
glBindFramebuffer(GL_FRAMEBUFFER, gpu::GLBackend::getFramebufferID(finalFbo));
_applicationOverlay.displayOverlayTexture();
>>>>>>> master
glBindFramebuffer(GL_FRAMEBUFFER, 0);
}
}
primaryFbo->release();
QOpenGLFramebufferObject * finalFbo = DependencyManager::get<GlowEffect>()->render();
finalFbo->bind();
{
PerformanceTimer perfTimer("renderOverlay");
_applicationOverlay.renderOverlay();
_applicationOverlay.displayOverlayTexture();
}
finalFbo->release();
// This might not be needed *right now*. We want to ensure that the FBO rendering
// has completed before we start trying to read from it in another context. However
@ -899,7 +882,7 @@ void Application::paintGL() {
_offscreenContext->doneCurrent();
Q_ASSERT(!QOpenGLContext::currentContext());
getActiveRenderPlugin()->render(finalFbo->texture());
getActiveRenderPlugin()->render(gpu::GLBackend::getTextureID(finalFbo->getRenderBuffer(0)));
Q_ASSERT(!QOpenGLContext::currentContext());
_offscreenContext->makeCurrent();
_frameCount++;
@ -951,8 +934,9 @@ void Application::resizeGL(int width, int height) {
updateProjectionMatrix();
glLoadIdentity();
auto canvasSize = getActiveRenderPlugin()->getCanvasSize();
auto offscreenUi = DependencyManager::get<OffscreenUi>();
offscreenUi->resize(_glWidget->size());
offscreenUi->resize(fromGlm(canvasSize));
// update Stats width
// let's set horizontal offset to give stats some margin to mirror
@ -1003,43 +987,6 @@ bool Application::importSVOFromURL(const QString& urlString) {
bool Application::event(QEvent* event) {
switch (event->type()) {
<<<<<<< HEAD
case QEvent::MouseMove:
mouseMoveEvent((QMouseEvent*)event);
return true;
case QEvent::MouseButtonPress:
mousePressEvent((QMouseEvent*)event);
return true;
case QEvent::MouseButtonRelease:
mouseReleaseEvent((QMouseEvent*)event);
return true;
case QEvent::KeyPress:
keyPressEvent((QKeyEvent*)event);
return true;
case QEvent::KeyRelease:
keyReleaseEvent((QKeyEvent*)event);
return true;
case QEvent::FocusIn:
//focusInEvent((QFocusEvent*)event);
//return true;
break;
case QEvent::FocusOut:
focusOutEvent((QFocusEvent*)event);
return true;
case QEvent::Resize:
resizeEvent((QResizeEvent *)event);
return true;
default:
break;
=======
case Lambda:
((LambdaEvent*)event)->call();
return true;
@ -1080,7 +1027,6 @@ bool Application::event(QEvent* event) {
return true;
default:
break;
>>>>>>> master
}
// handle custom URL
@ -2990,13 +2936,7 @@ void Application::updateShadowMap() {
glMatrixMode(GL_MODELVIEW);
}
<<<<<<< HEAD
fbo->release();
=======
// fbo->release();
glViewport(0, 0, _glWidget->getDeviceWidth(), _glWidget->getDeviceHeight());
>>>>>>> master
// glViewport(0, 0, _glWidget->getDeviceWidth(), _glWidget->getDeviceHeight());
activeRenderingThread = nullptr;
}

View file

@ -74,9 +74,8 @@
#include "octree/OctreeFade.h"
#include "octree/OctreePacketProcessor.h"
#include "UndoStackScriptingInterface.h"
#include "plugins/render/RenderPlugin.h"
class RenderPlugin;
class QGLWidget;
class QKeyEvent;
class QMouseEvent;

View file

@ -115,7 +115,10 @@ int main(int argc, const char* argv[]) {
exitCode = app.exec();
}
#if 0
OculusManager::deinit();
#endif
#ifdef Q_OS_WIN
ReleaseMutex(mutex);
#endif

View file

@ -13,6 +13,8 @@
#include <QSize>
#include <functional>
#include <glm/glm.hpp>
#include <glm/gtc/quaternion.hpp>
#include <RegisteredMetaTypes.h>
@ -46,6 +48,8 @@ public:
return trueMouseToUiMouse(getTrueMousePosition());
}
virtual std::function<QPointF(QPointF)> getMouseTranslator() { return [](const QPointF& p) { return p; }; };
// Convert from screen mouse coordinates to UI mouse coordinates
virtual glm::ivec2 trueMouseToUiMouse(const glm::ivec2 & position) const { return position; };
@ -69,6 +73,7 @@ public:
}
virtual void abandonCalibration() {}
virtual void resetSensors() {}
virtual float devicePixelRatio() { return 1.0; }
signals:
void recommendedFramebufferSizeChanged(const QSize & size);

View file

@ -27,6 +27,7 @@
#include "Application.h"
#include "ApplicationOverlay.h"
#include "devices/OculusManager.h"
#include "plugins/render/RenderPlugin.h"
#include "Util.h"
#include "ui/Stats.h"
@ -934,7 +935,6 @@ void ApplicationOverlay::renderAudioMeter() {
}
void ApplicationOverlay::renderStatsAndLogs() {
#if 0
Application* application = Application::getInstance();
QSharedPointer<BandwidthRecorder> bandwidthRecorder = DependencyManager::get<BandwidthRecorder>();
@ -972,7 +972,6 @@ void ApplicationOverlay::renderStatsAndLogs() {
0.30f, 0.0f, 0, frameTimer.toUtf8().constData(), WHITE_TEXT);
}
nodeBoundsDisplay.drawOverlay();
#endif
}
void ApplicationOverlay::renderDomainConnectionStatusBorder() {

View file

@ -139,7 +139,7 @@ gpu::FramebufferPointer GlowEffect::render() {
glDisable(GL_DEPTH_TEST);
glDepthMask(GL_FALSE);
gpu::FramebufferPointer destFBO = textureCache->getSecondaryFramebuffer()
gpu::FramebufferPointer destFBO = textureCache->getSecondaryFramebuffer();
if (!_enabled || _isEmpty) {
// copy the primary to the screen
if (destFBO && QOpenGLFramebufferObject::hasOpenGLFramebufferBlit()) {
@ -147,13 +147,13 @@ gpu::FramebufferPointer GlowEffect::render() {
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, gpu::GLBackend::getFramebufferID(destFBO));
glBlitFramebuffer(0, 0, framebufferSize.width(), framebufferSize.height(), 0, 0, framebufferSize.width(), framebufferSize.height(), GL_COLOR_BUFFER_BIT, GL_NEAREST);
} else {
destFBO->bind();
glBindFramebuffer(GL_FRAMEBUFFER, gpu::GLBackend::getFramebufferID(destFBO));
glEnable(GL_TEXTURE_2D);
glDisable(GL_LIGHTING);
renderFullscreenQuad();
glDisable(GL_TEXTURE_2D);
glEnable(GL_LIGHTING);
destFBO->release();
glBindFramebuffer(GL_FRAMEBUFFER, 0);
}
} else {
// diffuse into the secondary/tertiary (alternating between frames)
@ -188,11 +188,11 @@ gpu::FramebufferPointer GlowEffect::render() {
glBindTexture(GL_TEXTURE_2D, gpu::GLBackend::getTextureID(newDiffusedFBO->getRenderBuffer(0)));
destFBO = oldDiffusedFBO;
destFBO->bind();
glBindFramebuffer(GL_FRAMEBUFFER, gpu::GLBackend::getFramebufferID(destFBO));
_addSeparateProgram->bind();
renderFullscreenQuad();
_addSeparateProgram->release();
destFBO->release();
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glBindTexture(GL_TEXTURE_2D, 0);
glActiveTexture(GL_TEXTURE0);

View file

@ -9,8 +9,8 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#pragma once
#ifndef hifi_OffscreenGlCanvas_h
#define hifi_OffscreenGlCanvas_h
#ifndef hifi_OffscreenGlContext_h
#define hifi_OffscreenGlContext_h
#include <QOpenGLContext>
#include <QOffscreenSurface>

View file

@ -32,8 +32,7 @@ TextureCache::TextureCache() :
_permutationNormalTexture(0),
_whiteTexture(0),
_blueTexture(0),
_frameBufferSize(100, 100),
_associatedWidget(NULL)
_frameBufferSize(100, 100)
{
const qint64 TEXTURE_DEFAULT_UNUSED_MAX_SIZE = DEFAULT_UNUSED_MAX_SIZE;
setUnusedResourceCacheSize(TEXTURE_DEFAULT_UNUSED_MAX_SIZE);
@ -290,24 +289,6 @@ GLuint TextureCache::getShadowDepthTextureID() {
return gpu::GLBackend::getTextureID(_shadowTexture);
}
bool TextureCache::eventFilter(QObject* watched, QEvent* event) {
if (event->type() == QEvent::Resize) {
QSize size = static_cast<QResizeEvent*>(event)->size();
if (_frameBufferSize != size) {
_primaryFramebuffer.reset();
_primaryColorTexture.reset();
_primaryDepthTexture.reset();
_primaryNormalTexture.reset();
_primarySpecularTexture.reset();
_secondaryFramebuffer.reset();
_tertiaryFramebuffer.reset();
}
}
return false;
}
QSharedPointer<Resource> TextureCache::createResource(const QUrl& url,
const QSharedPointer<Resource>& fallback, bool delayLoad, const void* extra) {
const TextureExtra* textureExtra = static_cast<const TextureExtra*>(extra);
@ -315,14 +296,6 @@ QSharedPointer<Resource> TextureCache::createResource(const QUrl& url,
&Resource::allReferencesCleared);
}
void TextureCache::associateWithWidget(QGLWidget* widget) {
if (_associatedWidget) {
_associatedWidget->removeEventFilter(this);
}
_associatedWidget = widget;
_associatedWidget->installEventFilter(this);
}
Texture::Texture() {
}

View file

@ -336,6 +336,10 @@ QMatrix4x4 fromGlm(const glm::mat4 & m) {
return QMatrix4x4(&m[0][0]).transposed();
}
QSize fromGlm(const glm::ivec2 & v) {
return QSize(v.x, v.y);
}
QRectF glmToRect(const glm::vec2 & pos, const glm::vec2 & size) {
QRectF result(pos.x, pos.y, size.x, size.y);
return result;

View file

@ -112,6 +112,7 @@ glm::vec2 toGlm(const QPointF & pt);
glm::vec3 toGlm(const xColor & color);
glm::vec4 toGlm(const QColor & color);
QSize fromGlm(const glm::ivec2 & v);
QMatrix4x4 fromGlm(const glm::mat4 & m);
QRectF glmToRect(const glm::vec2 & pos, const glm::vec2 & size);