mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 18:23:54 +02:00
commit
74e79f15d8
11 changed files with 48 additions and 41 deletions
|
@ -103,7 +103,7 @@ else()
|
|||
add_executable(${TARGET_NAME} ${INTERFACE_SRCS} ${QM})
|
||||
endif()
|
||||
|
||||
add_dependency_external_projects(glm bullet LibOVR)
|
||||
add_dependency_external_projects(glm bullet)
|
||||
|
||||
# set up the external glm library
|
||||
find_package(GLM REQUIRED)
|
||||
|
@ -120,11 +120,6 @@ endif()
|
|||
|
||||
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_hifi_libraries(shared octree environment gpu model render fbx networking entities avatars
|
||||
audio audio-client animation script-engine physics
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 2.8 MiB |
|
@ -526,6 +526,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
|||
_window->setCentralWidget(_glWidget);
|
||||
|
||||
_window->restoreGeometry();
|
||||
_window->setVisible(true);
|
||||
|
||||
_glWidget->setFocusPolicy(Qt::StrongFocus);
|
||||
_glWidget->setFocus();
|
||||
|
@ -547,9 +548,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
|||
_offscreenContext->makeCurrent();
|
||||
initializeGL();
|
||||
|
||||
_window->setVisible(true);
|
||||
_offscreenContext->makeCurrent();
|
||||
|
||||
|
||||
_toolWindow = new ToolWindow();
|
||||
_toolWindow->setWindowFlags(_toolWindow->windowFlags() | Qt::WindowStaysOnTopHint);
|
||||
|
@ -796,7 +794,6 @@ void Application::initializeGL() {
|
|||
isInitialized = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Where the gpuContext is initialized and where the TRUE Backend is created and assigned
|
||||
gpu::Context::init<gpu::GLBackend>();
|
||||
_gpuContext = std::make_shared<gpu::Context>();
|
||||
|
@ -1037,7 +1034,7 @@ void Application::paintGL() {
|
|||
|
||||
if (displayPlugin->isStereo()) {
|
||||
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);
|
||||
for_each_eye([&](Eye eye){
|
||||
// Load the view frustum, used by meshes
|
||||
|
@ -1049,14 +1046,14 @@ void Application::paintGL() {
|
|||
eyeCamera.setTransform(displayPlugin->getModelview(eye, _myCamera.getTransform()));
|
||||
}
|
||||
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) {
|
||||
batch.setViewportTransform(renderArgs._viewport);
|
||||
batch.setStateScissorRect(renderArgs._viewport);
|
||||
});
|
||||
displaySide(&renderArgs, eyeCamera);
|
||||
}, [&] {
|
||||
r.moveLeft(r.width());
|
||||
currentViewport.moveLeft(currentViewport.width());
|
||||
});
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
} else {
|
||||
|
@ -1081,17 +1078,17 @@ void Application::paintGL() {
|
|||
auto primaryFbo = framebufferCache->getPrimaryFramebuffer();
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, gpu::GLBackend::getFramebufferID(primaryFbo));
|
||||
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);
|
||||
for_each_eye([&](Eye eye) {
|
||||
glViewport(r.x(), r.y(), r.width(), r.height());
|
||||
renderArgs._viewport = toGlm(currentViewport);
|
||||
if (displayPlugin->isHmd()) {
|
||||
_compositor.displayOverlayTextureHmd(&renderArgs, eye);
|
||||
} else {
|
||||
_compositor.displayOverlayTexture(&renderArgs);
|
||||
}
|
||||
}, [&] {
|
||||
r.moveLeft(r.width());
|
||||
currentViewport.moveLeft(currentViewport.width());
|
||||
});
|
||||
} else {
|
||||
glViewport(0, 0, size.width(), size.height());
|
||||
|
@ -1176,6 +1173,10 @@ void Application::resizeEvent(QResizeEvent * event) {
|
|||
|
||||
void Application::resizeGL() {
|
||||
PROFILE_RANGE(__FUNCTION__);
|
||||
if (nullptr == _displayPlugin) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto displayPlugin = getActiveDisplayPlugin();
|
||||
// Set the desired FBO texture size. If it hasn't changed, this does nothing.
|
||||
// Otherwise, it must rebuild the FBOs
|
||||
|
@ -1189,6 +1190,8 @@ void Application::resizeGL() {
|
|||
// Possible change in aspect ratio
|
||||
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>();
|
||||
|
||||
|
@ -4498,7 +4501,7 @@ int Application::getMaxOctreePacketsPerSecond() {
|
|||
}
|
||||
|
||||
qreal Application::getDevicePixelRatio() {
|
||||
return _window ? _window->windowHandle()->devicePixelRatio() : 1.0;
|
||||
return (_window && _window->windowHandle()) ? _window->windowHandle()->devicePixelRatio() : 1.0;
|
||||
}
|
||||
|
||||
DisplayPlugin * Application::getActiveDisplayPlugin() {
|
||||
|
|
|
@ -16,11 +16,9 @@
|
|||
#include <display-plugins/stereo/InterleavedStereoDisplayPlugin.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>
|
||||
|
||||
extern DisplayPlugin* makeOculusDisplayPlugin();
|
||||
|
||||
static void addDisplayPluginToMenu(DisplayPluginPointer displayPlugin, bool active = false) {
|
||||
auto menu = Menu::getInstance();
|
||||
|
@ -55,13 +53,10 @@ const DisplayPluginList& getDisplayPlugins() {
|
|||
new NullDisplayPlugin(),
|
||||
#endif
|
||||
// FIXME fix stereo display plugins
|
||||
// new SideBySideStereoDisplayPlugin(),
|
||||
// new InterleavedStereoDisplayPlugin(),
|
||||
#if (OVR_MAJOR_VERSION == 5)
|
||||
new Oculus_0_5_DisplayPlugin(),
|
||||
#else
|
||||
new Oculus_0_6_DisplayPlugin(),
|
||||
#endif
|
||||
//new SideBySideStereoDisplayPlugin(),
|
||||
//new InterleavedStereoDisplayPlugin(),
|
||||
|
||||
makeOculusDisplayPlugin(),
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
new OpenVrDisplayPlugin(),
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
#include <QGLWidget>
|
||||
#include <QTimer>
|
||||
|
||||
class QOpenGLContext;
|
||||
|
||||
/// customized canvas that simply forwards requests/events to the singleton application
|
||||
class GLCanvas : public QGLWidget {
|
||||
Q_OBJECT
|
||||
|
|
|
@ -215,7 +215,7 @@ void ApplicationCompositor::displayOverlayTexture(RenderArgs* renderArgs) {
|
|||
auto geometryCache = DependencyManager::get<GeometryCache>();
|
||||
|
||||
geometryCache->useSimpleDrawPipeline(batch);
|
||||
batch.setViewportTransform(glm::ivec4(0, 0, deviceSize.width(), deviceSize.height()));
|
||||
batch.setViewportTransform(renderArgs->_viewport);
|
||||
batch.setModelTransform(Transform());
|
||||
batch.setViewTransform(Transform());
|
||||
batch.setProjectionTransform(mat4());
|
||||
|
@ -295,6 +295,7 @@ void ApplicationCompositor::displayOverlayTextureHmd(RenderArgs* renderArgs, int
|
|||
mat4 camMat;
|
||||
_cameraBaseTransform.getMatrix(camMat);
|
||||
camMat = camMat * qApp->getEyePose(eye);
|
||||
batch.setViewportTransform(renderArgs->_viewport);
|
||||
batch.setViewTransform(camMat);
|
||||
|
||||
batch.setProjectionTransform(qApp->getEyeProjection(eye));
|
||||
|
|
|
@ -30,6 +30,10 @@
|
|||
#include "plugins/PluginContainer.h"
|
||||
#include "OculusHelpers.h"
|
||||
|
||||
DisplayPlugin* makeOculusDisplayPlugin() {
|
||||
return new Oculus_0_5_DisplayPlugin();
|
||||
}
|
||||
|
||||
using namespace oglplus;
|
||||
|
||||
const QString Oculus_0_5_DisplayPlugin::NAME("Oculus Rift (0.5)");
|
||||
|
|
|
@ -32,6 +32,9 @@
|
|||
|
||||
#include <OglplusHelpers.h>
|
||||
|
||||
DisplayPlugin* makeOculusDisplayPlugin() {
|
||||
return new Oculus_0_6_DisplayPlugin();
|
||||
}
|
||||
|
||||
// A base class for FBO wrappers that need to use the Oculus C
|
||||
// API to manage textures via ovrHmd_CreateSwapTextureSetGL,
|
||||
|
|
|
@ -313,27 +313,31 @@ bool isSimilarPosition(const glm::vec3& positionA, const glm::vec3& positionB, f
|
|||
return (positionDistance <= similarEnough);
|
||||
}
|
||||
|
||||
glm::uvec2 toGlm(const QSize & size) {
|
||||
glm::uvec2 toGlm(const QSize& size) {
|
||||
return glm::uvec2(size.width(), size.height());
|
||||
}
|
||||
|
||||
glm::ivec2 toGlm(const QPoint & pt) {
|
||||
glm::ivec2 toGlm(const QPoint& pt) {
|
||||
return glm::ivec2(pt.x(), pt.y());
|
||||
}
|
||||
|
||||
glm::vec2 toGlm(const QPointF & pt) {
|
||||
glm::vec2 toGlm(const QPointF& pt) {
|
||||
return glm::vec2(pt.x(), pt.y());
|
||||
}
|
||||
|
||||
glm::vec3 toGlm(const xColor & color) {
|
||||
glm::vec3 toGlm(const xColor& color) {
|
||||
static const float MAX_COLOR = 255.0f;
|
||||
return glm::vec3(color.red, color.green, color.blue) / MAX_COLOR;
|
||||
}
|
||||
|
||||
glm::vec4 toGlm(const QColor & color) {
|
||||
glm::vec4 toGlm(const QColor& color) {
|
||||
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) {
|
||||
return QMatrix4x4(&m[0][0]).transposed();
|
||||
}
|
||||
|
|
|
@ -18,9 +18,12 @@
|
|||
#include <glm/gtc/quaternion.hpp>
|
||||
|
||||
// Bring the most commonly used GLM types into the default namespace
|
||||
using glm::ivec3;
|
||||
using glm::ivec2;
|
||||
using glm::ivec3;
|
||||
using glm::ivec4;
|
||||
using glm::uvec2;
|
||||
using glm::uvec3;
|
||||
using glm::uvec4;
|
||||
using glm::mat3;
|
||||
using glm::mat4;
|
||||
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
|
||||
bool isSimilarPosition(const glm::vec3& positionA, const glm::vec3& positionB, float similarEnough = POSITION_SIMILAR_ENOUGH);
|
||||
|
||||
glm::uvec2 toGlm(const QSize & size);
|
||||
glm::ivec2 toGlm(const QPoint & pt);
|
||||
glm::vec2 toGlm(const QPointF & pt);
|
||||
glm::vec3 toGlm(const xColor & color);
|
||||
glm::vec4 toGlm(const QColor & color);
|
||||
uvec2 toGlm(const QSize& size);
|
||||
ivec2 toGlm(const QPoint& pt);
|
||||
vec2 toGlm(const QPointF& pt);
|
||||
vec3 toGlm(const xColor& color);
|
||||
vec4 toGlm(const QColor& color);
|
||||
ivec4 toGlm(const QRect& rect);
|
||||
|
||||
QSize fromGlm(const glm::ivec2 & v);
|
||||
QMatrix4x4 fromGlm(const glm::mat4 & m);
|
||||
|
|
Loading…
Reference in a new issue