Merge pull request #5534 from jherico/plugins

PLUGINS - Merge fixes
This commit is contained in:
Brad Hefta-Gaub 2015-08-08 14:44:33 -07:00
commit 74e79f15d8
11 changed files with 48 additions and 41 deletions

View file

@ -103,7 +103,7 @@ else()
add_executable(${TARGET_NAME} ${INTERFACE_SRCS} ${QM}) add_executable(${TARGET_NAME} ${INTERFACE_SRCS} ${QM})
endif() endif()
add_dependency_external_projects(glm bullet LibOVR) add_dependency_external_projects(glm bullet)
# set up the external glm library # set up the external glm library
find_package(GLM REQUIRED) find_package(GLM REQUIRED)
@ -120,11 +120,6 @@ endif()
target_link_libraries(${TARGET_NAME} ${BULLET_LIBRARIES}) target_link_libraries(${TARGET_NAME} ${BULLET_LIBRARIES})
find_package(LibOVR REQUIRED)
target_include_directories(${TARGET_NAME} PRIVATE ${LIBOVR_INCLUDE_DIRS})
#target_link_libraries(${TARGET_NAME} ${LIBOVR_LIBRARIES})
# link required hifi libraries # link required hifi libraries
link_hifi_libraries(shared octree environment gpu model render fbx networking entities avatars link_hifi_libraries(shared octree environment gpu model render fbx networking entities avatars
audio audio-client animation script-engine physics audio audio-client animation script-engine physics

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 MiB

View file

@ -526,6 +526,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
_window->setCentralWidget(_glWidget); _window->setCentralWidget(_glWidget);
_window->restoreGeometry(); _window->restoreGeometry();
_window->setVisible(true);
_glWidget->setFocusPolicy(Qt::StrongFocus); _glWidget->setFocusPolicy(Qt::StrongFocus);
_glWidget->setFocus(); _glWidget->setFocus();
@ -547,9 +548,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
_offscreenContext->makeCurrent(); _offscreenContext->makeCurrent();
initializeGL(); initializeGL();
_window->setVisible(true);
_offscreenContext->makeCurrent();
_toolWindow = new ToolWindow(); _toolWindow = new ToolWindow();
_toolWindow->setWindowFlags(_toolWindow->windowFlags() | Qt::WindowStaysOnTopHint); _toolWindow->setWindowFlags(_toolWindow->windowFlags() | Qt::WindowStaysOnTopHint);
@ -796,7 +794,6 @@ void Application::initializeGL() {
isInitialized = true; isInitialized = true;
} }
#endif #endif
// Where the gpuContext is initialized and where the TRUE Backend is created and assigned // Where the gpuContext is initialized and where the TRUE Backend is created and assigned
gpu::Context::init<gpu::GLBackend>(); gpu::Context::init<gpu::GLBackend>();
_gpuContext = std::make_shared<gpu::Context>(); _gpuContext = std::make_shared<gpu::Context>();
@ -1037,7 +1034,7 @@ void Application::paintGL() {
if (displayPlugin->isStereo()) { if (displayPlugin->isStereo()) {
PROFILE_RANGE(__FUNCTION__ "/stereoRender"); PROFILE_RANGE(__FUNCTION__ "/stereoRender");
QRect r(QPoint(0, 0), QSize(size.width() / 2, size.height())); QRect currentViewport(QPoint(0, 0), QSize(size.width() / 2, size.height()));
glEnable(GL_SCISSOR_TEST); glEnable(GL_SCISSOR_TEST);
for_each_eye([&](Eye eye){ for_each_eye([&](Eye eye){
// Load the view frustum, used by meshes // Load the view frustum, used by meshes
@ -1049,14 +1046,14 @@ void Application::paintGL() {
eyeCamera.setTransform(displayPlugin->getModelview(eye, _myCamera.getTransform())); eyeCamera.setTransform(displayPlugin->getModelview(eye, _myCamera.getTransform()));
} }
eyeCamera.setProjection(displayPlugin->getProjection(eye, _myCamera.getProjection())); eyeCamera.setProjection(displayPlugin->getProjection(eye, _myCamera.getProjection()));
renderArgs._viewport = gpu::Vec4i(r.x(), r.y(), r.width(), r.height()); renderArgs._viewport = toGlm(currentViewport);
doInBatch(&renderArgs, [&](gpu::Batch& batch) { doInBatch(&renderArgs, [&](gpu::Batch& batch) {
batch.setViewportTransform(renderArgs._viewport); batch.setViewportTransform(renderArgs._viewport);
batch.setStateScissorRect(renderArgs._viewport); batch.setStateScissorRect(renderArgs._viewport);
}); });
displaySide(&renderArgs, eyeCamera); displaySide(&renderArgs, eyeCamera);
}, [&] { }, [&] {
r.moveLeft(r.width()); currentViewport.moveLeft(currentViewport.width());
}); });
glDisable(GL_SCISSOR_TEST); glDisable(GL_SCISSOR_TEST);
} else { } else {
@ -1081,17 +1078,17 @@ void Application::paintGL() {
auto primaryFbo = framebufferCache->getPrimaryFramebuffer(); auto primaryFbo = framebufferCache->getPrimaryFramebuffer();
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, gpu::GLBackend::getFramebufferID(primaryFbo)); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, gpu::GLBackend::getFramebufferID(primaryFbo));
if (displayPlugin->isStereo()) { if (displayPlugin->isStereo()) {
QRect r(QPoint(0, 0), QSize(size.width() / 2, size.height())); QRect currentViewport(QPoint(0, 0), QSize(size.width() / 2, size.height()));
glClear(GL_DEPTH_BUFFER_BIT); glClear(GL_DEPTH_BUFFER_BIT);
for_each_eye([&](Eye eye) { for_each_eye([&](Eye eye) {
glViewport(r.x(), r.y(), r.width(), r.height()); renderArgs._viewport = toGlm(currentViewport);
if (displayPlugin->isHmd()) { if (displayPlugin->isHmd()) {
_compositor.displayOverlayTextureHmd(&renderArgs, eye); _compositor.displayOverlayTextureHmd(&renderArgs, eye);
} else { } else {
_compositor.displayOverlayTexture(&renderArgs); _compositor.displayOverlayTexture(&renderArgs);
} }
}, [&] { }, [&] {
r.moveLeft(r.width()); currentViewport.moveLeft(currentViewport.width());
}); });
} else { } else {
glViewport(0, 0, size.width(), size.height()); glViewport(0, 0, size.width(), size.height());
@ -1176,6 +1173,10 @@ void Application::resizeEvent(QResizeEvent * event) {
void Application::resizeGL() { void Application::resizeGL() {
PROFILE_RANGE(__FUNCTION__); PROFILE_RANGE(__FUNCTION__);
if (nullptr == _displayPlugin) {
return;
}
auto displayPlugin = getActiveDisplayPlugin(); auto displayPlugin = getActiveDisplayPlugin();
// Set the desired FBO texture size. If it hasn't changed, this does nothing. // Set the desired FBO texture size. If it hasn't changed, this does nothing.
// Otherwise, it must rebuild the FBOs // Otherwise, it must rebuild the FBOs
@ -1189,6 +1190,8 @@ void Application::resizeGL() {
// Possible change in aspect ratio // Possible change in aspect ratio
loadViewFrustum(_myCamera, _viewFrustum); loadViewFrustum(_myCamera, _viewFrustum);
} }
_myCamera.setProjection(glm::perspective(glm::radians(DEFAULT_FIELD_OF_VIEW_DEGREES), aspect(_renderResolution),
DEFAULT_NEAR_CLIP, DEFAULT_FAR_CLIP));
auto offscreenUi = DependencyManager::get<OffscreenUi>(); auto offscreenUi = DependencyManager::get<OffscreenUi>();
@ -4498,7 +4501,7 @@ int Application::getMaxOctreePacketsPerSecond() {
} }
qreal Application::getDevicePixelRatio() { qreal Application::getDevicePixelRatio() {
return _window ? _window->windowHandle()->devicePixelRatio() : 1.0; return (_window && _window->windowHandle()) ? _window->windowHandle()->devicePixelRatio() : 1.0;
} }
DisplayPlugin * Application::getActiveDisplayPlugin() { DisplayPlugin * Application::getActiveDisplayPlugin() {

View file

@ -16,11 +16,9 @@
#include <display-plugins/stereo/InterleavedStereoDisplayPlugin.h> #include <display-plugins/stereo/InterleavedStereoDisplayPlugin.h>
#include <display-plugins/Basic2DWindowOpenGLDisplayPlugin.h> #include <display-plugins/Basic2DWindowOpenGLDisplayPlugin.h>
#include <display-plugins/oculus/Oculus_0_6_DisplayPlugin.h>
#include <display-plugins/oculus/Oculus_0_5_DisplayPlugin.h>
#include <display-plugins/openvr/OpenVrDisplayPlugin.h> #include <display-plugins/openvr/OpenVrDisplayPlugin.h>
extern DisplayPlugin* makeOculusDisplayPlugin();
static void addDisplayPluginToMenu(DisplayPluginPointer displayPlugin, bool active = false) { static void addDisplayPluginToMenu(DisplayPluginPointer displayPlugin, bool active = false) {
auto menu = Menu::getInstance(); auto menu = Menu::getInstance();
@ -57,11 +55,8 @@ const DisplayPluginList& getDisplayPlugins() {
// FIXME fix stereo display plugins // FIXME fix stereo display plugins
//new SideBySideStereoDisplayPlugin(), //new SideBySideStereoDisplayPlugin(),
//new InterleavedStereoDisplayPlugin(), //new InterleavedStereoDisplayPlugin(),
#if (OVR_MAJOR_VERSION == 5)
new Oculus_0_5_DisplayPlugin(), makeOculusDisplayPlugin(),
#else
new Oculus_0_6_DisplayPlugin(),
#endif
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
new OpenVrDisplayPlugin(), new OpenVrDisplayPlugin(),

View file

@ -16,8 +16,6 @@
#include <QGLWidget> #include <QGLWidget>
#include <QTimer> #include <QTimer>
class QOpenGLContext;
/// customized canvas that simply forwards requests/events to the singleton application /// customized canvas that simply forwards requests/events to the singleton application
class GLCanvas : public QGLWidget { class GLCanvas : public QGLWidget {
Q_OBJECT Q_OBJECT

View file

@ -215,7 +215,7 @@ void ApplicationCompositor::displayOverlayTexture(RenderArgs* renderArgs) {
auto geometryCache = DependencyManager::get<GeometryCache>(); auto geometryCache = DependencyManager::get<GeometryCache>();
geometryCache->useSimpleDrawPipeline(batch); geometryCache->useSimpleDrawPipeline(batch);
batch.setViewportTransform(glm::ivec4(0, 0, deviceSize.width(), deviceSize.height())); batch.setViewportTransform(renderArgs->_viewport);
batch.setModelTransform(Transform()); batch.setModelTransform(Transform());
batch.setViewTransform(Transform()); batch.setViewTransform(Transform());
batch.setProjectionTransform(mat4()); batch.setProjectionTransform(mat4());
@ -295,6 +295,7 @@ void ApplicationCompositor::displayOverlayTextureHmd(RenderArgs* renderArgs, int
mat4 camMat; mat4 camMat;
_cameraBaseTransform.getMatrix(camMat); _cameraBaseTransform.getMatrix(camMat);
camMat = camMat * qApp->getEyePose(eye); camMat = camMat * qApp->getEyePose(eye);
batch.setViewportTransform(renderArgs->_viewport);
batch.setViewTransform(camMat); batch.setViewTransform(camMat);
batch.setProjectionTransform(qApp->getEyeProjection(eye)); batch.setProjectionTransform(qApp->getEyeProjection(eye));

View file

@ -30,6 +30,10 @@
#include "plugins/PluginContainer.h" #include "plugins/PluginContainer.h"
#include "OculusHelpers.h" #include "OculusHelpers.h"
DisplayPlugin* makeOculusDisplayPlugin() {
return new Oculus_0_5_DisplayPlugin();
}
using namespace oglplus; using namespace oglplus;
const QString Oculus_0_5_DisplayPlugin::NAME("Oculus Rift (0.5)"); const QString Oculus_0_5_DisplayPlugin::NAME("Oculus Rift (0.5)");

View file

@ -32,6 +32,9 @@
#include <OglplusHelpers.h> #include <OglplusHelpers.h>
DisplayPlugin* makeOculusDisplayPlugin() {
return new Oculus_0_6_DisplayPlugin();
}
// A base class for FBO wrappers that need to use the Oculus C // A base class for FBO wrappers that need to use the Oculus C
// API to manage textures via ovrHmd_CreateSwapTextureSetGL, // API to manage textures via ovrHmd_CreateSwapTextureSetGL,

View file

@ -334,6 +334,10 @@ glm::vec4 toGlm(const QColor & color) {
return glm::vec4(color.redF(), color.greenF(), color.blueF(), color.alphaF()); return glm::vec4(color.redF(), color.greenF(), color.blueF(), color.alphaF());
} }
ivec4 toGlm(const QRect& rect) {
return ivec4(rect.x(), rect.y(), rect.width(), rect.height());
}
QMatrix4x4 fromGlm(const glm::mat4 & m) { QMatrix4x4 fromGlm(const glm::mat4 & m) {
return QMatrix4x4(&m[0][0]).transposed(); return QMatrix4x4(&m[0][0]).transposed();
} }

View file

@ -18,9 +18,12 @@
#include <glm/gtc/quaternion.hpp> #include <glm/gtc/quaternion.hpp>
// Bring the most commonly used GLM types into the default namespace // Bring the most commonly used GLM types into the default namespace
using glm::ivec3;
using glm::ivec2; using glm::ivec2;
using glm::ivec3;
using glm::ivec4;
using glm::uvec2; using glm::uvec2;
using glm::uvec3;
using glm::uvec4;
using glm::mat3; using glm::mat3;
using glm::mat4; using glm::mat4;
using glm::vec2; using glm::vec2;
@ -115,11 +118,12 @@ bool isSimilarOrientation(const glm::quat& orientionA, const glm::quat& orientio
const float POSITION_SIMILAR_ENOUGH = 0.1f; // 0.1 meter const float POSITION_SIMILAR_ENOUGH = 0.1f; // 0.1 meter
bool isSimilarPosition(const glm::vec3& positionA, const glm::vec3& positionB, float similarEnough = POSITION_SIMILAR_ENOUGH); bool isSimilarPosition(const glm::vec3& positionA, const glm::vec3& positionB, float similarEnough = POSITION_SIMILAR_ENOUGH);
glm::uvec2 toGlm(const QSize & size); uvec2 toGlm(const QSize& size);
glm::ivec2 toGlm(const QPoint & pt); ivec2 toGlm(const QPoint& pt);
glm::vec2 toGlm(const QPointF & pt); vec2 toGlm(const QPointF& pt);
glm::vec3 toGlm(const xColor & color); vec3 toGlm(const xColor& color);
glm::vec4 toGlm(const QColor & color); vec4 toGlm(const QColor& color);
ivec4 toGlm(const QRect& rect);
QSize fromGlm(const glm::ivec2 & v); QSize fromGlm(const glm::ivec2 & v);
QMatrix4x4 fromGlm(const glm::mat4 & m); QMatrix4x4 fromGlm(const glm::mat4 & m);