Skip to content

Commit 09085f1

Browse files
committed
Working towards display plugins
1 parent 857552a commit 09085f1

File tree

14 files changed

+243
-88
lines changed

14 files changed

+243
-88
lines changed

CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,12 @@ option(GET_GVERB "Get Gverb library automatically as external project" 1)
177177
option(GET_SOXR "Get Soxr library automatically as external project" 1)
178178
option(GET_TBB "Get Threading Building Blocks library automatically as external project" 1)
179179
option(GET_LIBOVR "Get LibOVR library automatically as external project" 1)
180-
option(USE_NSIGHT "Attempt to find the nSight libraries" 1)
181180
option(GET_VHACD "Get V-HACD library automatically as external project" 1)
181+
option(GET_OPENVR "Get OpenVR library automatically as external project" 1)
182+
option(GET_BOOSTCONFIG "Get Boost-config library automatically as external project" 1)
183+
option(GET_OGLPLUS "Get OGLplus library automatically as external project" 1)
184+
185+
option(USE_NSIGHT "Attempt to find the nSight libraries" 1)
182186

183187
if (WIN32)
184188
option(GET_GLEW "Get GLEW library automatically as external project" 1)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
set(EXTERNAL_NAME boostconfig)
2+
string(TOUPPER ${EXTERNAL_NAME} EXTERNAL_NAME_UPPER)
3+
4+
include(ExternalProject)
5+
ExternalProject_Add(
6+
${EXTERNAL_NAME}
7+
URL https://github.com/boostorg/config/archive/boost-1.58.0.zip
8+
URL_MD5 42fa673bae2b7645a22736445e80eb8d
9+
CONFIGURE_COMMAND ""
10+
BUILD_COMMAND ""
11+
INSTALL_COMMAND ""
12+
LOG_DOWNLOAD 1
13+
)
14+
15+
ExternalProject_Get_Property(${EXTERNAL_NAME} SOURCE_DIR)
16+
17+
set(${EXTERNAL_NAME_UPPER}_INCLUDE_DIRS ${SOURCE_DIR}/include CACHE TYPE INTERNAL)
18+
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
set(EXTERNAL_NAME oglplus)
2+
string(TOUPPER ${EXTERNAL_NAME} EXTERNAL_NAME_UPPER)
3+
4+
include(ExternalProject)
5+
ExternalProject_Add(
6+
${EXTERNAL_NAME}
7+
URL http://softlayer-dal.dl.sourceforge.net/project/oglplus/oglplus-0.61.x/oglplus-0.61.0.zip
8+
URL_MD5 bb55038c36c660d2b6c7be380414fa60
9+
CONFIGURE_COMMAND ""
10+
BUILD_COMMAND ""
11+
INSTALL_COMMAND ""
12+
LOG_DOWNLOAD 1
13+
)
14+
15+
ExternalProject_Get_Property(${EXTERNAL_NAME} SOURCE_DIR)
16+
17+
set(${EXTERNAL_NAME_UPPER}_INCLUDE_DIRS ${SOURCE_DIR}/include ${SOURCE_DIR}/implement CACHE TYPE INTERNAL)
18+

cmake/externals/openvr/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ string(TOUPPER ${EXTERNAL_NAME} EXTERNAL_NAME_UPPER)
77

88
ExternalProject_Add(
99
${EXTERNAL_NAME}
10-
URL https://github.com/ValveSoftware/openvr/archive/0.9.0.zip
11-
URL_MD5 4fbde7759f604aaa68b9c40d628cc34a
10+
URL https://github.com/ValveSoftware/openvr/archive/0.9.1.zip
11+
URL_MD5 f986f5a6815e9454c53c5bf58ce02fdc
1212
CONFIGURE_COMMAND ""
1313
BUILD_COMMAND ""
1414
INSTALL_COMMAND ""

cmake/modules/FindBoostConfig.cmake

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#
2+
# Try to find BOOSTCONFIG include path.
3+
# Once done this will define
4+
#
5+
# BOOSTCONFIG_INCLUDE_DIRS
6+
#
7+
# Created by Bradley Austin Davis on 2015/05/22
8+
# Copyright 2015 High Fidelity, Inc.
9+
#
10+
# Distributed under the Apache License, Version 2.0.
11+
# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
12+
#
13+
14+
# setup hints for BOOSTCONFIG search
15+
include("${MACRO_DIR}/HifiLibrarySearchHints.cmake")
16+
hifi_library_search_hints("BOOSTCONFIG")
17+
18+
# locate header
19+
find_path(BOOSTCONFIG_INCLUDE_DIRS "boost/config.hpp" HINTS ${BOOSTCONFIG_SEARCH_DIRS})
20+
21+
include(FindPackageHandleStandardArgs)
22+
find_package_handle_standard_args(BOOSTCONFIG DEFAULT_MSG BOOSTCONFIG_INCLUDE_DIRS)
23+
24+
mark_as_advanced(BOOSTCONFIG_INCLUDE_DIRS BOOSTCONFIG_SEARCH_DIRS)

cmake/modules/FindOGLPLUS.cmake

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#
2+
# Try to find OGLPLUS include path.
3+
# Once done this will define
4+
#
5+
# OGLPLUS_INCLUDE_DIRS
6+
#
7+
# Created by Bradley Austin Davis on 2015/05/22
8+
# Copyright 2015 High Fidelity, Inc.
9+
#
10+
# Distributed under the Apache License, Version 2.0.
11+
# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
12+
#
13+
14+
# setup hints for OGLPLUS search
15+
include("${MACRO_DIR}/HifiLibrarySearchHints.cmake")
16+
hifi_library_search_hints("oglplus")
17+
18+
# locate header
19+
find_path(OGLPLUS_INCLUDE_DIRS "oglplus/fwd.hpp" HINTS ${OGLPLUS_SEARCH_DIRS})
20+
21+
include(FindPackageHandleStandardArgs)
22+
find_package_handle_standard_args(OGLPLUS DEFAULT_MSG OGLPLUS_INCLUDE_DIRS)
23+
24+
mark_as_advanced(OGLPLUS_INCLUDE_DIRS OGLPLUS_SEARCH_DIRS)

libraries/octree/src/ViewFrustum.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,17 @@
2727

2828
using namespace std;
2929

30-
ViewFrustum::ViewFrustum() {
31-
}
32-
3330
void ViewFrustum::setOrientation(const glm::quat& orientationAsQuaternion) {
3431
_orientation = orientationAsQuaternion;
3532
_right = glm::vec3(orientationAsQuaternion * glm::vec4(IDENTITY_RIGHT, 0.0f));
3633
_up = glm::vec3(orientationAsQuaternion * glm::vec4(IDENTITY_UP, 0.0f));
3734
_direction = glm::vec3(orientationAsQuaternion * glm::vec4(IDENTITY_FRONT, 0.0f));
35+
_view = glm::translate(mat4(), _position) * glm::mat4_cast(_orientation);
36+
}
37+
38+
void ViewFrustum::setPosition(const glm::vec3& position) {
39+
_position = position;
40+
_view = glm::translate(mat4(), _position) * glm::mat4_cast(_orientation);
3841
}
3942

4043
// Order cooresponds to the order defined in the BoxVertex enum.

libraries/octree/src/ViewFrustum.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,9 @@ const float DEFAULT_FAR_CLIP = (float)TREE_SCALE;
3636

3737
class ViewFrustum {
3838
public:
39-
ViewFrustum();
40-
4139
// setters for camera attributes
42-
void setPosition(const glm::vec3& p) { _position = p; }
43-
void setOrientation(const glm::quat& orientationAsQuaternion);
40+
void setPosition(const glm::vec3& position);
41+
void setOrientation(const glm::quat& orientation);
4442

4543
// getters for camera attributes
4644
const glm::vec3& getPosition() const { return _position; }
@@ -54,7 +52,8 @@ class ViewFrustum {
5452
void getFocalLength(float focalLength) { _focalLength = focalLength; }
5553

5654
// getters for lens attributes
57-
const glm::mat4 getProjection() const { return _projection; };
55+
const glm::mat4& getProjection() const { return _projection; };
56+
const glm::mat4& getView() const { return _view; };
5857
float getWidth() const { return _width; }
5958
float getHeight() const { return _height; }
6059
float getFieldOfView() const { return _fieldOfView; }
@@ -120,6 +119,7 @@ class ViewFrustum {
120119
// camera location/orientation attributes
121120
glm::vec3 _position; // the position in world-frame
122121
glm::quat _orientation;
122+
glm::mat4 _view;
123123

124124
// Lens attributes
125125
glm::mat4 _projection;
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
//
2+
// Created by Bradley Austin Davis on 2015/05/21
3+
// Copyright 2013 High Fidelity, Inc.
4+
//
5+
// Distributed under the Apache License, Version 2.0.
6+
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
7+
//
8+
9+
#include "GlWindow.h"
10+
11+
#include <QOpenGLContext>
12+
#include <QOpenGLDebugLogger>
13+
14+
static QSurfaceFormat getDefaultFormat() {
15+
QSurfaceFormat format;
16+
// Qt Quick may need a depth and stencil buffer. Always make sure these are available.
17+
format.setDepthBufferSize(16);
18+
format.setStencilBufferSize(8);
19+
format.setVersion(4, 1);
20+
#ifdef DEBUG
21+
format.setOption(QSurfaceFormat::DebugContext);
22+
#endif
23+
format.setProfile(QSurfaceFormat::OpenGLContextProfile::CompatibilityProfile);
24+
return format;
25+
}
26+
27+
GlWindow::GlWindow(QOpenGLContext * shareContext) : GlWindow(getDefaultFormat(), shareContext) {
28+
}
29+
30+
GlWindow::GlWindow(const QSurfaceFormat& format, QOpenGLContext * shareContext) {
31+
setSurfaceType(QSurface::OpenGLSurface);
32+
setFormat(format);
33+
_context = new QOpenGLContext;
34+
_context->setFormat(format);
35+
if (shareContext) {
36+
_context->setShareContext(shareContext);
37+
}
38+
_context->create();
39+
}
40+
41+
GlWindow::~GlWindow() {
42+
#ifdef DEBUG
43+
if (_logger) {
44+
makeCurrent();
45+
delete _logger;
46+
_logger = nullptr;
47+
}
48+
#endif
49+
_context->doneCurrent();
50+
_context->deleteLater();
51+
_context = nullptr;
52+
}
53+
54+
55+
void GlWindow::makeCurrent() {
56+
_context->makeCurrent(this);
57+
#ifdef DEBUG
58+
if (!_logger) {
59+
_logger = new QOpenGLDebugLogger(this);
60+
if (_logger->initialize()) {
61+
connect(_logger, &QOpenGLDebugLogger::messageLogged, [](const QOpenGLDebugMessage& message) {
62+
qDebug() << message;
63+
});
64+
_logger->disableMessages(QOpenGLDebugMessage::AnySource, QOpenGLDebugMessage::AnyType, QOpenGLDebugMessage::NotificationSeverity);
65+
_logger->startLogging(QOpenGLDebugLogger::LoggingMode::SynchronousLogging);
66+
}
67+
}
68+
#endif
69+
}
70+
71+
void GlWindow::doneCurrent() {
72+
_context->doneCurrent();
73+
}
74+
75+
void GlWindow::swapBuffers() {
76+
_context->swapBuffers(this);
77+
}
78+

libraries/render-utils/src/GlWindow.h

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//
2+
// Created by Bradley Austin Davis on 2015/05/21
3+
// Copyright 2013 High Fidelity, Inc.
4+
//
5+
// Distributed under the Apache License, Version 2.0.
6+
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
7+
//
8+
9+
#pragma once
10+
#ifndef hifi_GlWindow_h
11+
#define hifi_GlWindow_h
12+
13+
#include <QWindow>
14+
#include <QSurfaceFormat>
15+
16+
class QOpenGLContext;
17+
class QOpenGLDebugLogger;
18+
19+
class GlWindow : public QWindow {
20+
public:
21+
GlWindow(QOpenGLContext * shareContext = nullptr);
22+
GlWindow(const QSurfaceFormat& format, QOpenGLContext * shareContext = nullptr);
23+
virtual ~GlWindow();
24+
void makeCurrent();
25+
void doneCurrent();
26+
void swapBuffers();
27+
private:
28+
QOpenGLContext * _context{ nullptr };
29+
#ifdef DEBUG
30+
QOpenGLDebugLogger * _logger{ nullptr };
31+
#endif
32+
};
33+
34+
#endif

libraries/render-utils/src/OffscreenGlCanvas.cpp

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212

1313
#include "OffscreenGlCanvas.h"
14+
#include <QOpenGLDebugLogger>
1415

1516
OffscreenGlCanvas::OffscreenGlCanvas() {
1617
}
@@ -27,16 +28,35 @@ void OffscreenGlCanvas::create(QOpenGLContext* sharedContext) {
2728
format.setMajorVersion(4);
2829
format.setMinorVersion(1);
2930
format.setProfile(QSurfaceFormat::OpenGLContextProfile::CompatibilityProfile);
31+
#ifdef DEBUG
32+
format.setOption(QSurfaceFormat::DebugContext);
33+
#endif
3034
_context.setFormat(format);
3135
}
3236
_context.create();
3337

3438
_offscreenSurface.setFormat(_context.format());
3539
_offscreenSurface.create();
40+
3641
}
3742

3843
bool OffscreenGlCanvas::makeCurrent() {
39-
return _context.makeCurrent(&_offscreenSurface);
44+
bool result = _context.makeCurrent(&_offscreenSurface);
45+
46+
#ifdef DEBUG
47+
if (result && !_logger) {
48+
_logger = new QOpenGLDebugLogger(this);
49+
if (_logger->initialize()) {
50+
connect(_logger, &QOpenGLDebugLogger::messageLogged, [](const QOpenGLDebugMessage& message) {
51+
qDebug() << message;
52+
});
53+
_logger->disableMessages(QOpenGLDebugMessage::AnySource, QOpenGLDebugMessage::AnyType, QOpenGLDebugMessage::NotificationSeverity);
54+
_logger->startLogging(QOpenGLDebugLogger::LoggingMode::SynchronousLogging);
55+
}
56+
}
57+
#endif
58+
59+
return result;
4060
}
4161

4262
void OffscreenGlCanvas::doneCurrent() {

libraries/render-utils/src/OffscreenGlCanvas.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,24 @@
1515
#include <QOpenGLContext>
1616
#include <QOffscreenSurface>
1717

18+
class QOpenGLDebugLogger;
19+
1820
class OffscreenGlCanvas : public QObject {
1921
public:
2022
OffscreenGlCanvas();
2123
void create(QOpenGLContext* sharedContext = nullptr);
2224
bool makeCurrent();
2325
void doneCurrent();
26+
QOpenGLContext* getContext() {
27+
return &_context;
28+
}
2429

2530
protected:
2631
QOpenGLContext _context;
2732
QOffscreenSurface _offscreenSurface;
33+
#ifdef DEBUG
34+
QOpenGLDebugLogger * _logger{ nullptr };
35+
#endif
2836

2937
};
3038

libraries/render-utils/src/OffscreenGlContext.cpp

Lines changed: 0 additions & 43 deletions
This file was deleted.

0 commit comments

Comments
 (0)