mirror of
https://github.com/lubosz/overte.git
synced 2025-04-06 15:22:42 +02:00
Working towards display plugins
This commit is contained in:
parent
857552ae0b
commit
09085f1cd9
14 changed files with 243 additions and 88 deletions
|
@ -177,8 +177,12 @@ 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(USE_NSIGHT "Attempt to find the nSight libraries" 1)
|
||||
option(GET_VHACD "Get V-HACD library automatically as external project" 1)
|
||||
option(GET_OPENVR "Get OpenVR library automatically as external project" 1)
|
||||
option(GET_BOOSTCONFIG "Get Boost-config library automatically as external project" 1)
|
||||
option(GET_OGLPLUS "Get OGLplus library automatically as external project" 1)
|
||||
|
||||
option(USE_NSIGHT "Attempt to find the nSight libraries" 1)
|
||||
|
||||
if (WIN32)
|
||||
option(GET_GLEW "Get GLEW library automatically as external project" 1)
|
||||
|
|
18
cmake/externals/boostconfig/CMakeLists.txt
vendored
Normal file
18
cmake/externals/boostconfig/CMakeLists.txt
vendored
Normal file
|
@ -0,0 +1,18 @@
|
|||
set(EXTERNAL_NAME boostconfig)
|
||||
string(TOUPPER ${EXTERNAL_NAME} EXTERNAL_NAME_UPPER)
|
||||
|
||||
include(ExternalProject)
|
||||
ExternalProject_Add(
|
||||
${EXTERNAL_NAME}
|
||||
URL https://github.com/boostorg/config/archive/boost-1.58.0.zip
|
||||
URL_MD5 42fa673bae2b7645a22736445e80eb8d
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND ""
|
||||
INSTALL_COMMAND ""
|
||||
LOG_DOWNLOAD 1
|
||||
)
|
||||
|
||||
ExternalProject_Get_Property(${EXTERNAL_NAME} SOURCE_DIR)
|
||||
|
||||
set(${EXTERNAL_NAME_UPPER}_INCLUDE_DIRS ${SOURCE_DIR}/include CACHE TYPE INTERNAL)
|
||||
|
18
cmake/externals/oglplus/CMakeLists.txt
vendored
Normal file
18
cmake/externals/oglplus/CMakeLists.txt
vendored
Normal file
|
@ -0,0 +1,18 @@
|
|||
set(EXTERNAL_NAME oglplus)
|
||||
string(TOUPPER ${EXTERNAL_NAME} EXTERNAL_NAME_UPPER)
|
||||
|
||||
include(ExternalProject)
|
||||
ExternalProject_Add(
|
||||
${EXTERNAL_NAME}
|
||||
URL http://softlayer-dal.dl.sourceforge.net/project/oglplus/oglplus-0.61.x/oglplus-0.61.0.zip
|
||||
URL_MD5 bb55038c36c660d2b6c7be380414fa60
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND ""
|
||||
INSTALL_COMMAND ""
|
||||
LOG_DOWNLOAD 1
|
||||
)
|
||||
|
||||
ExternalProject_Get_Property(${EXTERNAL_NAME} SOURCE_DIR)
|
||||
|
||||
set(${EXTERNAL_NAME_UPPER}_INCLUDE_DIRS ${SOURCE_DIR}/include ${SOURCE_DIR}/implement CACHE TYPE INTERNAL)
|
||||
|
4
cmake/externals/openvr/CMakeLists.txt
vendored
4
cmake/externals/openvr/CMakeLists.txt
vendored
|
@ -7,8 +7,8 @@ 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
|
||||
URL https://github.com/ValveSoftware/openvr/archive/0.9.1.zip
|
||||
URL_MD5 f986f5a6815e9454c53c5bf58ce02fdc
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND ""
|
||||
INSTALL_COMMAND ""
|
||||
|
|
24
cmake/modules/FindBoostConfig.cmake
Normal file
24
cmake/modules/FindBoostConfig.cmake
Normal file
|
@ -0,0 +1,24 @@
|
|||
#
|
||||
# Try to find BOOSTCONFIG include path.
|
||||
# Once done this will define
|
||||
#
|
||||
# BOOSTCONFIG_INCLUDE_DIRS
|
||||
#
|
||||
# Created by Bradley Austin Davis on 2015/05/22
|
||||
# Copyright 2015 High Fidelity, Inc.
|
||||
#
|
||||
# Distributed under the Apache License, Version 2.0.
|
||||
# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
#
|
||||
|
||||
# setup hints for BOOSTCONFIG search
|
||||
include("${MACRO_DIR}/HifiLibrarySearchHints.cmake")
|
||||
hifi_library_search_hints("BOOSTCONFIG")
|
||||
|
||||
# locate header
|
||||
find_path(BOOSTCONFIG_INCLUDE_DIRS "boost/config.hpp" HINTS ${BOOSTCONFIG_SEARCH_DIRS})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(BOOSTCONFIG DEFAULT_MSG BOOSTCONFIG_INCLUDE_DIRS)
|
||||
|
||||
mark_as_advanced(BOOSTCONFIG_INCLUDE_DIRS BOOSTCONFIG_SEARCH_DIRS)
|
24
cmake/modules/FindOGLPLUS.cmake
Normal file
24
cmake/modules/FindOGLPLUS.cmake
Normal file
|
@ -0,0 +1,24 @@
|
|||
#
|
||||
# Try to find OGLPLUS include path.
|
||||
# Once done this will define
|
||||
#
|
||||
# OGLPLUS_INCLUDE_DIRS
|
||||
#
|
||||
# Created by Bradley Austin Davis on 2015/05/22
|
||||
# Copyright 2015 High Fidelity, Inc.
|
||||
#
|
||||
# Distributed under the Apache License, Version 2.0.
|
||||
# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
#
|
||||
|
||||
# setup hints for OGLPLUS search
|
||||
include("${MACRO_DIR}/HifiLibrarySearchHints.cmake")
|
||||
hifi_library_search_hints("oglplus")
|
||||
|
||||
# locate header
|
||||
find_path(OGLPLUS_INCLUDE_DIRS "oglplus/fwd.hpp" HINTS ${OGLPLUS_SEARCH_DIRS})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(OGLPLUS DEFAULT_MSG OGLPLUS_INCLUDE_DIRS)
|
||||
|
||||
mark_as_advanced(OGLPLUS_INCLUDE_DIRS OGLPLUS_SEARCH_DIRS)
|
|
@ -27,14 +27,17 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
ViewFrustum::ViewFrustum() {
|
||||
}
|
||||
|
||||
void ViewFrustum::setOrientation(const glm::quat& orientationAsQuaternion) {
|
||||
_orientation = orientationAsQuaternion;
|
||||
_right = glm::vec3(orientationAsQuaternion * glm::vec4(IDENTITY_RIGHT, 0.0f));
|
||||
_up = glm::vec3(orientationAsQuaternion * glm::vec4(IDENTITY_UP, 0.0f));
|
||||
_direction = glm::vec3(orientationAsQuaternion * glm::vec4(IDENTITY_FRONT, 0.0f));
|
||||
_view = glm::translate(mat4(), _position) * glm::mat4_cast(_orientation);
|
||||
}
|
||||
|
||||
void ViewFrustum::setPosition(const glm::vec3& position) {
|
||||
_position = position;
|
||||
_view = glm::translate(mat4(), _position) * glm::mat4_cast(_orientation);
|
||||
}
|
||||
|
||||
// Order cooresponds to the order defined in the BoxVertex enum.
|
||||
|
|
|
@ -36,11 +36,9 @@ const float DEFAULT_FAR_CLIP = (float)TREE_SCALE;
|
|||
|
||||
class ViewFrustum {
|
||||
public:
|
||||
ViewFrustum();
|
||||
|
||||
// setters for camera attributes
|
||||
void setPosition(const glm::vec3& p) { _position = p; }
|
||||
void setOrientation(const glm::quat& orientationAsQuaternion);
|
||||
void setPosition(const glm::vec3& position);
|
||||
void setOrientation(const glm::quat& orientation);
|
||||
|
||||
// getters for camera attributes
|
||||
const glm::vec3& getPosition() const { return _position; }
|
||||
|
@ -54,7 +52,8 @@ public:
|
|||
void getFocalLength(float focalLength) { _focalLength = focalLength; }
|
||||
|
||||
// getters for lens attributes
|
||||
const glm::mat4 getProjection() const { return _projection; };
|
||||
const glm::mat4& getProjection() const { return _projection; };
|
||||
const glm::mat4& getView() const { return _view; };
|
||||
float getWidth() const { return _width; }
|
||||
float getHeight() const { return _height; }
|
||||
float getFieldOfView() const { return _fieldOfView; }
|
||||
|
@ -120,6 +119,7 @@ private:
|
|||
// camera location/orientation attributes
|
||||
glm::vec3 _position; // the position in world-frame
|
||||
glm::quat _orientation;
|
||||
glm::mat4 _view;
|
||||
|
||||
// Lens attributes
|
||||
glm::mat4 _projection;
|
||||
|
|
78
libraries/render-utils/src/GlWindow.cpp
Normal file
78
libraries/render-utils/src/GlWindow.cpp
Normal file
|
@ -0,0 +1,78 @@
|
|||
//
|
||||
// Created by Bradley Austin Davis on 2015/05/21
|
||||
// Copyright 2013 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include "GlWindow.h"
|
||||
|
||||
#include <QOpenGLContext>
|
||||
#include <QOpenGLDebugLogger>
|
||||
|
||||
static QSurfaceFormat getDefaultFormat() {
|
||||
QSurfaceFormat format;
|
||||
// Qt Quick may need a depth and stencil buffer. Always make sure these are available.
|
||||
format.setDepthBufferSize(16);
|
||||
format.setStencilBufferSize(8);
|
||||
format.setVersion(4, 1);
|
||||
#ifdef DEBUG
|
||||
format.setOption(QSurfaceFormat::DebugContext);
|
||||
#endif
|
||||
format.setProfile(QSurfaceFormat::OpenGLContextProfile::CompatibilityProfile);
|
||||
return format;
|
||||
}
|
||||
|
||||
GlWindow::GlWindow(QOpenGLContext * shareContext) : GlWindow(getDefaultFormat(), shareContext) {
|
||||
}
|
||||
|
||||
GlWindow::GlWindow(const QSurfaceFormat& format, QOpenGLContext * shareContext) {
|
||||
setSurfaceType(QSurface::OpenGLSurface);
|
||||
setFormat(format);
|
||||
_context = new QOpenGLContext;
|
||||
_context->setFormat(format);
|
||||
if (shareContext) {
|
||||
_context->setShareContext(shareContext);
|
||||
}
|
||||
_context->create();
|
||||
}
|
||||
|
||||
GlWindow::~GlWindow() {
|
||||
#ifdef DEBUG
|
||||
if (_logger) {
|
||||
makeCurrent();
|
||||
delete _logger;
|
||||
_logger = nullptr;
|
||||
}
|
||||
#endif
|
||||
_context->doneCurrent();
|
||||
_context->deleteLater();
|
||||
_context = nullptr;
|
||||
}
|
||||
|
||||
|
||||
void GlWindow::makeCurrent() {
|
||||
_context->makeCurrent(this);
|
||||
#ifdef DEBUG
|
||||
if (!_logger) {
|
||||
_logger = new QOpenGLDebugLogger(this);
|
||||
if (_logger->initialize()) {
|
||||
connect(_logger, &QOpenGLDebugLogger::messageLogged, [](const QOpenGLDebugMessage& message) {
|
||||
qDebug() << message;
|
||||
});
|
||||
_logger->disableMessages(QOpenGLDebugMessage::AnySource, QOpenGLDebugMessage::AnyType, QOpenGLDebugMessage::NotificationSeverity);
|
||||
_logger->startLogging(QOpenGLDebugLogger::LoggingMode::SynchronousLogging);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void GlWindow::doneCurrent() {
|
||||
_context->doneCurrent();
|
||||
}
|
||||
|
||||
void GlWindow::swapBuffers() {
|
||||
_context->swapBuffers(this);
|
||||
}
|
||||
|
34
libraries/render-utils/src/GlWindow.h
Normal file
34
libraries/render-utils/src/GlWindow.h
Normal file
|
@ -0,0 +1,34 @@
|
|||
//
|
||||
// Created by Bradley Austin Davis on 2015/05/21
|
||||
// Copyright 2013 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#pragma once
|
||||
#ifndef hifi_GlWindow_h
|
||||
#define hifi_GlWindow_h
|
||||
|
||||
#include <QWindow>
|
||||
#include <QSurfaceFormat>
|
||||
|
||||
class QOpenGLContext;
|
||||
class QOpenGLDebugLogger;
|
||||
|
||||
class GlWindow : public QWindow {
|
||||
public:
|
||||
GlWindow(QOpenGLContext * shareContext = nullptr);
|
||||
GlWindow(const QSurfaceFormat& format, QOpenGLContext * shareContext = nullptr);
|
||||
virtual ~GlWindow();
|
||||
void makeCurrent();
|
||||
void doneCurrent();
|
||||
void swapBuffers();
|
||||
private:
|
||||
QOpenGLContext * _context{ nullptr };
|
||||
#ifdef DEBUG
|
||||
QOpenGLDebugLogger * _logger{ nullptr };
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
|
||||
#include "OffscreenGlCanvas.h"
|
||||
#include <QOpenGLDebugLogger>
|
||||
|
||||
OffscreenGlCanvas::OffscreenGlCanvas() {
|
||||
}
|
||||
|
@ -27,16 +28,35 @@ void OffscreenGlCanvas::create(QOpenGLContext* sharedContext) {
|
|||
format.setMajorVersion(4);
|
||||
format.setMinorVersion(1);
|
||||
format.setProfile(QSurfaceFormat::OpenGLContextProfile::CompatibilityProfile);
|
||||
#ifdef DEBUG
|
||||
format.setOption(QSurfaceFormat::DebugContext);
|
||||
#endif
|
||||
_context.setFormat(format);
|
||||
}
|
||||
_context.create();
|
||||
|
||||
_offscreenSurface.setFormat(_context.format());
|
||||
_offscreenSurface.create();
|
||||
|
||||
}
|
||||
|
||||
bool OffscreenGlCanvas::makeCurrent() {
|
||||
return _context.makeCurrent(&_offscreenSurface);
|
||||
bool result = _context.makeCurrent(&_offscreenSurface);
|
||||
|
||||
#ifdef DEBUG
|
||||
if (result && !_logger) {
|
||||
_logger = new QOpenGLDebugLogger(this);
|
||||
if (_logger->initialize()) {
|
||||
connect(_logger, &QOpenGLDebugLogger::messageLogged, [](const QOpenGLDebugMessage& message) {
|
||||
qDebug() << message;
|
||||
});
|
||||
_logger->disableMessages(QOpenGLDebugMessage::AnySource, QOpenGLDebugMessage::AnyType, QOpenGLDebugMessage::NotificationSeverity);
|
||||
_logger->startLogging(QOpenGLDebugLogger::LoggingMode::SynchronousLogging);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void OffscreenGlCanvas::doneCurrent() {
|
||||
|
|
|
@ -15,16 +15,24 @@
|
|||
#include <QOpenGLContext>
|
||||
#include <QOffscreenSurface>
|
||||
|
||||
class QOpenGLDebugLogger;
|
||||
|
||||
class OffscreenGlCanvas : public QObject {
|
||||
public:
|
||||
OffscreenGlCanvas();
|
||||
void create(QOpenGLContext* sharedContext = nullptr);
|
||||
bool makeCurrent();
|
||||
void doneCurrent();
|
||||
QOpenGLContext* getContext() {
|
||||
return &_context;
|
||||
}
|
||||
|
||||
protected:
|
||||
QOpenGLContext _context;
|
||||
QOffscreenSurface _offscreenSurface;
|
||||
#ifdef DEBUG
|
||||
QOpenGLDebugLogger * _logger{ nullptr };
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
//
|
||||
// OffscreenGlCanvas.cpp
|
||||
// interface/src/renderer
|
||||
//
|
||||
// Created by Bradley Austin Davis on 2014/04/09.
|
||||
// Copyright 2015 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
|
||||
#include "OffscreenGlContext.h"
|
||||
|
||||
OffscreenGlContext::OffscreenGlContext() {
|
||||
}
|
||||
|
||||
void OffscreenGlContext::create(QOpenGLContext * sharedContext) {
|
||||
QSurfaceFormat format;
|
||||
format.setDepthBufferSize(16);
|
||||
format.setStencilBufferSize(8);
|
||||
format.setMajorVersion(4);
|
||||
format.setMinorVersion(1);
|
||||
format.setProfile(QSurfaceFormat::OpenGLContextProfile::CompatibilityProfile);
|
||||
|
||||
_context.setFormat(format);
|
||||
if (nullptr != sharedContext) {
|
||||
_context.setShareContext(sharedContext);
|
||||
}
|
||||
_context.create();
|
||||
|
||||
_offscreenSurface.setFormat(_context.format());
|
||||
_offscreenSurface.create();
|
||||
}
|
||||
|
||||
bool OffscreenGlContext::makeCurrent() {
|
||||
return _context.makeCurrent(&_offscreenSurface);
|
||||
}
|
||||
|
||||
void OffscreenGlContext::doneCurrent() {
|
||||
_context.doneCurrent();
|
||||
}
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
//
|
||||
// OffscreenGlCanvas.h
|
||||
// interface/src/renderer
|
||||
//
|
||||
// Created by Bradley Austin Davis on 2014/04/09.
|
||||
// Copyright 2015 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
#pragma once
|
||||
#ifndef hifi_OffscreenGlContext_h
|
||||
#define hifi_OffscreenGlContext_h
|
||||
|
||||
#include <QOpenGLContext>
|
||||
#include <QOffscreenSurface>
|
||||
|
||||
class OffscreenGlContext : public QObject {
|
||||
public:
|
||||
OffscreenGlContext();
|
||||
void create(QOpenGLContext * sharedContext = nullptr);
|
||||
bool makeCurrent();
|
||||
void doneCurrent();
|
||||
QOpenGLContext * getContext() {
|
||||
return &_context;
|
||||
}
|
||||
|
||||
protected:
|
||||
QOpenGLContext _context;
|
||||
QOffscreenSurface _offscreenSurface;
|
||||
};
|
||||
|
||||
#endif // hifi_OffscreenGlCanvas_h
|
Loading…
Reference in a new issue