mirror of
https://github.com/lubosz/overte.git
synced 2025-04-23 16:14:01 +02:00
Working on decoupling rendering
This commit is contained in:
parent
fe482b35ff
commit
9f0d410387
64 changed files with 1703 additions and 412 deletions
|
@ -36,8 +36,22 @@ endif ()
|
|||
configure_file(InterfaceConfig.h.in "${PROJECT_BINARY_DIR}/includes/InterfaceConfig.h")
|
||||
configure_file(InterfaceVersion.h.in "${PROJECT_BINARY_DIR}/includes/InterfaceVersion.h")
|
||||
|
||||
|
||||
macro(GroupSources curdir)
|
||||
file(GLOB children RELATIVE ${PROJECT_SOURCE_DIR}/${curdir} ${PROJECT_SOURCE_DIR}/${curdir}/*)
|
||||
foreach(child ${children})
|
||||
if(IS_DIRECTORY ${PROJECT_SOURCE_DIR}/${curdir}/${child})
|
||||
GroupSources(${curdir}/${child})
|
||||
else()
|
||||
string(REPLACE "/" "\\" groupname ${curdir})
|
||||
source_group(${groupname} FILES ${PROJECT_SOURCE_DIR}/${curdir}/${child})
|
||||
endif()
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
# grab the implementation and header files from src dirs
|
||||
file(GLOB_RECURSE INTERFACE_SRCS "src/*.cpp" "src/*.h")
|
||||
GroupSources("src")
|
||||
|
||||
# Add SpeechRecognizer if on Windows or OS X, otherwise remove
|
||||
if (WIN32)
|
||||
|
@ -54,10 +68,14 @@ else ()
|
|||
list(REMOVE_ITEM INTERFACE_SRCS ${SPEECHRECOGNIZER_CPP})
|
||||
endif ()
|
||||
|
||||
find_package(Qt5 COMPONENTS Gui Multimedia Network OpenGL Script Svg WebKitWidgets)
|
||||
find_package(Qt5 COMPONENTS Gui Multimedia Network OpenGL Qml Quick Script Svg WebKitWidgets)
|
||||
|
||||
# grab the ui files in resources/ui
|
||||
file (GLOB_RECURSE QT_UI_FILES ui/*.ui)
|
||||
source_group("UI Files" FILES ${QT_UI_FILES})
|
||||
|
||||
|
||||
|
||||
# have qt5 wrap them and generate the appropriate header files
|
||||
qt5_wrap_ui(QT_UI_HEADERS "${QT_UI_FILES}")
|
||||
|
||||
|
|
|
@ -267,6 +267,7 @@ bool setupEssentials(int& argc, char** argv) {
|
|||
Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
||||
QApplication(argc, argv),
|
||||
_dependencyManagerIsSetup(setupEssentials(argc, argv)),
|
||||
_offscreenContext(new OffscreenGlContext()),
|
||||
_window(new MainWindow(desktop())),
|
||||
_toolWindow(NULL),
|
||||
_friendsWindow(NULL),
|
||||
|
@ -476,18 +477,14 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
|||
|
||||
ResourceCache::setRequestLimit(3);
|
||||
|
||||
_window->setCentralWidget(_glWidget);
|
||||
|
||||
_window->setCentralWidget(new QWidget());
|
||||
_window->restoreGeometry();
|
||||
|
||||
_window->setVisible(true);
|
||||
_glWidget->setFocusPolicy(Qt::StrongFocus);
|
||||
_glWidget->setFocus();
|
||||
|
||||
// enable mouse tracking; otherwise, we only get drag events
|
||||
_glWidget->setMouseTracking(true);
|
||||
|
||||
#if 0
|
||||
_fullscreenMenuWidget->setParent(_glWidget);
|
||||
#endif
|
||||
|
||||
_menuBarHeight = Menu::getInstance()->height();
|
||||
if (Menu::getInstance()->isOptionChecked(MenuOption::Fullscreen)) {
|
||||
setFullscreen(true); // Initialize menu bar show/hide
|
||||
|
@ -497,6 +494,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
|||
_toolWindow->setWindowFlags(_toolWindow->windowFlags() | Qt::WindowStaysOnTopHint);
|
||||
_toolWindow->setWindowTitle("Tools");
|
||||
|
||||
_offscreenContext->create();
|
||||
_offscreenContext->makeCurrent();
|
||||
initializeGL();
|
||||
// initialization continues in initializeGL when OpenGL context is ready
|
||||
|
||||
// Tell our entity edit sender about our known jurisdictions
|
||||
|
@ -629,9 +629,8 @@ Application::~Application() {
|
|||
_myAvatar = NULL;
|
||||
|
||||
ModelEntityItem::cleanupLoadedAnimations();
|
||||
|
||||
// stop the glWidget frame timer so it doesn't call paintGL
|
||||
_glWidget->stopFrameTimer();
|
||||
|
||||
getActiveRenderPlugin()->deactivate();
|
||||
|
||||
DependencyManager::destroy<AvatarManager>();
|
||||
DependencyManager::destroy<AnimationCache>();
|
||||
|
@ -732,19 +731,14 @@ void Application::paintGL() {
|
|||
bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
|
||||
PerformanceWarning warn(showWarnings, "Application::paintGL()");
|
||||
|
||||
// Set the desired FBO texture size. If it hasn't changed, this does nothing.
|
||||
// Otherwise, it must rebuild the FBOs
|
||||
if (OculusManager::isConnected()) {
|
||||
DependencyManager::get<TextureCache>()->setFrameBufferSize(OculusManager::getRenderTargetSize());
|
||||
} else {
|
||||
QSize fbSize = _glWidget->getDeviceSize() * getRenderResolutionScale();
|
||||
DependencyManager::get<TextureCache>()->setFrameBufferSize(fbSize);
|
||||
}
|
||||
_offscreenContext->makeCurrent();
|
||||
QSize fbSize = getActiveRenderPlugin()->getRecommendedFramebufferSize() * getRenderResolutionScale();
|
||||
DependencyManager::get<TextureCache>()->setFrameBufferSize(fbSize);
|
||||
|
||||
glEnable(GL_LINE_SMOOTH);
|
||||
|
||||
if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON) {
|
||||
if (!OculusManager::isConnected()) {
|
||||
if (!getActiveRenderPlugin()->isHmd()) {
|
||||
// If there isn't an HMD, match exactly to avatar's head
|
||||
_myCamera.setPosition(_myAvatar->getHead()->getEyePosition());
|
||||
_myCamera.setRotation(_myAvatar->getHead()->getCameraOrientation());
|
||||
|
@ -753,17 +747,15 @@ void Application::paintGL() {
|
|||
_myCamera.setPosition(_myAvatar->getDefaultEyePosition());
|
||||
_myCamera.setRotation(_myAvatar->getWorldAlignedOrientation());
|
||||
}
|
||||
|
||||
} else if (_myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) {
|
||||
static const float THIRD_PERSON_CAMERA_DISTANCE = 1.5f;
|
||||
_myCamera.setPosition(_myAvatar->getDefaultEyePosition() +
|
||||
_myAvatar->getOrientation() * glm::vec3(0.0f, 0.0f, 1.0f) * THIRD_PERSON_CAMERA_DISTANCE * _myAvatar->getScale());
|
||||
if (OculusManager::isConnected()) {
|
||||
if (getActiveRenderPlugin()->isHmd()) {
|
||||
_myCamera.setRotation(_myAvatar->getWorldAlignedOrientation());
|
||||
} else {
|
||||
_myCamera.setRotation(_myAvatar->getHead()->getOrientation());
|
||||
}
|
||||
|
||||
} else if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
|
||||
_myCamera.setRotation(_myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f)));
|
||||
_myCamera.setPosition(_myAvatar->getDefaultEyePosition() +
|
||||
|
@ -772,30 +764,17 @@ void Application::paintGL() {
|
|||
glm::vec3(0.0f, 0.0f, -1.0f) * MIRROR_FULLSCREEN_DISTANCE * _scaleMirror);
|
||||
}
|
||||
|
||||
// Update camera position
|
||||
if (!OculusManager::isConnected()) {
|
||||
_myCamera.update(1.0f / _fps);
|
||||
}
|
||||
|
||||
if (getShadowsEnabled()) {
|
||||
updateShadowMap();
|
||||
}
|
||||
|
||||
if (OculusManager::isConnected()) {
|
||||
//When in mirror mode, use camera rotation. Otherwise, use body rotation
|
||||
if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
|
||||
OculusManager::display(_myCamera.getRotation(), _myCamera.getPosition(), _myCamera);
|
||||
} else {
|
||||
OculusManager::display(_myAvatar->getWorldAlignedOrientation(), _myAvatar->getDefaultEyePosition(), _myCamera);
|
||||
}
|
||||
_myCamera.update(1.0f / _fps);
|
||||
DependencyManager::get<GlowEffect>()->prepare();
|
||||
|
||||
} else if (TV3DManager::isConnected()) {
|
||||
|
||||
TV3DManager::display(_myCamera);
|
||||
|
||||
} else {
|
||||
DependencyManager::get<GlowEffect>()->prepare();
|
||||
// Primary rendering pass
|
||||
auto primaryFbo = DependencyManager::get<TextureCache>()->getPrimaryFramebufferObject();
|
||||
primaryFbo->bind();
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
// Viewport is assigned to the size of the framebuffer
|
||||
QSize size = DependencyManager::get<TextureCache>()->getPrimaryFramebufferObject()->size();
|
||||
|
@ -809,20 +788,32 @@ void Application::paintGL() {
|
|||
|
||||
if (Menu::getInstance()->isOptionChecked(MenuOption::FullscreenMirror)) {
|
||||
_rearMirrorTools->render(true);
|
||||
|
||||
} else if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) {
|
||||
renderRearViewMirror(_mirrorViewRect);
|
||||
}
|
||||
|
||||
DependencyManager::get<GlowEffect>()->render();
|
||||
|
||||
{
|
||||
PerformanceTimer perfTimer("renderOverlay");
|
||||
_applicationOverlay.renderOverlay(true);
|
||||
_applicationOverlay.displayOverlayTexture();
|
||||
renderRearViewMirror(_mirrorViewRect);
|
||||
}
|
||||
}
|
||||
primaryFbo->release();
|
||||
|
||||
QOpenGLFramebufferObject * finalFbo = DependencyManager::get<GlowEffect>()->render();
|
||||
// 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
|
||||
// once we have multi-threaded rendering, this will almost certainly be critical,
|
||||
// but may be better handled with a fence object
|
||||
glFinish();
|
||||
|
||||
#if 0
|
||||
{
|
||||
PerformanceTimer perfTimer("renderOverlay");
|
||||
_applicationOverlay.renderOverlay();
|
||||
_applicationOverlay.displayOverlayTexture();
|
||||
}
|
||||
#endif
|
||||
|
||||
_offscreenContext->doneCurrent();
|
||||
Q_ASSERT(!QOpenGLContext::currentContext());
|
||||
getActiveRenderPlugin()->render(finalFbo->texture());
|
||||
Q_ASSERT(!QOpenGLContext::currentContext());
|
||||
_offscreenContext->makeCurrent();
|
||||
_frameCount++;
|
||||
}
|
||||
|
||||
|
@ -845,14 +836,23 @@ void Application::showEditEntitiesHelp() {
|
|||
}
|
||||
|
||||
void Application::resetCamerasOnResizeGL(Camera& camera, int width, int height) {
|
||||
#if 0
|
||||
if (OculusManager::isConnected()) {
|
||||
OculusManager::configureCamera(camera, width, height);
|
||||
} else if (TV3DManager::isConnected()) {
|
||||
TV3DManager::configureCamera(camera, width, height);
|
||||
} else {
|
||||
#endif
|
||||
camera.setAspectRatio((float)width / height);
|
||||
camera.setFieldOfView(_fieldOfView.get());
|
||||
#if 0
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void Application::resizeEvent(QResizeEvent * event) {
|
||||
const QSize & newSize = event->size();
|
||||
resizeGL(newSize.width(), newSize.height());
|
||||
}
|
||||
|
||||
void Application::resizeGL(int width, int height) {
|
||||
|
@ -911,6 +911,43 @@ bool Application::importSVOFromURL(const QString& urlString) {
|
|||
}
|
||||
|
||||
bool Application::event(QEvent* event) {
|
||||
switch (event->type()) {
|
||||
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;
|
||||
}
|
||||
|
||||
// handle custom URL
|
||||
if (event->type() == QEvent::FileOpen) {
|
||||
|
@ -1102,9 +1139,11 @@ void Application::keyPressEvent(QKeyEvent* event) {
|
|||
case Qt::Key_J:
|
||||
if (isShifted) {
|
||||
_viewFrustum.setFocalLength(_viewFrustum.getFocalLength() - 0.1f);
|
||||
#if 0
|
||||
if (TV3DManager::isConnected()) {
|
||||
TV3DManager::configureCamera(_myCamera, _glWidget->getDeviceWidth(), _glWidget->getDeviceHeight());
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
_myCamera.setEyeOffsetPosition(_myCamera.getEyeOffsetPosition() + glm::vec3(-0.001, 0, 0));
|
||||
}
|
||||
|
@ -1114,10 +1153,11 @@ void Application::keyPressEvent(QKeyEvent* event) {
|
|||
case Qt::Key_M:
|
||||
if (isShifted) {
|
||||
_viewFrustum.setFocalLength(_viewFrustum.getFocalLength() + 0.1f);
|
||||
#if 0
|
||||
if (TV3DManager::isConnected()) {
|
||||
TV3DManager::configureCamera(_myCamera, _glWidget->getDeviceWidth(), _glWidget->getDeviceHeight());
|
||||
}
|
||||
|
||||
#endif
|
||||
} else {
|
||||
_myCamera.setEyeOffsetPosition(_myCamera.getEyeOffsetPosition() + glm::vec3(0.001, 0, 0));
|
||||
}
|
||||
|
@ -1168,17 +1208,14 @@ void Application::keyPressEvent(QKeyEvent* event) {
|
|||
case Qt::Key_Space: {
|
||||
if (!event->isAutoRepeat()) {
|
||||
// this starts an HFActionEvent
|
||||
HFActionEvent startActionEvent(HFActionEvent::startType(),
|
||||
_myCamera.computePickRay(getTrueMouseX(),
|
||||
getTrueMouseY()));
|
||||
HFActionEvent startActionEvent(HFActionEvent::startType(), computePickRay());
|
||||
sendEvent(this, &startActionEvent);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case Qt::Key_Escape: {
|
||||
OculusManager::abandonCalibration();
|
||||
|
||||
getActiveRenderPlugin()->abandonCalibration();
|
||||
if (!event->isAutoRepeat()) {
|
||||
// this starts the HFCancelEvent
|
||||
HFBackEvent startBackEvent(HFBackEvent::startType());
|
||||
|
@ -1266,9 +1303,7 @@ void Application::keyReleaseEvent(QKeyEvent* event) {
|
|||
case Qt::Key_Space: {
|
||||
if (!event->isAutoRepeat()) {
|
||||
// this ends the HFActionEvent
|
||||
HFActionEvent endActionEvent(HFActionEvent::endType(),
|
||||
_myCamera.computePickRay(getTrueMouseX(),
|
||||
getTrueMouseY()));
|
||||
HFActionEvent endActionEvent(HFActionEvent::endType(), computePickRay());
|
||||
sendEvent(this, &endActionEvent);
|
||||
}
|
||||
break;
|
||||
|
@ -1362,7 +1397,7 @@ void Application::mousePressEvent(QMouseEvent* event, unsigned int deviceID) {
|
|||
|
||||
// nobody handled this - make it an action event on the _window object
|
||||
HFActionEvent actionEvent(HFActionEvent::startType(),
|
||||
_myCamera.computePickRay(event->x(), event->y()));
|
||||
computePickRay(event->x(), event->y()));
|
||||
sendEvent(this, &actionEvent);
|
||||
|
||||
} else if (event->button() == Qt::RightButton) {
|
||||
|
@ -1397,7 +1432,7 @@ void Application::mouseReleaseEvent(QMouseEvent* event, unsigned int deviceID) {
|
|||
|
||||
// fire an action end event
|
||||
HFActionEvent actionEvent(HFActionEvent::endType(),
|
||||
_myCamera.computePickRay(event->x(), event->y()));
|
||||
computePickRay(event->x(), event->y()));
|
||||
sendEvent(this, &actionEvent);
|
||||
}
|
||||
}
|
||||
|
@ -1569,11 +1604,13 @@ void Application::idle() {
|
|||
const float BIGGEST_DELTA_TIME_SECS = 0.25f;
|
||||
update(glm::clamp((float)timeSinceLastUpdate / 1000.0f, 0.0f, BIGGEST_DELTA_TIME_SECS));
|
||||
}
|
||||
|
||||
{
|
||||
PerformanceTimer perfTimer("updateGL");
|
||||
PerformanceWarning warn(showWarnings, "Application::idle()... updateGL()");
|
||||
_glWidget->updateGL();
|
||||
getActiveRenderPlugin()->idle();
|
||||
}
|
||||
|
||||
{
|
||||
PerformanceTimer perfTimer("rest");
|
||||
PerformanceWarning warn(showWarnings, "Application::idle()... rest of it");
|
||||
|
@ -1653,11 +1690,15 @@ void Application::setFullscreen(bool fullscreen) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void Application::setEnable3DTVMode(bool enable3DTVMode) {
|
||||
#if 0
|
||||
resizeGL(_glWidget->getDeviceWidth(), _glWidget->getDeviceHeight());
|
||||
#endif
|
||||
}
|
||||
|
||||
void Application::setEnableVRMode(bool enableVRMode) {
|
||||
#if 0
|
||||
if (Menu::getInstance()->isOptionChecked(MenuOption::EnableVRMode) != enableVRMode) {
|
||||
Menu::getInstance()->getActionForOption(MenuOption::EnableVRMode)->setChecked(enableVRMode);
|
||||
}
|
||||
|
@ -1682,6 +1723,7 @@ void Application::setEnableVRMode(bool enableVRMode) {
|
|||
resizeGL(_glWidget->getDeviceWidth(), _glWidget->getDeviceHeight());
|
||||
|
||||
updateCursorVisibility();
|
||||
#endif
|
||||
}
|
||||
|
||||
void Application::setLowVelocityFilter(bool lowVelocityFilter) {
|
||||
|
@ -1689,44 +1731,36 @@ void Application::setLowVelocityFilter(bool lowVelocityFilter) {
|
|||
}
|
||||
|
||||
bool Application::mouseOnScreen() const {
|
||||
if (OculusManager::isConnected()) {
|
||||
return getMouseX() >= 0 && getMouseX() <= _glWidget->getDeviceWidth() &&
|
||||
getMouseY() >= 0 && getMouseY() <= _glWidget->getDeviceHeight();
|
||||
}
|
||||
return true;
|
||||
return getActiveRenderPlugin()->isMouseOnScreen();
|
||||
}
|
||||
|
||||
int Application::getMouseX() const {
|
||||
if (OculusManager::isConnected()) {
|
||||
glm::vec2 pos = _applicationOverlay.screenToOverlay(glm::vec2(getTrueMouseX(), getTrueMouseY()));
|
||||
return pos.x;
|
||||
}
|
||||
return getTrueMouseX();
|
||||
return getActiveRenderPlugin()->getUiMousePosition().x;
|
||||
}
|
||||
|
||||
int Application::getMouseY() const {
|
||||
if (OculusManager::isConnected()) {
|
||||
glm::vec2 pos = _applicationOverlay.screenToOverlay(glm::vec2(getTrueMouseX(), getTrueMouseY()));
|
||||
return pos.y;
|
||||
}
|
||||
return getTrueMouseY();
|
||||
return getActiveRenderPlugin()->getUiMousePosition().x;
|
||||
}
|
||||
|
||||
int Application::getMouseDragStartedX() const {
|
||||
#if 0
|
||||
if (OculusManager::isConnected()) {
|
||||
glm::vec2 pos = _applicationOverlay.screenToOverlay(glm::vec2(getTrueMouseDragStartedX(),
|
||||
getTrueMouseDragStartedY()));
|
||||
return pos.x;
|
||||
}
|
||||
#endif
|
||||
return getTrueMouseDragStartedX();
|
||||
}
|
||||
|
||||
int Application::getMouseDragStartedY() const {
|
||||
#if 0
|
||||
if (OculusManager::isConnected()) {
|
||||
glm::vec2 pos = _applicationOverlay.screenToOverlay(glm::vec2(getTrueMouseDragStartedX(),
|
||||
getTrueMouseDragStartedY()));
|
||||
return pos.y;
|
||||
}
|
||||
#endif
|
||||
return getTrueMouseDragStartedY();
|
||||
}
|
||||
|
||||
|
@ -1878,6 +1912,7 @@ void Application::init() {
|
|||
|
||||
_mirrorCamera.setMode(CAMERA_MODE_MIRROR);
|
||||
|
||||
#if 0
|
||||
OculusManager::connect();
|
||||
if (OculusManager::isConnected()) {
|
||||
QMetaObject::invokeMethod(Menu::getInstance()->getActionForOption(MenuOption::Fullscreen),
|
||||
|
@ -1891,6 +1926,7 @@ void Application::init() {
|
|||
"trigger",
|
||||
Qt::QueuedConnection);
|
||||
}
|
||||
#endif
|
||||
|
||||
_timerStart.start();
|
||||
_lastTimeUpdated.start();
|
||||
|
@ -1955,19 +1991,20 @@ void Application::init() {
|
|||
_entityClipboardRenderer.setViewFrustum(getViewFrustum());
|
||||
_entityClipboardRenderer.setTree(&_entityClipboard);
|
||||
|
||||
_rearMirrorTools = new RearMirrorTools(_glWidget, _mirrorViewRect);
|
||||
_rearMirrorTools = new RearMirrorTools(_mirrorViewRect);
|
||||
|
||||
connect(_rearMirrorTools, SIGNAL(closeView()), SLOT(closeMirrorView()));
|
||||
connect(_rearMirrorTools, SIGNAL(restoreView()), SLOT(restoreMirrorView()));
|
||||
connect(_rearMirrorTools, SIGNAL(shrinkView()), SLOT(shrinkMirrorView()));
|
||||
connect(_rearMirrorTools, SIGNAL(resetView()), SLOT(resetSensors()));
|
||||
|
||||
#if 0
|
||||
// make sure our texture cache knows about window size changes
|
||||
DependencyManager::get<TextureCache>()->associateWithWidget(_glWidget);
|
||||
#endif
|
||||
|
||||
// initialize the GlowEffect with our widget
|
||||
DependencyManager::get<GlowEffect>()->init(_glWidget,
|
||||
Menu::getInstance()->isOptionChecked(MenuOption::EnableGlowEffect));
|
||||
DependencyManager::get<GlowEffect>()->init(Menu::getInstance()->isOptionChecked(MenuOption::EnableGlowEffect));
|
||||
}
|
||||
|
||||
void Application::closeMirrorView() {
|
||||
|
@ -2018,7 +2055,7 @@ void Application::updateMouseRay() {
|
|||
// make sure the frustum is up-to-date
|
||||
loadViewFrustum(_myCamera, _viewFrustum);
|
||||
|
||||
PickRay pickRay = _myCamera.computePickRay(getTrueMouseX(), getTrueMouseY());
|
||||
PickRay pickRay = computePickRay();
|
||||
_mouseRayOrigin = pickRay.origin;
|
||||
_mouseRayDirection = pickRay.direction;
|
||||
|
||||
|
@ -2043,6 +2080,7 @@ void Application::updateMyAvatarLookAtPosition() {
|
|||
bool isLookingAtSomeone = false;
|
||||
glm::vec3 lookAtSpot;
|
||||
if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
|
||||
#if 0
|
||||
// When I am in mirror mode, just look right at the camera (myself)
|
||||
if (!OculusManager::isConnected()) {
|
||||
lookAtSpot = _myCamera.getPosition();
|
||||
|
@ -2053,7 +2091,7 @@ void Application::updateMyAvatarLookAtPosition() {
|
|||
lookAtSpot = OculusManager::getRightEyePosition();
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
} else {
|
||||
AvatarSharedPointer lookingAt = _myAvatar->getLookAtTargetAvatar().toStrongRef();
|
||||
if (lookingAt && _myAvatar != lookingAt.data()) {
|
||||
|
@ -2138,6 +2176,7 @@ void Application::updateCamera(float deltaTime) {
|
|||
bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
|
||||
PerformanceWarning warn(showWarnings, "Application::updateCamera()");
|
||||
|
||||
#if 0
|
||||
if (!OculusManager::isConnected() && !TV3DManager::isConnected() &&
|
||||
Menu::getInstance()->isOptionChecked(MenuOption::OffAxisProjection)) {
|
||||
FaceTracker* tracker = getActiveFaceTracker();
|
||||
|
@ -2149,6 +2188,8 @@ void Application::updateCamera(float deltaTime) {
|
|||
updateProjectionMatrix();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void Application::updateDialogs(float deltaTime) {
|
||||
|
@ -2239,13 +2280,13 @@ void Application::update(float deltaTime) {
|
|||
PerformanceTimer perfTimer("overlays");
|
||||
_overlays.update(deltaTime);
|
||||
}
|
||||
|
||||
#if 0
|
||||
{
|
||||
PerformanceTimer perfTimer("myAvatar");
|
||||
updateMyAvatarLookAtPosition();
|
||||
DependencyManager::get<AvatarManager>()->updateMyAvatar(deltaTime); // Sample hardware, update view frustum if needed, and send avatar data to mixer/nodes
|
||||
}
|
||||
|
||||
#endif
|
||||
{
|
||||
PerformanceTimer perfTimer("emitSimulating");
|
||||
// let external parties know we're updating
|
||||
|
@ -2561,16 +2602,12 @@ void Application::queryOctree(NodeType_t serverType, PacketType packetType, Node
|
|||
}
|
||||
|
||||
bool Application::isHMDMode() const {
|
||||
if (OculusManager::isConnected()) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return getActiveRenderPlugin()->isHmd();
|
||||
}
|
||||
|
||||
QRect Application::getDesirableApplicationGeometry() {
|
||||
QRect applicationGeometry = getWindow()->geometry();
|
||||
|
||||
#if 0
|
||||
// If our parent window is on the HMD, then don't use its geometry, instead use
|
||||
// the "main screen" geometry.
|
||||
HMDToolsDialog* hmdTools = DependencyManager::get<DialogsManager>()->getHMDToolsDialog();
|
||||
|
@ -2588,6 +2625,7 @@ QRect Application::getDesirableApplicationGeometry() {
|
|||
applicationGeometry = betterScreen->geometry();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return applicationGeometry;
|
||||
}
|
||||
|
||||
|
@ -2786,8 +2824,6 @@ void Application::updateShadowMap() {
|
|||
}
|
||||
|
||||
fbo->release();
|
||||
|
||||
glViewport(0, 0, _glWidget->getDeviceWidth(), _glWidget->getDeviceHeight());
|
||||
activeRenderingThread = nullptr;
|
||||
}
|
||||
|
||||
|
@ -2826,10 +2862,6 @@ int Application::getBoundaryLevelAdjust() const {
|
|||
return DependencyManager::get<LODManager>()->getBoundaryLevelAdjust();
|
||||
}
|
||||
|
||||
PickRay Application::computePickRay(float x, float y) {
|
||||
return getCamera()->computePickRay(x, y);
|
||||
}
|
||||
|
||||
QImage Application::renderAvatarBillboard() {
|
||||
DependencyManager::get<TextureCache>()->getPrimaryFramebufferObject()->bind();
|
||||
|
||||
|
@ -2837,9 +2869,11 @@ QImage Application::renderAvatarBillboard() {
|
|||
Glower glower;
|
||||
|
||||
const int BILLBOARD_SIZE = 64;
|
||||
#if 0
|
||||
renderRearViewMirror(QRect(0, _glWidget->getDeviceHeight() - BILLBOARD_SIZE,
|
||||
BILLBOARD_SIZE, BILLBOARD_SIZE),
|
||||
true);
|
||||
#endif
|
||||
|
||||
QImage image(BILLBOARD_SIZE, BILLBOARD_SIZE, QImage::Format_ARGB32);
|
||||
glReadPixels(0, 0, BILLBOARD_SIZE, BILLBOARD_SIZE, GL_BGRA, GL_UNSIGNED_BYTE, image.bits());
|
||||
|
@ -3130,12 +3164,13 @@ void Application::computeOffAxisFrustum(float& left, float& right, float& bottom
|
|||
|
||||
// allow 3DTV/Oculus to override parameters from camera
|
||||
_displayViewFrustum.computeOffAxisFrustum(left, right, bottom, top, nearVal, farVal, nearClipPlane, farClipPlane);
|
||||
#if 0
|
||||
if (OculusManager::isConnected()) {
|
||||
OculusManager::overrideOffAxisFrustum(left, right, bottom, top, nearVal, farVal, nearClipPlane, farClipPlane);
|
||||
|
||||
} else if (TV3DManager::isConnected()) {
|
||||
TV3DManager::overrideOffAxisFrustum(left, right, bottom, top, nearVal, farVal, nearClipPlane, farClipPlane);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
bool Application::getShadowsEnabled() {
|
||||
|
@ -3148,32 +3183,6 @@ bool Application::getCascadeShadowsEnabled() {
|
|||
return Menu::getInstance()->isOptionChecked(MenuOption::CascadedShadows);
|
||||
}
|
||||
|
||||
glm::vec2 Application::getScaledScreenPoint(glm::vec2 projectedPoint) {
|
||||
float horizontalScale = _glWidget->getDeviceWidth() / 2.0f;
|
||||
float verticalScale = _glWidget->getDeviceHeight() / 2.0f;
|
||||
|
||||
// -1,-1 is 0,windowHeight
|
||||
// 1,1 is windowWidth,0
|
||||
|
||||
// -1,1 1,1
|
||||
// +-----------------------+
|
||||
// | | |
|
||||
// | | |
|
||||
// | -1,0 | |
|
||||
// |-----------+-----------|
|
||||
// | 0,0 |
|
||||
// | | |
|
||||
// | | |
|
||||
// | | |
|
||||
// +-----------------------+
|
||||
// -1,-1 1,-1
|
||||
|
||||
glm::vec2 screenPoint((projectedPoint.x + 1.0) * horizontalScale,
|
||||
((projectedPoint.y + 1.0) * -verticalScale) + _glWidget->getDeviceHeight());
|
||||
|
||||
return screenPoint;
|
||||
}
|
||||
|
||||
void Application::renderRearViewMirror(const QRect& region, bool billboard) {
|
||||
// Grab current viewport to reset it at the end
|
||||
int viewport[4];
|
||||
|
@ -3214,7 +3223,6 @@ void Application::renderRearViewMirror(const QRect& region, bool billboard) {
|
|||
_mirrorCamera.setAspectRatio((float)region.width() / region.height());
|
||||
|
||||
_mirrorCamera.setRotation(_myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI, 0.0f)));
|
||||
_mirrorCamera.update(1.0f/_fps);
|
||||
|
||||
// set the bounds of rear mirror view
|
||||
if (billboard) {
|
||||
|
@ -3254,15 +3262,19 @@ void Application::resetSensors() {
|
|||
DependencyManager::get<Visage>()->reset();
|
||||
DependencyManager::get<DdeFaceTracker>()->reset();
|
||||
|
||||
getActiveRenderPlugin()->resetSensors();
|
||||
#if 0
|
||||
OculusManager::reset();
|
||||
#endif
|
||||
|
||||
//_leapmotion.reset();
|
||||
|
||||
#if 0
|
||||
QScreen* currentScreen = _window->windowHandle()->screen();
|
||||
QWindow* mainWindow = _window->windowHandle();
|
||||
QPoint windowCenter = mainWindow->geometry().center();
|
||||
_glWidget->cursor().setPos(currentScreen, windowCenter);
|
||||
|
||||
#endif
|
||||
_myAvatar->reset();
|
||||
|
||||
QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(), "reset", Qt::QueuedConnection);
|
||||
|
@ -4021,7 +4033,7 @@ void Application::setPreviousScriptLocation(const QString& previousScriptLocatio
|
|||
|
||||
void Application::loadDialog() {
|
||||
|
||||
QString fileNameString = QFileDialog::getOpenFileName(_glWidget,
|
||||
QString fileNameString = QFileDialog::getOpenFileName(desktop(),
|
||||
tr("Open Script"),
|
||||
getPreviousScriptLocation(),
|
||||
tr("JavaScript Files (*.js)"));
|
||||
|
@ -4062,7 +4074,7 @@ void Application::setScriptsLocation(const QString& scriptsLocation) {
|
|||
|
||||
void Application::toggleLogDialog() {
|
||||
if (! _logDialog) {
|
||||
_logDialog = new LogDialog(_glWidget, getLogger());
|
||||
_logDialog = new LogDialog(desktop(), getLogger());
|
||||
}
|
||||
|
||||
if (_logDialog->isVisible()) {
|
||||
|
@ -4119,7 +4131,7 @@ void Application::parseVersionXml() {
|
|||
}
|
||||
|
||||
if (!shouldSkipVersion(latestVersion) && applicationVersion() != latestVersion) {
|
||||
new UpdateDialog(_glWidget, releaseNotes, latestVersion, downloadUrl);
|
||||
new UpdateDialog(desktop(), releaseNotes, latestVersion, downloadUrl);
|
||||
}
|
||||
sender->deleteLater();
|
||||
}
|
||||
|
@ -4152,7 +4164,7 @@ void Application::takeSnapshot() {
|
|||
}
|
||||
|
||||
if (!_snapshotShareDialog) {
|
||||
_snapshotShareDialog = new SnapshotShareDialog(fileName, _glWidget);
|
||||
_snapshotShareDialog = new SnapshotShareDialog(fileName, desktop());
|
||||
}
|
||||
_snapshotShareDialog->show();
|
||||
}
|
||||
|
@ -4330,3 +4342,90 @@ void Application::friendsWindowClosed() {
|
|||
delete _friendsWindow;
|
||||
_friendsWindow = NULL;
|
||||
}
|
||||
|
||||
|
||||
PickRay Application::computePickRay() const {
|
||||
return computePickRay(getTrueMouseX(), getTrueMouseY());
|
||||
}
|
||||
|
||||
PickRay Application::computeViewPickRay(float xRatio, float yRatio) const {
|
||||
PickRay result;
|
||||
#if 0
|
||||
if (OculusManager::isConnected()) {
|
||||
Application::getInstance()->getApplicationOverlay().computeOculusPickRay(xRatio, yRatio, result.origin, result.direction);
|
||||
} else {
|
||||
#endif
|
||||
Application::getInstance()->getViewFrustum()->computePickRay(xRatio, yRatio, result.origin, result.direction);
|
||||
#if 0
|
||||
}
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
PickRay Application::computePickRay(float x, float y) const {
|
||||
glm::vec2 canvasSize = getCanvasSize();
|
||||
x /= canvasSize.x;
|
||||
y /= canvasSize.y;
|
||||
return computeViewPickRay(x, y);
|
||||
}
|
||||
|
||||
glm::ivec2 Application::getCanvasSize() const {
|
||||
return getActiveRenderPlugin()->getCanvasSize();
|
||||
}
|
||||
|
||||
QSize Application::getDeviceSize() const {
|
||||
return getActiveRenderPlugin()->getRecommendedFramebufferSize(); // _glWidget->getDeviceSize();
|
||||
}
|
||||
|
||||
void Application::resizeGL() {
|
||||
auto size = getCanvasSize();
|
||||
return resizeGL(size.x, size.y);
|
||||
}
|
||||
|
||||
bool Application::hasFocus() const {
|
||||
return getActiveRenderPlugin()->hasFocus();
|
||||
}
|
||||
|
||||
glm::vec2 Application::getViewportDimensions() const {
|
||||
return toGlm(getDeviceSize());
|
||||
}
|
||||
|
||||
int Application::getTrueMouseX() const {
|
||||
return getActiveRenderPlugin()->getTrueMousePosition().x;
|
||||
}
|
||||
|
||||
int Application::getTrueMouseY() const {
|
||||
return getActiveRenderPlugin()->getTrueMousePosition().y;
|
||||
}
|
||||
|
||||
bool Application::isThrottleRendering() const {
|
||||
return getActiveRenderPlugin()->isThrottled();
|
||||
}
|
||||
|
||||
#include "plugins/render/NullRenderPlugin.h"
|
||||
#include "plugins/render/WindowRenderPlugin.h"
|
||||
#include "plugins/render/LegacyRenderPlugin.h"
|
||||
|
||||
static RenderPlugin * renderPlugin = nullptr;
|
||||
|
||||
RenderPlugin * Application::getActiveRenderPlugin() {
|
||||
if (nullptr == renderPlugin) {
|
||||
//renderPlugin = new WindowRenderPlugin();
|
||||
renderPlugin = new LegacyRenderPlugin();
|
||||
renderPlugin->init();
|
||||
renderPlugin->activate();
|
||||
connect(renderPlugin, &RenderPlugin::requestRender, this, [&] {
|
||||
this->paintGL();
|
||||
});
|
||||
connect(renderPlugin, &RenderPlugin::recommendedFramebufferSizeChanged, this, [&](const QSize & size) {
|
||||
DependencyManager::get<TextureCache>()->setFrameBufferSize(size * getRenderResolutionScale());
|
||||
this->resizeGL(size.width(), size.height());
|
||||
});
|
||||
_offscreenContext->makeCurrent();
|
||||
}
|
||||
return renderPlugin;
|
||||
}
|
||||
|
||||
const RenderPlugin * Application::getActiveRenderPlugin() const {
|
||||
return ((Application*)this)->getActiveRenderPlugin();
|
||||
}
|
||||
|
|
|
@ -36,6 +36,8 @@
|
|||
#include <StDev.h>
|
||||
#include <TextureCache.h>
|
||||
#include <ViewFrustum.h>
|
||||
#include <OffscreenGlContext.h>
|
||||
|
||||
|
||||
#include "AudioClient.h"
|
||||
#include "Bookmarks.h"
|
||||
|
@ -70,6 +72,7 @@
|
|||
#include "octree/OctreeFade.h"
|
||||
#include "octree/OctreePacketProcessor.h"
|
||||
#include "UndoStackScriptingInterface.h"
|
||||
#include "plugins/render/RenderPlugin.h"
|
||||
|
||||
|
||||
class QGLWidget;
|
||||
|
@ -154,6 +157,8 @@ public:
|
|||
void paintGL();
|
||||
void resizeGL(int width, int height);
|
||||
|
||||
void resizeEvent(QResizeEvent * size);
|
||||
|
||||
void keyPressEvent(QKeyEvent* event);
|
||||
void keyReleaseEvent(QKeyEvent* event);
|
||||
|
||||
|
@ -174,8 +179,14 @@ public:
|
|||
bool event(QEvent* event);
|
||||
bool eventFilter(QObject* object, QEvent* event);
|
||||
|
||||
GLCanvas* getGLWidget() { return _glWidget; }
|
||||
bool isThrottleRendering() const { return _glWidget->isThrottleRendering(); }
|
||||
glm::ivec2 getCanvasSize() const;
|
||||
QSize getDeviceSize() const;
|
||||
bool hasFocus() const;
|
||||
PickRay computePickRay() const;
|
||||
PickRay computeViewPickRay(float xRatio, float yRatio) const;
|
||||
void resizeGL();
|
||||
|
||||
bool isThrottleRendering() const;
|
||||
|
||||
Camera* getCamera() { return &_myCamera; }
|
||||
// Represents the current view frustum of the avatar.
|
||||
|
@ -201,8 +212,8 @@ public:
|
|||
bool mouseOnScreen() const;
|
||||
int getMouseX() const;
|
||||
int getMouseY() const;
|
||||
int getTrueMouseX() const { return _glWidget->mapFromGlobal(QCursor::pos()).x(); }
|
||||
int getTrueMouseY() const { return _glWidget->mapFromGlobal(QCursor::pos()).y(); }
|
||||
int getTrueMouseX() const;
|
||||
int getTrueMouseY() const;
|
||||
int getMouseDragStartedX() const;
|
||||
int getMouseDragStartedY() const;
|
||||
int getTrueMouseDragStartedX() const { return _mouseDragStartedX; }
|
||||
|
@ -271,15 +282,17 @@ public:
|
|||
virtual QThread* getMainThread() { return thread(); }
|
||||
virtual float getSizeScale() const;
|
||||
virtual int getBoundaryLevelAdjust() const;
|
||||
virtual PickRay computePickRay(float x, float y);
|
||||
virtual PickRay computePickRay(float x, float y) const;
|
||||
virtual const glm::vec3& getAvatarPosition() const { return _myAvatar->getPosition(); }
|
||||
RenderPlugin * getActiveRenderPlugin();
|
||||
const RenderPlugin * getActiveRenderPlugin() const;
|
||||
|
||||
NodeBounds& getNodeBoundsDisplay() { return _nodeBoundsDisplay; }
|
||||
|
||||
FileLogger* getLogger() { return _logger; }
|
||||
|
||||
glm::vec2 getViewportDimensions() const { return glm::vec2(_glWidget->getDeviceWidth(),
|
||||
_glWidget->getDeviceHeight()); }
|
||||
glm::vec2 getViewportDimensions() const;
|
||||
|
||||
NodeToJurisdictionMap& getEntityServerJurisdictions() { return _entityServerJurisdictions; }
|
||||
|
||||
void skipVersion(QString latestVersion);
|
||||
|
@ -411,8 +424,6 @@ private slots:
|
|||
void setEnableVRMode(bool enableVRMode);
|
||||
void cameraMenuChanged();
|
||||
|
||||
glm::vec2 getScaledScreenPoint(glm::vec2 projectedPoint);
|
||||
|
||||
void closeMirrorView();
|
||||
void restoreMirrorView();
|
||||
void shrinkMirrorView();
|
||||
|
@ -471,6 +482,9 @@ private:
|
|||
int sendNackPackets();
|
||||
|
||||
bool _dependencyManagerIsSetup;
|
||||
|
||||
OffscreenGlContext* _offscreenContext{ new OffscreenGlContext() };
|
||||
|
||||
MainWindow* _window;
|
||||
|
||||
ToolWindow* _toolWindow;
|
||||
|
@ -611,7 +625,7 @@ private:
|
|||
QThread _settingsThread;
|
||||
QTimer _settingsTimer;
|
||||
|
||||
GLCanvas* _glWidget = new GLCanvas(); // our GLCanvas has a couple extra features
|
||||
|
||||
|
||||
void checkSkeleton();
|
||||
|
||||
|
|
|
@ -55,42 +55,24 @@ Camera::Camera() :
|
|||
_farClip(DEFAULT_FAR_CLIP), // default
|
||||
_hmdPosition(),
|
||||
_hmdRotation(),
|
||||
_scale(1.0f),
|
||||
_isKeepLookingAt(false),
|
||||
_lookingAt(0.0f, 0.0f, 0.0f)
|
||||
_scale(1.0f)
|
||||
{
|
||||
}
|
||||
|
||||
void Camera::update(float deltaTime) {
|
||||
if (_isKeepLookingAt) {
|
||||
lookAt(_lookingAt);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void Camera::setPosition(const glm::vec3& position) {
|
||||
_position = position;
|
||||
}
|
||||
|
||||
void Camera::setRotation(const glm::quat& rotation) {
|
||||
_rotation = rotation;
|
||||
if (_isKeepLookingAt) {
|
||||
lookAt(_lookingAt);
|
||||
}
|
||||
}
|
||||
|
||||
void Camera::setHmdPosition(const glm::vec3& hmdPosition) {
|
||||
_hmdPosition = hmdPosition;
|
||||
if (_isKeepLookingAt) {
|
||||
lookAt(_lookingAt);
|
||||
}
|
||||
}
|
||||
|
||||
void Camera::setHmdRotation(const glm::quat& hmdRotation) {
|
||||
_hmdRotation = hmdRotation;
|
||||
if (_isKeepLookingAt) {
|
||||
lookAt(_lookingAt);
|
||||
}
|
||||
}
|
||||
|
||||
float Camera::getFarClip() const {
|
||||
|
@ -121,21 +103,6 @@ void Camera::setFarClip(float f) {
|
|||
_farClip = f;
|
||||
}
|
||||
|
||||
PickRay Camera::computePickRay(float x, float y) {
|
||||
auto glCanvas = Application::getInstance()->getGLWidget();
|
||||
return computeViewPickRay(x / glCanvas->width(), y / glCanvas->height());
|
||||
}
|
||||
|
||||
PickRay Camera::computeViewPickRay(float xRatio, float yRatio) {
|
||||
PickRay result;
|
||||
if (OculusManager::isConnected()) {
|
||||
Application::getInstance()->getApplicationOverlay().computeOculusPickRay(xRatio, yRatio, result.origin, result.direction);
|
||||
} else {
|
||||
Application::getInstance()->getViewFrustum()->computePickRay(xRatio, yRatio, result.origin, result.direction);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void Camera::setModeString(const QString& mode) {
|
||||
CameraMode targetMode = stringToMode(mode);
|
||||
|
||||
|
@ -164,17 +131,3 @@ void Camera::setModeString(const QString& mode) {
|
|||
QString Camera::getModeString() const {
|
||||
return modeToString(_mode);
|
||||
}
|
||||
|
||||
void Camera::lookAt(const glm::vec3& lookAt) {
|
||||
glm::vec3 up = IDENTITY_UP;
|
||||
glm::mat4 lookAtMatrix = glm::lookAt(_position, lookAt, up);
|
||||
glm::quat rotation = glm::quat_cast(lookAtMatrix);
|
||||
rotation.w = -rotation.w; // Rosedale approved
|
||||
_rotation = rotation;
|
||||
}
|
||||
|
||||
void Camera::keepLookingAt(const glm::vec3& point) {
|
||||
lookAt(point);
|
||||
_isKeepLookingAt = true;
|
||||
_lookingAt = point;
|
||||
}
|
||||
|
|
|
@ -41,8 +41,6 @@ public:
|
|||
|
||||
void initialize(); // instantly put the camera at the ideal position and rotation.
|
||||
|
||||
void update( float deltaTime );
|
||||
|
||||
void setRotation(const glm::quat& rotation);
|
||||
void setHmdPosition(const glm::vec3& hmdPosition);
|
||||
void setHmdRotation(const glm::quat& hmdRotation);
|
||||
|
@ -77,20 +75,6 @@ public slots:
|
|||
|
||||
void setOrientation(const glm::quat& orientation) { setRotation(orientation); }
|
||||
glm::quat getOrientation() const { return getRotation(); }
|
||||
|
||||
PickRay computePickRay(float x, float y);
|
||||
PickRay computeViewPickRay(float xRatio, float yRatio);
|
||||
|
||||
// These only work on independent cameras
|
||||
/// one time change to what the camera is looking at
|
||||
void lookAt(const glm::vec3& value);
|
||||
|
||||
/// fix what the camera is looking at, and keep the camera looking at this even if position changes
|
||||
void keepLookingAt(const glm::vec3& value);
|
||||
|
||||
/// stops the keep looking at feature, doesn't change what's being looked at, but will stop camera from
|
||||
/// continuing to update it's orientation to keep looking at the item
|
||||
void stopLooking() { _isKeepLookingAt = false; }
|
||||
|
||||
signals:
|
||||
void modeUpdated(const QString& newMode);
|
||||
|
@ -108,8 +92,6 @@ private:
|
|||
glm::vec3 _hmdPosition;
|
||||
glm::quat _hmdRotation;
|
||||
float _scale;
|
||||
bool _isKeepLookingAt;
|
||||
glm::vec3 _lookingAt;
|
||||
};
|
||||
|
||||
#endif // hifi_Camera_h
|
||||
|
|
|
@ -60,21 +60,27 @@ void GLCanvas::initializeGL() {
|
|||
|
||||
void GLCanvas::paintGL() {
|
||||
if (!_throttleRendering && !Application::getInstance()->getWindow()->isMinimized()) {
|
||||
#if 0
|
||||
//Need accurate frame timing for the oculus rift
|
||||
if (OculusManager::isConnected()) {
|
||||
OculusManager::beginFrameTiming();
|
||||
}
|
||||
|
||||
#endif
|
||||
Application::getInstance()->paintGL();
|
||||
|
||||
#if 0
|
||||
if (!OculusManager::isConnected()) {
|
||||
#endif
|
||||
|
||||
swapBuffers();
|
||||
#if 0
|
||||
} else {
|
||||
if (OculusManager::allowSwap()) {
|
||||
swapBuffers();
|
||||
}
|
||||
OculusManager::endFrameTiming();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -134,17 +140,21 @@ void GLCanvas::activeChanged(Qt::ApplicationState state) {
|
|||
void GLCanvas::throttleRender() {
|
||||
_frameTimer.start(_idleRenderInterval);
|
||||
if (!Application::getInstance()->getWindow()->isMinimized()) {
|
||||
#if 0
|
||||
//Need accurate frame timing for the oculus rift
|
||||
if (OculusManager::isConnected()) {
|
||||
OculusManager::beginFrameTiming();
|
||||
}
|
||||
#endif
|
||||
|
||||
Application::getInstance()->paintGL();
|
||||
swapBuffers();
|
||||
|
||||
#if 0
|
||||
if (OculusManager::isConnected()) {
|
||||
OculusManager::endFrameTiming();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -38,15 +38,14 @@ bool AudioToolBox::mousePressEvent(int x, int y) {
|
|||
void AudioToolBox::render(int x, int y, bool boxed) {
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
||||
auto glCanvas = Application::getInstance()->getGLWidget();
|
||||
if (_micTextureId == 0) {
|
||||
_micTextureId = glCanvas->bindTexture(QImage(PathUtils::resourcesPath() + "images/mic.svg"));
|
||||
_micTextureId = new QOpenGLTexture(QImage(PathUtils::resourcesPath() + "images/mic.svg"));
|
||||
}
|
||||
if (_muteTextureId == 0) {
|
||||
_muteTextureId = glCanvas->bindTexture(QImage(PathUtils::resourcesPath() + "images/mic-mute.svg"));
|
||||
_muteTextureId = new QOpenGLTexture(QImage(PathUtils::resourcesPath() + "images/mic-mute.svg"));
|
||||
}
|
||||
if (_boxTextureId == 0) {
|
||||
_boxTextureId = glCanvas->bindTexture(QImage(PathUtils::resourcesPath() + "images/audio-box.svg"));
|
||||
_boxTextureId = new QOpenGLTexture(QImage(PathUtils::resourcesPath() + "images/audio-box.svg"));
|
||||
}
|
||||
|
||||
auto audioIO = DependencyManager::get<AudioClient>();
|
||||
|
@ -60,7 +59,7 @@ void AudioToolBox::render(int x, int y, bool boxed) {
|
|||
|
||||
QRect boxBounds = QRect(x - BOX_LEFT_PADDING, y - BOX_TOP_PADDING, BOX_WIDTH, BOX_HEIGHT);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, _boxTextureId);
|
||||
_boxTextureId->bind();
|
||||
|
||||
glm::vec4 quadColor;
|
||||
|
||||
|
@ -81,10 +80,10 @@ void AudioToolBox::render(int x, int y, bool boxed) {
|
|||
|
||||
_iconBounds = QRect(x, y, MUTE_ICON_SIZE, MUTE_ICON_SIZE);
|
||||
if (!audioIO->isMuted()) {
|
||||
glBindTexture(GL_TEXTURE_2D, _micTextureId);
|
||||
_micTextureId->bind();
|
||||
iconColor = 1.0f;
|
||||
} else {
|
||||
glBindTexture(GL_TEXTURE_2D, _muteTextureId);
|
||||
_muteTextureId->bind();
|
||||
|
||||
// Make muted icon pulsate
|
||||
static const float PULSE_MIN = 0.4f;
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
#include <DependencyManager.h>
|
||||
#include <GeometryCache.h>
|
||||
#include <QOpenGLTexture>
|
||||
|
||||
class AudioToolBox : public Dependency {
|
||||
SINGLETON_DEPENDENCY
|
||||
|
@ -24,9 +25,9 @@ public:
|
|||
protected:
|
||||
AudioToolBox();
|
||||
private:
|
||||
GLuint _micTextureId = 0;
|
||||
GLuint _muteTextureId = 0;
|
||||
GLuint _boxTextureId = 0;
|
||||
QOpenGLTexture* _micTextureId = 0;
|
||||
QOpenGLTexture* _muteTextureId = 0;
|
||||
QOpenGLTexture* _boxTextureId = 0;
|
||||
int _boxQuadID = GeometryCache::UNKNOWN_ID;
|
||||
QRect _iconBounds;
|
||||
qint64 _iconPulseTimeReference = 0;
|
||||
|
|
|
@ -289,9 +289,12 @@ glm::quat Head::getCameraOrientation() const {
|
|||
// to change the driving direction while in Oculus mode. It is used to support driving toward where you're
|
||||
// head is looking. Note that in oculus mode, your actual camera view and where your head is looking is not
|
||||
// always the same.
|
||||
#if 0
|
||||
if (OculusManager::isConnected()) {
|
||||
return getOrientation();
|
||||
}
|
||||
#endif
|
||||
|
||||
Avatar* owningAvatar = static_cast<Avatar*>(_owningAvatar);
|
||||
return owningAvatar->getWorldAlignedOrientation() * glm::quat(glm::radians(glm::vec3(_basePitch, 0.0f, 0.0f)));
|
||||
}
|
||||
|
|
|
@ -230,6 +230,7 @@ void MyAvatar::simulate(float deltaTime) {
|
|||
void MyAvatar::updateFromTrackers(float deltaTime) {
|
||||
glm::vec3 estimatedPosition, estimatedRotation;
|
||||
|
||||
#if 0
|
||||
if (isPlaying() && !OculusManager::isConnected()) {
|
||||
return;
|
||||
}
|
||||
|
@ -301,6 +302,7 @@ void MyAvatar::updateFromTrackers(float deltaTime) {
|
|||
-MAX_LEAN, MAX_LEAN));
|
||||
head->setLeanForward(glm::clamp(glm::degrees(atanf(relativePosition.z * _leanScale / TORSO_LENGTH)),
|
||||
-MAX_LEAN, MAX_LEAN));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -829,11 +831,15 @@ void MyAvatar::updateLookAtTargetAvatar() {
|
|||
howManyLookingAtMe++;
|
||||
// Have that avatar look directly at my camera
|
||||
// Philip TODO: correct to look at left/right eye
|
||||
#if 0
|
||||
if (OculusManager::isConnected()) {
|
||||
avatar->getHead()->setCorrectedLookAtPosition(OculusManager::getLeftEyePosition());
|
||||
} else {
|
||||
#endif
|
||||
avatar->getHead()->setCorrectedLookAtPosition(Application::getInstance()->getViewFrustum()->getPosition());
|
||||
#if 0
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
avatar->getHead()->clearCorrectedLookAtPosition();
|
||||
}
|
||||
|
@ -1017,6 +1023,7 @@ void MyAvatar::renderBody(ViewFrustum* renderFrustum, RenderArgs::RenderMode ren
|
|||
renderFrustum->setNearClip(DEFAULT_NEAR_CLIP);
|
||||
} else {
|
||||
float clipDistance = _skeletonModel.getHeadClipDistance();
|
||||
#if 0
|
||||
if (OculusManager::isConnected()) {
|
||||
// If avatar is horizontally in front of camera, increase clip distance by the amount it is in front.
|
||||
glm::vec3 cameraToAvatar = _position - cameraPos;
|
||||
|
@ -1027,6 +1034,7 @@ void MyAvatar::renderBody(ViewFrustum* renderFrustum, RenderArgs::RenderMode ren
|
|||
clipDistance += headOffset;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
renderFrustum->setNearClip(clipDistance);
|
||||
}
|
||||
}
|
||||
|
@ -1061,11 +1069,13 @@ void MyAvatar::updateOrientation(float deltaTime) {
|
|||
// Gather rotation information from keyboard
|
||||
const float TIME_BETWEEN_HMD_TURNS = 0.5f;
|
||||
const float HMD_TURN_DEGREES = 22.5f;
|
||||
#if 0
|
||||
if (!OculusManager::isConnected()) {
|
||||
// Smoothly rotate body with arrow keys if not in HMD
|
||||
_bodyYawDelta -= _driveKeys[ROT_RIGHT] * YAW_SPEED * deltaTime;
|
||||
_bodyYawDelta += _driveKeys[ROT_LEFT] * YAW_SPEED * deltaTime;
|
||||
} else {
|
||||
#endif
|
||||
// Jump turns if in HMD
|
||||
if (_driveKeys[ROT_RIGHT] || _driveKeys[ROT_LEFT]) {
|
||||
if (_turningKeyPressTime == 0.0f) {
|
||||
|
@ -1079,7 +1089,9 @@ void MyAvatar::updateOrientation(float deltaTime) {
|
|||
} else {
|
||||
_turningKeyPressTime = 0.0f;
|
||||
}
|
||||
#if 0
|
||||
}
|
||||
#endif
|
||||
getHead()->setBasePitch(getHead()->getBasePitch() + (_driveKeys[ROT_UP] - _driveKeys[ROT_DOWN]) * PITCH_SPEED * deltaTime);
|
||||
|
||||
// update body orientation by movement inputs
|
||||
|
@ -1095,6 +1107,7 @@ void MyAvatar::updateOrientation(float deltaTime) {
|
|||
float MINIMUM_ROTATION_RATE = 2.0f;
|
||||
if (fabs(_bodyYawDelta) < MINIMUM_ROTATION_RATE) { _bodyYawDelta = 0.0f; }
|
||||
|
||||
#if 0
|
||||
if (OculusManager::isConnected()) {
|
||||
// these angles will be in radians
|
||||
float yaw, pitch, roll;
|
||||
|
@ -1117,7 +1130,7 @@ void MyAvatar::updateOrientation(float deltaTime) {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
glm::vec3 MyAvatar::applyKeyboardMotor(float deltaTime, const glm::vec3& localVelocity, bool isHovering) {
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#if 0
|
||||
#include "InterfaceConfig.h"
|
||||
|
||||
#include "OculusManager.h"
|
||||
|
@ -860,3 +860,4 @@ int OculusManager::getHMDScreen() {
|
|||
return hmdScreenIndex;
|
||||
}
|
||||
|
||||
#endif
|
|
@ -35,18 +35,15 @@ bool TV3DManager::isConnected() {
|
|||
}
|
||||
|
||||
void TV3DManager::connect() {
|
||||
auto glCanvas = Application::getInstance()->getGLWidget();
|
||||
int width = glCanvas->getDeviceWidth();
|
||||
int height = glCanvas->getDeviceHeight();
|
||||
auto deviceSize = qApp->getDeviceSize();
|
||||
Camera& camera = *Application::getInstance()->getCamera();
|
||||
|
||||
configureCamera(camera, width, height);
|
||||
configureCamera(camera, deviceSize.width(), deviceSize.height());
|
||||
}
|
||||
|
||||
|
||||
// The basic strategy of this stereoscopic rendering is explained here:
|
||||
// http://www.orthostereo.com/geometryopengl.html
|
||||
void TV3DManager::setFrustum(Camera& whichCamera) {
|
||||
void TV3DManager::setFrustum(const Camera& whichCamera) {
|
||||
const double DTR = 0.0174532925; // degree to radians
|
||||
const double IOD = 0.05; //intraocular distance
|
||||
double fovy = whichCamera.getFieldOfView(); // field of view in y-axis
|
||||
|
@ -70,7 +67,9 @@ void TV3DManager::setFrustum(Camera& whichCamera) {
|
|||
_rightEye.modelTranslation = -IOD / 2;
|
||||
}
|
||||
|
||||
void TV3DManager::configureCamera(Camera& whichCamera, int screenWidth, int screenHeight) {
|
||||
void TV3DManager::configureCamera(Camera& whichCamera_, int screenWidth, int screenHeight) {
|
||||
const Camera& whichCamera = whichCamera_;
|
||||
|
||||
if (screenHeight == 0) {
|
||||
screenHeight = 1; // prevent divide by 0
|
||||
}
|
||||
|
@ -93,8 +92,7 @@ void TV3DManager::display(Camera& whichCamera) {
|
|||
// left eye portal
|
||||
int portalX = 0;
|
||||
int portalY = 0;
|
||||
auto glCanvas = Application::getInstance()->getGLWidget();
|
||||
QSize deviceSize = glCanvas->getDeviceSize() *
|
||||
QSize deviceSize = qApp->getDeviceSize() *
|
||||
Application::getInstance()->getRenderResolutionScale();
|
||||
int portalW = deviceSize.width() / 2;
|
||||
int portalH = deviceSize.height();
|
||||
|
@ -103,7 +101,7 @@ void TV3DManager::display(Camera& whichCamera) {
|
|||
|
||||
// We only need to render the overlays to a texture once, then we just render the texture as a quad
|
||||
// PrioVR will only work if renderOverlay is called, calibration is connected to Application::renderingOverlay()
|
||||
applicationOverlay.renderOverlay(true);
|
||||
applicationOverlay.renderOverlay();
|
||||
|
||||
DependencyManager::get<GlowEffect>()->prepare();
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
@ -134,7 +132,9 @@ void TV3DManager::display(Camera& whichCamera) {
|
|||
eyeCamera.setEyeOffsetPosition(glm::vec3(-_activeEye->modelTranslation,0,0));
|
||||
Application::getInstance()->displaySide(eyeCamera, false, RenderArgs::MONO);
|
||||
|
||||
#if 0
|
||||
applicationOverlay.displayOverlayTexture3DTV(whichCamera, _aspect, fov);
|
||||
#endif
|
||||
_activeEye = NULL;
|
||||
}
|
||||
glPopMatrix();
|
||||
|
@ -162,8 +162,9 @@ void TV3DManager::display(Camera& whichCamera) {
|
|||
glLoadIdentity();
|
||||
eyeCamera.setEyeOffsetPosition(glm::vec3(-_activeEye->modelTranslation,0,0));
|
||||
Application::getInstance()->displaySide(eyeCamera, false, RenderArgs::MONO);
|
||||
|
||||
#if 0
|
||||
applicationOverlay.displayOverlayTexture3DTV(whichCamera, _aspect, fov);
|
||||
#endif
|
||||
_activeEye = NULL;
|
||||
}
|
||||
glPopMatrix();
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
|
||||
#ifndef hifi_TV3DManager_h
|
||||
#define hifi_TV3DManager_h
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
|
@ -37,7 +36,7 @@ public:
|
|||
static void overrideOffAxisFrustum(float& left, float& right, float& bottom, float& top, float& nearVal,
|
||||
float& farVal, glm::vec4& nearClipPlane, glm::vec4& farClipPlane);
|
||||
private:
|
||||
static void setFrustum(Camera& whichCamera);
|
||||
static void setFrustum(const Camera& whichCamera);
|
||||
static int _screenWidth;
|
||||
static int _screenHeight;
|
||||
static double _aspect;
|
||||
|
|
|
@ -94,11 +94,14 @@ int main(int argc, const char* argv[]) {
|
|||
usecTimestampNowForceClockSkew(clockSkew);
|
||||
qCDebug(interfaceapp, "clockSkewOption=%s clockSkew=%d", clockSkewOption, clockSkew);
|
||||
}
|
||||
|
||||
#if 0
|
||||
// Oculus initialization MUST PRECEDE OpenGL context creation.
|
||||
// The nature of the Application constructor means this has to be either here,
|
||||
// or in the main window ctor, before GL startup.
|
||||
OculusManager::init();
|
||||
|
||||
#endif
|
||||
|
||||
int exitCode;
|
||||
{
|
||||
QSettings::setDefaultFormat(QSettings::IniFormat);
|
||||
|
|
1
interface/src/plugins/Plugin.cpp
Normal file
1
interface/src/plugins/Plugin.cpp
Normal file
|
@ -0,0 +1 @@
|
|||
#include "Plugin.h"
|
20
interface/src/plugins/Plugin.h
Normal file
20
interface/src/plugins/Plugin.h
Normal file
|
@ -0,0 +1,20 @@
|
|||
#pragma once
|
||||
|
||||
#include <QString>
|
||||
#include <QObject>
|
||||
|
||||
class Plugin : public QObject {
|
||||
private:
|
||||
bool _active{ false };
|
||||
public:
|
||||
virtual const QString & getName() = 0;
|
||||
virtual bool isSupported() { return true; }
|
||||
|
||||
virtual void init() {}
|
||||
virtual void deinit() {}
|
||||
|
||||
virtual void activate() {}
|
||||
virtual void deactivate() {}
|
||||
|
||||
virtual void idle() {}
|
||||
};
|
1
interface/src/plugins/PluginManager.cpp
Normal file
1
interface/src/plugins/PluginManager.cpp
Normal file
|
@ -0,0 +1 @@
|
|||
#include "PluginManager.h"
|
12
interface/src/plugins/PluginManager.h
Normal file
12
interface/src/plugins/PluginManager.h
Normal file
|
@ -0,0 +1,12 @@
|
|||
#pragma once
|
||||
|
||||
#include "plugins/Plugin.h"
|
||||
#include "plugins/render/RenderPlugin.h"
|
||||
#include <QList>
|
||||
#include <QSharedPointer>
|
||||
|
||||
class PluginManager : public QObject {
|
||||
public:
|
||||
static PluginManager * getInstance();
|
||||
const QList<QSharedPointer<RenderPlugin>> getRenderPlugins();
|
||||
};
|
11
interface/src/plugins/render/HmdRenderPlugin.cpp
Normal file
11
interface/src/plugins/render/HmdRenderPlugin.cpp
Normal file
|
@ -0,0 +1,11 @@
|
|||
//
|
||||
// HmdRenderPlugin.cpp
|
||||
//
|
||||
// Created by Bradley Austin Davis on 2014/04/13.
|
||||
// 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 "HmdRenderPlugin.h"
|
15
interface/src/plugins/render/HmdRenderPlugin.h
Normal file
15
interface/src/plugins/render/HmdRenderPlugin.h
Normal file
|
@ -0,0 +1,15 @@
|
|||
//
|
||||
// HmdRenderPlugin.h
|
||||
//
|
||||
// Created by Bradley Austin Davis on 2014/04/13.
|
||||
// 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
|
||||
#include "StereoRenderPlugin.h"
|
||||
|
||||
class HmdRenderPlugin : public StereoRenderPlugin {
|
||||
virtual bool isHmd() const final { return true; }
|
||||
};
|
87
interface/src/plugins/render/LegacyRenderPlugin.cpp
Normal file
87
interface/src/plugins/render/LegacyRenderPlugin.cpp
Normal file
|
@ -0,0 +1,87 @@
|
|||
//
|
||||
// LegacyRenderPlugin.cpp
|
||||
//
|
||||
// Created by Bradley Austin Davis on 2014/04/13.
|
||||
// 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 "Application.h"
|
||||
#include "LegacyRenderPlugin.h"
|
||||
#include "MainWindow.h"
|
||||
#include <RenderUtil.h>
|
||||
|
||||
const QString LegacyRenderPlugin::NAME("LegacyRenderPlugin");
|
||||
|
||||
const QString & LegacyRenderPlugin::getName() {
|
||||
return NAME;
|
||||
}
|
||||
|
||||
static QWidget * oldWidget = nullptr;
|
||||
|
||||
void LegacyRenderPlugin::activate() {
|
||||
_window = new GLCanvas();
|
||||
QGLFormat format(QGL::NoDepthBuffer | QGL::NoStencilBuffer);
|
||||
_window->setContext(new QGLContext(format),
|
||||
QGLContext::fromOpenGLContext(QOpenGLContext::currentContext()));
|
||||
_window->makeCurrent();
|
||||
oldWidget = qApp->getWindow()->centralWidget();
|
||||
qApp->getWindow()->setCentralWidget(_window);
|
||||
_window->doneCurrent();
|
||||
_window->setFocusPolicy(Qt::StrongFocus);
|
||||
_window->setFocus();
|
||||
_window->setMouseTracking(true);
|
||||
}
|
||||
|
||||
void LegacyRenderPlugin::deactivate() {
|
||||
qApp->getWindow()->setCentralWidget(oldWidget);
|
||||
// stop the glWidget frame timer so it doesn't call paintGL
|
||||
_window->stopFrameTimer();
|
||||
_window->doneCurrent();
|
||||
_window->deleteLater();
|
||||
_window = nullptr;
|
||||
}
|
||||
|
||||
QSize LegacyRenderPlugin::getRecommendedFramebufferSize() const {
|
||||
return _window->getDeviceSize();
|
||||
}
|
||||
|
||||
void LegacyRenderPlugin::makeCurrent() {
|
||||
_window->makeCurrent();
|
||||
QSize windowSize = _window->size();
|
||||
glViewport(0, 0, windowSize.width(), windowSize.height());
|
||||
}
|
||||
|
||||
void LegacyRenderPlugin::doneCurrent() {
|
||||
_window->doneCurrent();
|
||||
}
|
||||
|
||||
void LegacyRenderPlugin::swapBuffers() {
|
||||
_window->swapBuffers();
|
||||
glFinish();
|
||||
}
|
||||
|
||||
void LegacyRenderPlugin::idle() {
|
||||
_window->updateGL();
|
||||
}
|
||||
|
||||
glm::ivec2 LegacyRenderPlugin::getCanvasSize() const {
|
||||
return toGlm(_window->size());
|
||||
}
|
||||
|
||||
bool LegacyRenderPlugin::hasFocus() const {
|
||||
return _window->hasFocus();
|
||||
}
|
||||
|
||||
PickRay LegacyRenderPlugin::computePickRay(const glm::vec2 & pos) const {
|
||||
return PickRay();
|
||||
}
|
||||
|
||||
bool isMouseOnScreen() {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool LegacyRenderPlugin::isThrottled() {
|
||||
return _window->isThrottleRendering();
|
||||
}
|
36
interface/src/plugins/render/LegacyRenderPlugin.h
Normal file
36
interface/src/plugins/render/LegacyRenderPlugin.h
Normal file
|
@ -0,0 +1,36 @@
|
|||
//
|
||||
// LegacyRenderPlugin.h
|
||||
//
|
||||
// Created by Bradley Austin Davis on 2014/04/13.
|
||||
// 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
|
||||
|
||||
#include "SimpleRenderPlugin.h"
|
||||
#include "GLCanvas.h"
|
||||
|
||||
class LegacyRenderPlugin : public SimpleRenderPlugin<GLCanvas> {
|
||||
Q_OBJECT
|
||||
public:
|
||||
static const QString NAME;
|
||||
virtual const QString & getName();
|
||||
|
||||
virtual void activate();
|
||||
virtual void deactivate();
|
||||
|
||||
virtual QSize getRecommendedFramebufferSize() const;
|
||||
virtual glm::ivec2 getCanvasSize() const;
|
||||
virtual bool hasFocus() const;
|
||||
virtual PickRay computePickRay(const glm::vec2 & pos) const;
|
||||
virtual bool isMouseOnScreen() const { return true; }
|
||||
virtual bool isThrottled();
|
||||
|
||||
protected:
|
||||
virtual void makeCurrent();
|
||||
virtual void doneCurrent();
|
||||
virtual void swapBuffers();
|
||||
virtual void idle();
|
||||
};
|
44
interface/src/plugins/render/NullRenderPlugin.cpp
Normal file
44
interface/src/plugins/render/NullRenderPlugin.cpp
Normal file
|
@ -0,0 +1,44 @@
|
|||
//
|
||||
// NullRenderPlugin.cpp
|
||||
//
|
||||
// Created by Bradley Austin Davis on 2014/04/13.
|
||||
// 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 "NullRenderPlugin.h"
|
||||
|
||||
const QString NullRenderPlugin::NAME("NullRenderPlugin");
|
||||
|
||||
const QString & NullRenderPlugin::getName() {
|
||||
return NAME;
|
||||
}
|
||||
|
||||
QSize NullRenderPlugin::getRecommendedFramebufferSize() const {
|
||||
return QSize(100, 100);
|
||||
}
|
||||
|
||||
glm::ivec2 NullRenderPlugin::getCanvasSize() const {
|
||||
return glm::ivec2(100, 100);
|
||||
}
|
||||
|
||||
bool NullRenderPlugin::hasFocus() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
glm::ivec2 NullRenderPlugin::getRelativeMousePosition() const {
|
||||
return glm::ivec2();
|
||||
}
|
||||
|
||||
glm::ivec2 NullRenderPlugin::getTrueMousePosition() const {
|
||||
return glm::ivec2();
|
||||
}
|
||||
|
||||
PickRay NullRenderPlugin::computePickRay(const glm::vec2 & pos) const {
|
||||
return PickRay();
|
||||
}
|
||||
|
||||
bool NullRenderPlugin::isMouseOnScreen() {
|
||||
return false;
|
||||
}
|
29
interface/src/plugins/render/NullRenderPlugin.h
Normal file
29
interface/src/plugins/render/NullRenderPlugin.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
//
|
||||
// NullRenderPlugin.h
|
||||
//
|
||||
// Created by Bradley Austin Davis on 2014/04/13.
|
||||
// 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
|
||||
|
||||
#include "RenderPlugin.h"
|
||||
|
||||
class NullRenderPlugin : public RenderPlugin {
|
||||
public:
|
||||
static const QString NAME;
|
||||
|
||||
virtual ~NullRenderPlugin() final {}
|
||||
virtual const QString & getName();
|
||||
|
||||
virtual QSize getRecommendedFramebufferSize() const;
|
||||
virtual glm::ivec2 getCanvasSize() const;
|
||||
virtual bool hasFocus() const;
|
||||
virtual glm::ivec2 getRelativeMousePosition() const;
|
||||
virtual glm::ivec2 getTrueMousePosition() const;
|
||||
virtual PickRay computePickRay(const glm::vec2 & pos) const;
|
||||
virtual bool isMouseOnScreen();
|
||||
|
||||
};
|
10
interface/src/plugins/render/OculusBaseRenderPlugin.cpp
Normal file
10
interface/src/plugins/render/OculusBaseRenderPlugin.cpp
Normal file
|
@ -0,0 +1,10 @@
|
|||
//
|
||||
// OculusBaseRenderPlugin.cpp
|
||||
//
|
||||
// Created by Bradley Austin Davis on 2014/04/13.
|
||||
// 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 "OculusBaseRenderPlugin.h"
|
77
interface/src/plugins/render/OculusBaseRenderPlugin.h
Normal file
77
interface/src/plugins/render/OculusBaseRenderPlugin.h
Normal file
|
@ -0,0 +1,77 @@
|
|||
//
|
||||
// OculusBaseRenderPlugin.h
|
||||
//
|
||||
// Created by Bradley Austin Davis on 2014/04/13.
|
||||
// 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
|
||||
|
||||
#include "HmdRenderPlugin.h"
|
||||
|
||||
class OculusRenderPluginBase : public HmdRenderPlugin {
|
||||
|
||||
};
|
||||
|
||||
#if 0
|
||||
// Set the desired FBO texture size. If it hasn't changed, this does nothing.
|
||||
// Otherwise, it must rebuild the FBOs
|
||||
if (OculusManager::isConnected()) {
|
||||
DependencyManager::get<TextureCache>()->setFrameBufferSize(OculusManager::getRenderTargetSize());
|
||||
} else {
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
// Update camera position
|
||||
if (!OculusManager::isConnected()) {
|
||||
_myCamera.update(1.0f / _fps);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
if (OculusManager::isConnected()) {
|
||||
//When in mirror mode, use camera rotation. Otherwise, use body rotation
|
||||
if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
|
||||
OculusManager::display(_myCamera.getRotation(), _myCamera.getPosition(), _myCamera);
|
||||
} else {
|
||||
OculusManager::display(_myAvatar->getWorldAlignedOrientation(), _myAvatar->getDefaultEyePosition(), _myCamera);
|
||||
}
|
||||
_myCamera.update(1.0f / _fps);
|
||||
|
||||
} else if (TV3DManager::isConnected()) {
|
||||
|
||||
TV3DManager::display(_myCamera);
|
||||
|
||||
} else {
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
OculusManager::abandonCalibration();
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
if (OculusManager::isConnected()) {
|
||||
return getMouseX() >= 0 && getMouseX() <= _glWidget->getDeviceWidth() &&
|
||||
getMouseY() >= 0 && getMouseY() <= _glWidget->getDeviceHeight();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
if (OculusManager::isConnected()) {
|
||||
glm::vec2 pos = _applicationOverlay.screenToOverlay(glm::vec2(getTrueMouseX(), getTrueMouseY()));
|
||||
return pos.x;
|
||||
}
|
||||
#endif
|
||||
#if 0
|
||||
if (OculusManager::isConnected()) {
|
||||
glm::vec2 pos = _applicationOverlay.screenToOverlay(glm::vec2(getTrueMouseX(), getTrueMouseY()));
|
||||
return pos.y;
|
||||
}
|
||||
#endif
|
||||
|
10
interface/src/plugins/render/OculusDirectD3DRenderPlugin.cpp
Normal file
10
interface/src/plugins/render/OculusDirectD3DRenderPlugin.cpp
Normal file
|
@ -0,0 +1,10 @@
|
|||
//
|
||||
// OculusDirectD3DRenderPlugin.cpp
|
||||
//
|
||||
// Created by Bradley Austin Davis on 2014/04/13.
|
||||
// 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 "OculusDirectD3DRenderPlugin.h"
|
12
interface/src/plugins/render/OculusDirectD3DRenderPlugin.h
Normal file
12
interface/src/plugins/render/OculusDirectD3DRenderPlugin.h
Normal file
|
@ -0,0 +1,12 @@
|
|||
//
|
||||
// OculusDirectD3DRenderPlugin.h
|
||||
//
|
||||
// Created by Bradley Austin Davis on 2014/04/13.
|
||||
// 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
|
||||
|
||||
#include "OculusBaseRenderPlugin.h"
|
10
interface/src/plugins/render/OculusDirectRenderPlugin.cpp
Normal file
10
interface/src/plugins/render/OculusDirectRenderPlugin.cpp
Normal file
|
@ -0,0 +1,10 @@
|
|||
//
|
||||
// OculusDirectRenderPlugin.cpp
|
||||
//
|
||||
// Created by Bradley Austin Davis on 2014/04/13.
|
||||
// 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 "OculusDirectRenderPlugin.h"
|
12
interface/src/plugins/render/OculusDirectRenderPlugin.h
Normal file
12
interface/src/plugins/render/OculusDirectRenderPlugin.h
Normal file
|
@ -0,0 +1,12 @@
|
|||
//
|
||||
// OculusDirectRenderPlugin.h
|
||||
//
|
||||
// Created by Bradley Austin Davis on 2014/04/13.
|
||||
// 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
|
||||
|
||||
#include "OculusBaseRenderPlugin.h"
|
10
interface/src/plugins/render/OculusExtendedRenderPlugin.cpp
Normal file
10
interface/src/plugins/render/OculusExtendedRenderPlugin.cpp
Normal file
|
@ -0,0 +1,10 @@
|
|||
//
|
||||
// OculusExtendedRenderPlugin.cpp
|
||||
//
|
||||
// Created by Bradley Austin Davis on 2014/04/13.
|
||||
// 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 "OculusExtendedRenderPlugin.h"
|
12
interface/src/plugins/render/OculusExtendedRenderPlugin.h
Normal file
12
interface/src/plugins/render/OculusExtendedRenderPlugin.h
Normal file
|
@ -0,0 +1,12 @@
|
|||
//
|
||||
// OculusExtendedRenderPlugin.h
|
||||
//
|
||||
// Created by Bradley Austin Davis on 2014/04/13.
|
||||
// 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
|
||||
|
||||
#include "OculusBaseRenderPlugin.h"
|
16
interface/src/plugins/render/RenderPlugin.cpp
Normal file
16
interface/src/plugins/render/RenderPlugin.cpp
Normal file
|
@ -0,0 +1,16 @@
|
|||
//
|
||||
// RenderPlugin.cpp
|
||||
//
|
||||
// Created by Bradley Austin Davis on 2014/04/13.
|
||||
// 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 "RenderPlugin.h"
|
||||
|
||||
bool RenderPlugin::isMouseOnScreen() const {
|
||||
glm::ivec2 mousePosition = getTrueMousePosition();
|
||||
return (glm::all(glm::greaterThanEqual(mousePosition, glm::ivec2(0))) &&
|
||||
glm::all(glm::lessThanEqual(mousePosition, glm::ivec2(getCanvasSize()))));
|
||||
}
|
63
interface/src/plugins/render/RenderPlugin.h
Normal file
63
interface/src/plugins/render/RenderPlugin.h
Normal file
|
@ -0,0 +1,63 @@
|
|||
//
|
||||
// RenderPlugin.h
|
||||
//
|
||||
// Created by Bradley Austin Davis on 2014/04/13.
|
||||
// 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
|
||||
|
||||
#include "plugins/Plugin.h"
|
||||
|
||||
#include <QSize>
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtc/quaternion.hpp>
|
||||
#include <RegisteredMetaTypes.h>
|
||||
|
||||
class RenderPlugin : public Plugin {
|
||||
Q_OBJECT
|
||||
public:
|
||||
virtual bool isHmd() const { return false; }
|
||||
virtual bool isStereo() const { return false; }
|
||||
virtual bool isThrottled() const { return false; }
|
||||
|
||||
// Rendering support
|
||||
virtual void preRender() {};
|
||||
virtual void render(int finalSceneTexture) {};
|
||||
virtual void postRender() {};
|
||||
|
||||
// Pointer support
|
||||
virtual bool hasFocus() const = 0;
|
||||
virtual QSize getRecommendedFramebufferSize() const = 0;
|
||||
virtual glm::ivec2 getCanvasSize() const = 0;
|
||||
virtual glm::ivec2 getUiMousePosition() const = 0;
|
||||
virtual glm::ivec2 getTrueMousePosition() const = 0;
|
||||
virtual PickRay computePickRay(const glm::vec2 & pos) const = 0;
|
||||
virtual bool isMouseOnScreen() const;
|
||||
|
||||
// HMD specific methods
|
||||
// TODO move these into another class
|
||||
virtual glm::mat4 headPose() const {
|
||||
static const glm::mat4 pose; return pose;
|
||||
}
|
||||
virtual glm::quat headOrientation() const {
|
||||
static const glm::quat orientation; return orientation;
|
||||
}
|
||||
virtual glm::vec3 headTranslation() const {
|
||||
static const glm::vec3 tranlsation; return tranlsation;
|
||||
}
|
||||
virtual void abandonCalibration() {}
|
||||
virtual void resetSensors() {}
|
||||
|
||||
signals:
|
||||
void recommendedFramebufferSizeChanged(const QSize & size);
|
||||
void requestRender();
|
||||
|
||||
protected:
|
||||
virtual void makeCurrent() {}
|
||||
virtual void doneCurrent() {}
|
||||
virtual void swapBuffers() {}
|
||||
};
|
13
interface/src/plugins/render/SimpleRenderPlugin.cpp
Normal file
13
interface/src/plugins/render/SimpleRenderPlugin.cpp
Normal file
|
@ -0,0 +1,13 @@
|
|||
//
|
||||
// SimpleRenderPlugin.cpp
|
||||
//
|
||||
// Created by Bradley Austin Davis on 2014/04/13.
|
||||
// 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 "SimpleRenderPlugin.h"
|
||||
#include <RenderUtil.h>
|
||||
#include <QOpenGLContext>
|
||||
|
56
interface/src/plugins/render/SimpleRenderPlugin.h
Normal file
56
interface/src/plugins/render/SimpleRenderPlugin.h
Normal file
|
@ -0,0 +1,56 @@
|
|||
//
|
||||
// SimpleRenderPlugin.h
|
||||
//
|
||||
// Created by Bradley Austin Davis on 2014/04/13.
|
||||
// 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
|
||||
|
||||
#include "RenderPlugin.h"
|
||||
#include <QOpenGLContext>
|
||||
#include <GLMHelpers.h>
|
||||
#include <RenderUtil.h>
|
||||
|
||||
template <typename T>
|
||||
class SimpleRenderPlugin : public RenderPlugin {
|
||||
public:
|
||||
virtual void render(int finalSceneTexture) {
|
||||
makeCurrent();
|
||||
|
||||
glDisable(GL_LIGHTING);
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glBindTexture(GL_TEXTURE_2D, finalSceneTexture);
|
||||
renderFullscreenQuad();
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
|
||||
glPopMatrix();
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPopMatrix();
|
||||
|
||||
glEnable(GL_LIGHTING);
|
||||
|
||||
swapBuffers();
|
||||
doneCurrent();
|
||||
}
|
||||
|
||||
virtual glm::ivec2 getUiMousePosition() const {
|
||||
return getTrueMousePosition();
|
||||
}
|
||||
|
||||
virtual glm::ivec2 getTrueMousePosition() const {
|
||||
return toGlm(_window->mapFromGlobal(QCursor::pos()));
|
||||
}
|
||||
|
||||
protected:
|
||||
T * _window;
|
||||
};
|
10
interface/src/plugins/render/StereoRenderPlugin.cpp
Normal file
10
interface/src/plugins/render/StereoRenderPlugin.cpp
Normal file
|
@ -0,0 +1,10 @@
|
|||
//
|
||||
// StereoRenderPlugin.cpp
|
||||
//
|
||||
// Created by Bradley Austin Davis on 2014/04/13.
|
||||
// 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 "StereoRenderPlugin.h"
|
17
interface/src/plugins/render/StereoRenderPlugin.h
Normal file
17
interface/src/plugins/render/StereoRenderPlugin.h
Normal file
|
@ -0,0 +1,17 @@
|
|||
//
|
||||
// StereoRenderPlugin.h
|
||||
//
|
||||
// Created by Bradley Austin Davis on 2014/04/13.
|
||||
// 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
|
||||
#include "RenderPlugin.h"
|
||||
|
||||
class StereoRenderPlugin : public RenderPlugin {
|
||||
virtual bool isStereo() const final { return true; }
|
||||
};
|
||||
|
11
interface/src/plugins/render/Tv3dRenderPlugin.cpp
Normal file
11
interface/src/plugins/render/Tv3dRenderPlugin.cpp
Normal file
|
@ -0,0 +1,11 @@
|
|||
//
|
||||
// Tv3dRenderPlugin.cpp
|
||||
//
|
||||
// Created by Bradley Austin Davis on 2014/04/13.
|
||||
// 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 "Tv3dRenderPlugin.h"
|
13
interface/src/plugins/render/Tv3dRenderPlugin.h
Normal file
13
interface/src/plugins/render/Tv3dRenderPlugin.h
Normal file
|
@ -0,0 +1,13 @@
|
|||
//
|
||||
// Tv3dRenderPlugin.h
|
||||
//
|
||||
// Created by Bradley Austin Davis on 2014/04/13.
|
||||
// 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
|
||||
|
||||
#include "StereoRenderPlugin.h"
|
514
interface/src/plugins/render/WindowRenderPlugin.cpp
Normal file
514
interface/src/plugins/render/WindowRenderPlugin.cpp
Normal file
|
@ -0,0 +1,514 @@
|
|||
//
|
||||
// WindowRenderPlugin.cpp
|
||||
//
|
||||
// Created by Bradley Austin Davis on 2014/04/13.
|
||||
// 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 "WindowRenderPlugin.h"
|
||||
#include "RenderUtil.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
|
||||
WindowRenderPlugin::WindowRenderPlugin() {
|
||||
connect(&_timer, &QTimer::timeout, this, [&] {
|
||||
emit requestRender();
|
||||
});
|
||||
}
|
||||
|
||||
const QString WindowRenderPlugin::NAME("WindowRenderPlugin");
|
||||
|
||||
const QString & WindowRenderPlugin::getName() {
|
||||
return NAME;
|
||||
}
|
||||
|
||||
void WindowRenderPlugin::activate() {
|
||||
Q_ASSERT(nullptr == _window);
|
||||
|
||||
_context = new QOpenGLContext;
|
||||
|
||||
_window = new QWindow;
|
||||
_window->setSurfaceType(QSurface::OpenGLSurface);
|
||||
_window->installEventFilter(this);
|
||||
glMatrixMode(0);
|
||||
{
|
||||
QSurfaceFormat format;
|
||||
format.setDepthBufferSize(0);
|
||||
format.setStencilBufferSize(0);
|
||||
format.setVersion(4, 1);
|
||||
// Ugh....
|
||||
format.setProfile(QSurfaceFormat::OpenGLContextProfile::CompatibilityProfile);
|
||||
_window->setFormat(format);
|
||||
_context->setFormat(format);
|
||||
}
|
||||
|
||||
_context->setShareContext(QOpenGLContext::currentContext());
|
||||
_context->create();
|
||||
|
||||
_window->show();
|
||||
|
||||
_timer.start(8);
|
||||
}
|
||||
|
||||
void WindowRenderPlugin::deactivate() {
|
||||
_timer.stop();
|
||||
_context->doneCurrent();
|
||||
_context->deleteLater();
|
||||
_context = nullptr;
|
||||
_window->hide();
|
||||
_window->destroy();
|
||||
_window = nullptr;
|
||||
}
|
||||
|
||||
bool WindowRenderPlugin::eventFilter(QObject* object, QEvent* event) {
|
||||
switch (event->type()) {
|
||||
case QEvent::MouseButtonPress:
|
||||
case QEvent::MouseButtonRelease:
|
||||
case QEvent::KeyPress:
|
||||
case QEvent::KeyRelease:
|
||||
case QEvent::FocusIn:
|
||||
case QEvent::FocusOut:
|
||||
case QEvent::Resize:
|
||||
case QEvent::MouseMove:
|
||||
QCoreApplication::sendEvent(QCoreApplication::instance(), event);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
QSize WindowRenderPlugin::getRecommendedFramebufferSize() const {
|
||||
return _window->size();
|
||||
}
|
||||
|
||||
void WindowRenderPlugin::makeCurrent() {
|
||||
_context->makeCurrent(_window);
|
||||
QSize windowSize = _window->size();
|
||||
glViewport(0, 0, windowSize.width(), windowSize.height());
|
||||
}
|
||||
|
||||
void WindowRenderPlugin::doneCurrent() {
|
||||
_context->doneCurrent();
|
||||
}
|
||||
|
||||
void WindowRenderPlugin::swapBuffers() {
|
||||
_context->swapBuffers(_window);
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
|
||||
//
|
||||
// MainWindow.h
|
||||
// interface
|
||||
//
|
||||
// Created by Mohammed Nafees on 04/06/2014.
|
||||
// Copyright (c) 2014 High Fidelity, Inc. All rights reserved.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#ifndef __hifi__MainWindow__
|
||||
#define __hifi__MainWindow__
|
||||
|
||||
#include <QWindow>
|
||||
#include <QTimer>
|
||||
|
||||
#include <SettingHandle.h>
|
||||
|
||||
#define MSECS_PER_FRAME_WHEN_THROTTLED 66
|
||||
|
||||
class MainWindow : public QWindow {
|
||||
public:
|
||||
explicit MainWindow(QWindow* parent = NULL);
|
||||
|
||||
// Some helpers for compatiblity with QMainWindow
|
||||
void activateWindow() {
|
||||
requestActivate();
|
||||
}
|
||||
|
||||
bool isMinimized() const {
|
||||
return windowState() == Qt::WindowMinimized;
|
||||
}
|
||||
|
||||
void stopFrameTimer();
|
||||
|
||||
bool isThrottleRendering() const;
|
||||
|
||||
int getDeviceWidth() const;
|
||||
int getDeviceHeight() const;
|
||||
QSize getDeviceSize() const { return QSize(getDeviceWidth(), getDeviceHeight()); }
|
||||
|
||||
/*
|
||||
|
||||
|
||||
|
||||
private slots:
|
||||
void activeChanged(Qt::ApplicationState state);
|
||||
void throttleRender();
|
||||
bool eventFilter(QObject*, QEvent* event);
|
||||
*/
|
||||
public slots:
|
||||
void restoreGeometry();
|
||||
void saveGeometry();
|
||||
|
||||
signals:
|
||||
void windowGeometryChanged(QRect geometry);
|
||||
void windowShown(bool shown);
|
||||
|
||||
protected:
|
||||
virtual void moveEvent(QMoveEvent* event);
|
||||
virtual void resizeEvent(QResizeEvent* event);
|
||||
virtual void showEvent(QShowEvent* event);
|
||||
virtual void hideEvent(QHideEvent* event);
|
||||
virtual void changeEvent(QEvent* event);
|
||||
virtual void windowStateChanged(Qt::WindowState windowState);
|
||||
virtual void activeChanged();
|
||||
|
||||
virtual void initializeGL();
|
||||
virtual void paintGL();
|
||||
virtual void resizeGL(int width, int height);
|
||||
|
||||
private:
|
||||
Setting::Handle<QRect> _windowGeometry;
|
||||
Setting::Handle<int> _windowState;
|
||||
Qt::WindowState _lastState{ Qt::WindowNoState };
|
||||
QOpenGLContext * _context{ nullptr };
|
||||
QTimer _frameTimer;
|
||||
bool _throttleRendering{ false };
|
||||
int _idleRenderInterval{ MSECS_PER_FRAME_WHEN_THROTTLED };
|
||||
};
|
||||
|
||||
#endif /* defined(__hifi__MainWindow__) */
|
||||
|
||||
|
||||
|
||||
|
||||
//
|
||||
// MainWindow.cpp
|
||||
// interface
|
||||
//
|
||||
// Created by Mohammed Nafees on 04/06/2014.
|
||||
// Copyright (c) 2014 High Fidelity, Inc. All rights reserved.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDesktopWidget>
|
||||
#include <QEvent>
|
||||
#include <QMoveEvent>
|
||||
#include <QResizeEvent>
|
||||
#include <QShowEvent>
|
||||
#include <QHideEvent>
|
||||
#include <QWindowStateChangeEvent>
|
||||
|
||||
#include "Application.h"
|
||||
|
||||
#include "MainWindow.h"
|
||||
#include "Menu.h"
|
||||
#include "Util.h"
|
||||
|
||||
#include <QOpenGLContext>
|
||||
|
||||
|
||||
MainWindow::MainWindow(QWindow * parent) :
|
||||
QWindow(parent),
|
||||
_windowGeometry("WindowGeometry"),
|
||||
_windowState("WindowState", 0) {
|
||||
setSurfaceType(QSurface::OpenGLSurface);
|
||||
|
||||
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);
|
||||
// Ugh....
|
||||
format.setProfile(QSurfaceFormat::OpenGLContextProfile::CompatibilityProfile);
|
||||
setFormat(format);
|
||||
|
||||
_context = new QOpenGLContext;
|
||||
_context->setFormat(format);
|
||||
_context->create();
|
||||
|
||||
show();
|
||||
}
|
||||
|
||||
void MainWindow::restoreGeometry() {
|
||||
QRect geometry = _windowGeometry.get(qApp->desktop()->availableGeometry());
|
||||
setGeometry(geometry);
|
||||
|
||||
// Restore to maximized or full screen after restoring to windowed so that going windowed goes to good position and sizes.
|
||||
int state = _windowState.get(Qt::WindowNoState) & ~Qt::WindowActive;
|
||||
if (state != Qt::WindowNoState) {
|
||||
setWindowState((Qt::WindowState)state);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::saveGeometry() {
|
||||
// Did not use geometry() on purpose,
|
||||
// see http://doc.qt.io/qt-5/qsettings.html#restoring-the-state-of-a-gui-application
|
||||
_windowState.set((int)windowState());
|
||||
|
||||
// Save position and size only if windowed so that have good values for windowed after starting maximized or full screen.
|
||||
if (windowState() == Qt::WindowNoState) {
|
||||
_windowGeometry.set(geometry());
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::moveEvent(QMoveEvent* event) {
|
||||
emit windowGeometryChanged(QRect(event->pos(), size()));
|
||||
QWindow::moveEvent(event);
|
||||
}
|
||||
|
||||
void MainWindow::resizeEvent(QResizeEvent* event) {
|
||||
emit windowGeometryChanged(QRect(QPoint(x(), y()), event->size()));
|
||||
QWindow::resizeEvent(event);
|
||||
}
|
||||
|
||||
void MainWindow::showEvent(QShowEvent* event) {
|
||||
if (event->spontaneous()) {
|
||||
emit windowShown(true);
|
||||
}
|
||||
QWindow::showEvent(event);
|
||||
}
|
||||
|
||||
void MainWindow::hideEvent(QHideEvent* event) {
|
||||
if (event->spontaneous()) {
|
||||
emit windowShown(false);
|
||||
}
|
||||
QWindow::hideEvent(event);
|
||||
}
|
||||
|
||||
void MainWindow::windowStateChanged(Qt::WindowState windowState) {
|
||||
// If we're changing from minimized to non-minimized or vice versas, emit
|
||||
// a windowShown signal (i.e. don't emit the signal if we're going from
|
||||
// fullscreen to nostate
|
||||
if ((_lastState == Qt::WindowMinimized) ^ (windowState == Qt::WindowMinimized)) {
|
||||
emit windowShown(windowState != Qt::WindowMinimized);
|
||||
}
|
||||
|
||||
bool fullscreen = windowState == Qt::WindowFullScreen;
|
||||
if (fullscreen != Menu::getInstance()->isOptionChecked(MenuOption::Fullscreen)) {
|
||||
Menu::getInstance()->setIsOptionChecked(MenuOption::Fullscreen, fullscreen);
|
||||
}
|
||||
|
||||
_lastState = windowState;
|
||||
QWindow::windowStateChanged(windowState);
|
||||
}
|
||||
|
||||
void MainWindow::activeChanged() {
|
||||
if (isActive()) {
|
||||
emit windowShown(true);
|
||||
} else {
|
||||
emit windowShown(false);
|
||||
}
|
||||
QWindow::activeChanged();
|
||||
}
|
||||
|
||||
void MainWindow::stopFrameTimer() {
|
||||
_frameTimer.stop();
|
||||
}
|
||||
|
||||
bool MainWindow::isThrottleRendering() const {
|
||||
return _throttleRendering || isMinimized();
|
||||
}
|
||||
|
||||
|
||||
int MainWindow::getDeviceWidth() const {
|
||||
return width() * devicePixelRatio();
|
||||
}
|
||||
|
||||
int MainWindow::getDeviceHeight() const {
|
||||
return height() * devicePixelRatio();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void MainWindow::initializeGL() {
|
||||
Application::getInstance()->initializeGL();
|
||||
// setAttribute(Qt::WA_AcceptTouchEvents);
|
||||
// setAcceptDrops(true);
|
||||
connect(Application::getInstance(), SIGNAL(applicationStateChanged(Qt::ApplicationState)), this, SLOT(activeChanged(Qt::ApplicationState)));
|
||||
connect(&_frameTimer, SIGNAL(timeout()), this, SLOT(throttleRender()));
|
||||
}
|
||||
|
||||
void GLCanvas::resizeGL(int width, int height) {
|
||||
Application::getInstance()->resizeGL(width, height);
|
||||
}
|
||||
|
||||
void GLCanvas::paintGL() {
|
||||
if (!_throttleRendering && !Application::getInstance()->getWindow()->isMinimized()) {
|
||||
//Need accurate frame timing for the oculus rift
|
||||
if (OculusManager::isConnected()) {
|
||||
OculusManager::beginFrameTiming();
|
||||
}
|
||||
|
||||
Application::getInstance()->paintGL();
|
||||
|
||||
if (!OculusManager::isConnected()) {
|
||||
swapBuffers();
|
||||
} else {
|
||||
if (OculusManager::allowSwap()) {
|
||||
swapBuffers();
|
||||
}
|
||||
OculusManager::endFrameTiming();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
||||
GLCanvas::GLCanvas() : QGLWidget(QGL::NoDepthBuffer | QGL::NoStencilBuffer),
|
||||
#ifdef Q_OS_LINUX
|
||||
// Cause GLCanvas::eventFilter to be called.
|
||||
// It wouldn't hurt to do this on Mac and PC too; but apparently it's only needed on linux.
|
||||
qApp->installEventFilter(this);
|
||||
#endif
|
||||
}
|
||||
|
||||
void GLCanvas::keyPressEvent(QKeyEvent* event) {
|
||||
Application::getInstance()->keyPressEvent(event);
|
||||
}
|
||||
|
||||
void GLCanvas::keyReleaseEvent(QKeyEvent* event) {
|
||||
Application::getInstance()->keyReleaseEvent(event);
|
||||
}
|
||||
|
||||
void GLCanvas::focusOutEvent(QFocusEvent* event) {
|
||||
Application::getInstance()->focusOutEvent(event);
|
||||
}
|
||||
|
||||
void GLCanvas::mouseMoveEvent(QMouseEvent* event) {
|
||||
Application::getInstance()->mouseMoveEvent(event);
|
||||
}
|
||||
|
||||
void GLCanvas::mousePressEvent(QMouseEvent* event) {
|
||||
Application::getInstance()->mousePressEvent(event);
|
||||
}
|
||||
|
||||
void GLCanvas::mouseReleaseEvent(QMouseEvent* event) {
|
||||
Application::getInstance()->mouseReleaseEvent(event);
|
||||
}
|
||||
|
||||
void GLCanvas::activeChanged(Qt::ApplicationState state) {
|
||||
switch (state) {
|
||||
case Qt::ApplicationActive:
|
||||
// If we're active, stop the frame timer and the throttle.
|
||||
_frameTimer.stop();
|
||||
_throttleRendering = false;
|
||||
break;
|
||||
|
||||
case Qt::ApplicationSuspended:
|
||||
case Qt::ApplicationHidden:
|
||||
// If we're hidden or are about to suspend, don't render anything.
|
||||
_throttleRendering = false;
|
||||
_frameTimer.stop();
|
||||
break;
|
||||
|
||||
default:
|
||||
// Otherwise, throttle.
|
||||
if (!_throttleRendering && !Application::getInstance()->isAboutToQuit()) {
|
||||
_frameTimer.start(_idleRenderInterval);
|
||||
_throttleRendering = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void GLCanvas::throttleRender() {
|
||||
_frameTimer.start(_idleRenderInterval);
|
||||
if (!Application::getInstance()->getWindow()->isMinimized()) {
|
||||
//Need accurate frame timing for the oculus rift
|
||||
if (OculusManager::isConnected()) {
|
||||
OculusManager::beginFrameTiming();
|
||||
}
|
||||
|
||||
Application::getInstance()->paintGL();
|
||||
swapBuffers();
|
||||
|
||||
if (OculusManager::isConnected()) {
|
||||
OculusManager::endFrameTiming();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int updateTime = 0;
|
||||
bool GLCanvas::event(QEvent* event) {
|
||||
switch (event->type()) {
|
||||
case QEvent::TouchBegin:
|
||||
Application::getInstance()->touchBeginEvent(static_cast<QTouchEvent*>(event));
|
||||
event->accept();
|
||||
return true;
|
||||
case QEvent::TouchEnd:
|
||||
Application::getInstance()->touchEndEvent(static_cast<QTouchEvent*>(event));
|
||||
return true;
|
||||
case QEvent::TouchUpdate:
|
||||
Application::getInstance()->touchUpdateEvent(static_cast<QTouchEvent*>(event));
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return QGLWidget::event(event);
|
||||
}
|
||||
|
||||
void GLCanvas::wheelEvent(QWheelEvent* event) {
|
||||
Application::getInstance()->wheelEvent(event);
|
||||
}
|
||||
|
||||
void GLCanvas::dragEnterEvent(QDragEnterEvent* event) {
|
||||
const QMimeData* mimeData = event->mimeData();
|
||||
foreach(QUrl url, mimeData->urls()) {
|
||||
auto urlString = url.toString();
|
||||
if (Application::getInstance()->canAcceptURL(urlString)) {
|
||||
event->acceptProposedAction();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GLCanvas::dropEvent(QDropEvent* event) {
|
||||
Application::getInstance()->dropEvent(event);
|
||||
}
|
||||
|
||||
// Pressing Alt (and Meta) key alone activates the menubar because its style inherits the
|
||||
// SHMenuBarAltKeyNavigation from QWindowsStyle. This makes it impossible for a scripts to
|
||||
// receive keyPress events for the Alt (and Meta) key in a reliable manner.
|
||||
//
|
||||
// This filter catches events before QMenuBar can steal the keyboard focus.
|
||||
// The idea was borrowed from
|
||||
// http://www.archivum.info/qt-interest@trolltech.com/2006-09/00053/Re-(Qt4)-Alt-key-focus-QMenuBar-(solved).html
|
||||
|
||||
bool GLCanvas::eventFilter(QObject*, QEvent* event) {
|
||||
switch (event->type()) {
|
||||
case QEvent::KeyPress:
|
||||
case QEvent::KeyRelease:
|
||||
case QEvent::ShortcutOverride:
|
||||
{
|
||||
QKeyEvent* keyEvent = static_cast<QKeyEvent*>(event);
|
||||
if (keyEvent->key() == Qt::Key_Alt || keyEvent->key() == Qt::Key_Meta) {
|
||||
if (event->type() == QEvent::KeyPress) {
|
||||
keyPressEvent(keyEvent);
|
||||
} else if (event->type() == QEvent::KeyRelease) {
|
||||
keyReleaseEvent(keyEvent);
|
||||
} else {
|
||||
QGLWidget::event(event);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
*/
|
||||
#endif
|
40
interface/src/plugins/render/WindowRenderPlugin.h
Normal file
40
interface/src/plugins/render/WindowRenderPlugin.h
Normal file
|
@ -0,0 +1,40 @@
|
|||
//
|
||||
// WindowRenderPlugin.h
|
||||
//
|
||||
// Created by Bradley Austin Davis on 2014/04/13.
|
||||
// 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
|
||||
|
||||
#include "SimpleRenderPlugin.h"
|
||||
|
||||
#include <QWindow>
|
||||
#include <QOpenGLContext>
|
||||
#include <QTimer>
|
||||
|
||||
class WindowRenderPlugin : public SimpleRenderPlugin<QWindow> {
|
||||
Q_OBJECT
|
||||
public:
|
||||
static const QString NAME;
|
||||
|
||||
WindowRenderPlugin();
|
||||
|
||||
virtual const QString & getName();
|
||||
|
||||
virtual void activate();
|
||||
virtual void deactivate();
|
||||
virtual bool eventFilter(QObject* object, QEvent* event);
|
||||
virtual QSize getRecommendedFramebufferSize() const;
|
||||
|
||||
protected:
|
||||
virtual void makeCurrent();
|
||||
virtual void doneCurrent();
|
||||
virtual void swapBuffers();
|
||||
|
||||
private:
|
||||
QTimer _timer;
|
||||
QOpenGLContext * _context{ nullptr };
|
||||
};
|
|
@ -286,8 +286,7 @@ void ControllerScriptingInterface::releaseJoystick(int joystickIndex) {
|
|||
}
|
||||
|
||||
glm::vec2 ControllerScriptingInterface::getViewportDimensions() const {
|
||||
auto glCanvas = Application::getInstance()->getGLWidget();
|
||||
return glm::vec2(glCanvas->width(), glCanvas->height());
|
||||
return Application::getInstance()->getCanvasSize();
|
||||
}
|
||||
|
||||
AbstractInputController* ControllerScriptingInterface::createInputController(const QString& deviceName, const QString& tracker) {
|
||||
|
|
|
@ -41,7 +41,7 @@ WebWindowClass* WindowScriptingInterface::doCreateWebWindow(const QString& title
|
|||
}
|
||||
|
||||
QScriptValue WindowScriptingInterface::hasFocus() {
|
||||
return Application::getInstance()->getGLWidget()->hasFocus();
|
||||
return Application::getInstance()->hasFocus();
|
||||
}
|
||||
|
||||
void WindowScriptingInterface::setFocus() {
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "InterfaceConfig.h"
|
||||
|
||||
#include <QOpenGLFramebufferObject>
|
||||
#include <QOpenGLTexture>
|
||||
|
||||
#include <avatar/AvatarManager.h>
|
||||
#include <GLMHelpers.h>
|
||||
|
@ -167,13 +168,13 @@ ApplicationOverlay::~ApplicationOverlay() {
|
|||
}
|
||||
|
||||
// Renders the overlays either to a texture or to the screen
|
||||
void ApplicationOverlay::renderOverlay(bool renderToTexture) {
|
||||
void ApplicationOverlay::renderOverlay() {
|
||||
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), "ApplicationOverlay::displayOverlay()");
|
||||
Overlays& overlays = qApp->getOverlays();
|
||||
auto glCanvas = Application::getInstance()->getGLWidget();
|
||||
|
||||
_textureFov = glm::radians(_oculusUIAngularSize);
|
||||
_textureAspectRatio = (float)glCanvas->getDeviceWidth() / (float)glCanvas->getDeviceHeight();
|
||||
glm::vec2 canvasSize = Application::getInstance()->getCanvasSize();
|
||||
_textureAspectRatio = canvasSize.x / canvasSize.y;;
|
||||
|
||||
//Handle fading and deactivation/activation of UI
|
||||
|
||||
|
@ -183,17 +184,15 @@ void ApplicationOverlay::renderOverlay(bool renderToTexture) {
|
|||
glDisable(GL_LIGHTING);
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
if (renderToTexture) {
|
||||
_overlays.buildFramebufferObject();
|
||||
_overlays.bind();
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
}
|
||||
_overlays.buildFramebufferObject();
|
||||
_overlays.bind();
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
glPushMatrix(); {
|
||||
const float NEAR_CLIP = -10000;
|
||||
const float FAR_CLIP = 10000;
|
||||
glLoadIdentity();
|
||||
glOrtho(0, glCanvas->width(), glCanvas->height(), 0, NEAR_CLIP, FAR_CLIP);
|
||||
glOrtho(0, canvasSize.x, canvasSize.y, 0, NEAR_CLIP, FAR_CLIP);
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
|
||||
|
@ -217,10 +216,7 @@ void ApplicationOverlay::renderOverlay(bool renderToTexture) {
|
|||
glEnable(GL_DEPTH_TEST);
|
||||
glEnable(GL_LIGHTING);
|
||||
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_CONSTANT_ALPHA, GL_ONE);
|
||||
|
||||
if (renderToTexture) {
|
||||
_overlays.release();
|
||||
}
|
||||
_overlays.release();
|
||||
}
|
||||
|
||||
// Draws the FBO texture for the screen
|
||||
|
@ -228,7 +224,6 @@ void ApplicationOverlay::displayOverlayTexture() {
|
|||
if (_alpha == 0.0f) {
|
||||
return;
|
||||
}
|
||||
auto glCanvas = Application::getInstance()->getGLWidget();
|
||||
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
|
@ -237,15 +232,15 @@ void ApplicationOverlay::displayOverlayTexture() {
|
|||
glMatrixMode(GL_PROJECTION);
|
||||
glPushMatrix(); {
|
||||
glLoadIdentity();
|
||||
glOrtho(0, glCanvas->getDeviceWidth(), glCanvas->getDeviceHeight(), 0, -1.0, 1.0);
|
||||
glOrtho(0, 1, 1, 0, -1.0, 1.0);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glDisable(GL_LIGHTING);
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
glm::vec2 topLeft(0.0f, 0.0f);
|
||||
glm::vec2 bottomRight(glCanvas->getDeviceWidth(), glCanvas->getDeviceHeight());
|
||||
glm::vec2 texCoordTopLeft(0.0f, 1.0f);
|
||||
glm::vec2 texCoordBottomRight(1.0f, 0.0f);
|
||||
static const glm::vec2 topLeft(0);
|
||||
static const glm::vec2 bottomRight(1);
|
||||
static const glm::vec2 texCoordTopLeft(0.0f, 1.0f);
|
||||
static const glm::vec2 texCoordBottomRight(1.0f, 0.0f);
|
||||
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight, texCoordTopLeft, texCoordBottomRight,
|
||||
glm::vec4(1.0f, 1.0f, 1.0f, _alpha));
|
||||
|
@ -255,6 +250,7 @@ void ApplicationOverlay::displayOverlayTexture() {
|
|||
glDisable(GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
#if 0
|
||||
// Draws the FBO texture for Oculus rift.
|
||||
void ApplicationOverlay::displayOverlayTextureOculus(Camera& whichCamera) {
|
||||
if (_alpha == 0.0f) {
|
||||
|
@ -440,10 +436,10 @@ void ApplicationOverlay::computeOculusPickRay(float x, float y, glm::vec3& origi
|
|||
origin = myAvatar->getEyePosition();
|
||||
direction = cursorPos - origin;
|
||||
}
|
||||
#endif
|
||||
|
||||
//Caculate the click location using one of the sixense controllers. Scale is not applied
|
||||
QPoint ApplicationOverlay::getPalmClickLocation(const PalmData *palm) const {
|
||||
auto glCanvas = Application::getInstance()->getGLWidget();
|
||||
MyAvatar* myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar();
|
||||
|
||||
glm::vec3 tip = myAvatar->getLaserPointerTipPosition(palm);
|
||||
|
@ -454,8 +450,9 @@ QPoint ApplicationOverlay::getPalmClickLocation(const PalmData *palm) const {
|
|||
glm::vec3 tipPos = invOrientation * (tip - eyePos);
|
||||
|
||||
QPoint rv;
|
||||
|
||||
#if 0
|
||||
if (OculusManager::isConnected()) {
|
||||
auto glCanvas = Application::getInstance()->getGLWidget();
|
||||
float t;
|
||||
|
||||
//We back the ray up by dir to ensure that it will not start inside the UI.
|
||||
|
@ -483,6 +480,7 @@ QPoint ApplicationOverlay::getPalmClickLocation(const PalmData *palm) const {
|
|||
rv.setY(INT_MAX);
|
||||
}
|
||||
} else {
|
||||
#endif
|
||||
glm::dmat4 projection;
|
||||
qApp->getProjectionMatrix(&projection);
|
||||
|
||||
|
@ -492,9 +490,12 @@ QPoint ApplicationOverlay::getPalmClickLocation(const PalmData *palm) const {
|
|||
ndcSpacePos = glm::vec3(clipSpacePos) / clipSpacePos.w;
|
||||
}
|
||||
|
||||
rv.setX(((ndcSpacePos.x + 1.0) / 2.0) * glCanvas->width());
|
||||
rv.setY((1.0 - ((ndcSpacePos.y + 1.0) / 2.0)) * glCanvas->height());
|
||||
glm::ivec2 canvasSize = Application::getInstance()->getCanvasSize();
|
||||
rv.setX(((ndcSpacePos.x + 1.0) / 2.0) * canvasSize.x);
|
||||
rv.setY((1.0 - ((ndcSpacePos.y + 1.0) / 2.0)) * canvasSize.y);
|
||||
#if 0
|
||||
}
|
||||
#endif
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -518,18 +519,19 @@ bool ApplicationOverlay::calculateRayUICollisionPoint(const glm::vec3& position,
|
|||
|
||||
//Renders optional pointers
|
||||
void ApplicationOverlay::renderPointers() {
|
||||
auto glCanvas = Application::getInstance()->getGLWidget();
|
||||
|
||||
//lazily load crosshair texture
|
||||
if (_crosshairTexture == 0) {
|
||||
_crosshairTexture = glCanvas->bindTexture(QImage(PathUtils::resourcesPath() + "images/sixense-reticle.png"));
|
||||
_crosshairTexture = new QOpenGLTexture(QImage(PathUtils::resourcesPath() + "images/sixense-reticle.png"));
|
||||
}
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, _crosshairTexture);
|
||||
|
||||
_crosshairTexture->bind();
|
||||
#if 0
|
||||
|
||||
if (OculusManager::isConnected() && !qApp->getLastMouseMoveWasSimulated() && !qApp->isMouseHidden()) {
|
||||
auto glCanvas = Application::getInstance()->getGLWidget();
|
||||
//If we are in oculus, render reticle later
|
||||
if (_lastMouseMove == 0) {
|
||||
_lastMouseMove = usecTimestampNow();
|
||||
|
@ -564,7 +566,9 @@ void ApplicationOverlay::renderPointers() {
|
|||
_magActive[MOUSE] = _magnifier;
|
||||
_reticleActive[LEFT_CONTROLLER] = false;
|
||||
_reticleActive[RIGHT_CONTROLLER] = false;
|
||||
} else if (qApp->getLastMouseMoveWasSimulated() && Menu::getInstance()->isOptionChecked(MenuOption::SixenseMouseInput)) {
|
||||
} else
|
||||
#endif
|
||||
if (qApp->getLastMouseMoveWasSimulated() && Menu::getInstance()->isOptionChecked(MenuOption::SixenseMouseInput)) {
|
||||
_lastMouseMove = 0;
|
||||
//only render controller pointer if we aren't already rendering a mouse pointer
|
||||
_reticleActive[MOUSE] = false;
|
||||
|
@ -576,6 +580,7 @@ void ApplicationOverlay::renderPointers() {
|
|||
}
|
||||
|
||||
void ApplicationOverlay::renderControllerPointers() {
|
||||
#if 0
|
||||
auto glCanvas = Application::getInstance()->getGLWidget();
|
||||
MyAvatar* myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar();
|
||||
|
||||
|
@ -683,10 +688,12 @@ void ApplicationOverlay::renderControllerPointers() {
|
|||
glm::vec4(RETICLE_COLOR[0], RETICLE_COLOR[1], RETICLE_COLOR[2], 1.0f));
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void ApplicationOverlay::renderPointersOculus(const glm::vec3& eyePos) {
|
||||
glBindTexture(GL_TEXTURE_2D, _crosshairTexture);
|
||||
_crosshairTexture->bind();
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
|
||||
|
@ -723,10 +730,10 @@ void ApplicationOverlay::renderMagnifier(glm::vec2 magPos, float sizeMult, bool
|
|||
if (!_magnifier) {
|
||||
return;
|
||||
}
|
||||
auto glCanvas = Application::getInstance()->getGLWidget();
|
||||
auto canvasSize = Application::getInstance()->getCanvasSize();
|
||||
|
||||
const int widgetWidth = glCanvas->width();
|
||||
const int widgetHeight = glCanvas->height();
|
||||
const int widgetWidth = canvasSize.x;
|
||||
const int widgetHeight = canvasSize.y;
|
||||
|
||||
const float halfWidth = (MAGNIFY_WIDTH / _textureAspectRatio) * sizeMult / 2.0f;
|
||||
const float halfHeight = MAGNIFY_HEIGHT * sizeMult / 2.0f;
|
||||
|
@ -788,6 +795,7 @@ void ApplicationOverlay::renderMagnifier(glm::vec2 magPos, float sizeMult, bool
|
|||
}
|
||||
|
||||
void ApplicationOverlay::renderAudioMeter() {
|
||||
#if 0
|
||||
auto glCanvas = Application::getInstance()->getGLWidget();
|
||||
auto audio = DependencyManager::get<AudioClient>();
|
||||
|
||||
|
@ -900,9 +908,11 @@ void ApplicationOverlay::renderAudioMeter() {
|
|||
audioLevel, AUDIO_METER_HEIGHT, quadColor,
|
||||
_audioBlueQuad);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void ApplicationOverlay::renderStatsAndLogs() {
|
||||
#if 0
|
||||
Application* application = Application::getInstance();
|
||||
QSharedPointer<BandwidthRecorder> bandwidthRecorder = DependencyManager::get<BandwidthRecorder>();
|
||||
|
||||
|
@ -938,9 +948,11 @@ void ApplicationOverlay::renderStatsAndLogs() {
|
|||
0.30f, 0.0f, 0, frameTimer.toUtf8().constData(), WHITE_TEXT);
|
||||
}
|
||||
nodeBoundsDisplay.drawOverlay();
|
||||
#endif
|
||||
}
|
||||
|
||||
void ApplicationOverlay::renderDomainConnectionStatusBorder() {
|
||||
#if 0
|
||||
auto nodeList = DependencyManager::get<NodeList>();
|
||||
|
||||
if (nodeList && !nodeList->getDomainHandler().isConnected()) {
|
||||
|
@ -969,6 +981,7 @@ void ApplicationOverlay::renderDomainConnectionStatusBorder() {
|
|||
|
||||
geometryCache->renderVertices(gpu::LINE_STRIP, _domainStatusBorder);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
ApplicationOverlay::TexturedHemisphere::TexturedHemisphere() :
|
||||
|
@ -1088,7 +1101,7 @@ void ApplicationOverlay::TexturedHemisphere::cleanupVBO() {
|
|||
}
|
||||
|
||||
void ApplicationOverlay::TexturedHemisphere::buildFramebufferObject() {
|
||||
QSize size = Application::getInstance()->getGLWidget()->getDeviceSize();
|
||||
QSize size = Application::getInstance()->getDeviceSize();
|
||||
if (_framebufferObject != NULL && size == _framebufferObject->size()) {
|
||||
// Already build
|
||||
return;
|
||||
|
@ -1159,7 +1172,7 @@ glm::vec3 ApplicationOverlay::sphericalToDirection(glm::vec2 sphericalPos) const
|
|||
}
|
||||
|
||||
glm::vec2 ApplicationOverlay::screenToSpherical(glm::vec2 screenPos) const {
|
||||
QSize screenSize = Application::getInstance()->getGLWidget()->getDeviceSize();
|
||||
QSize screenSize = Application::getInstance()->getDeviceSize();
|
||||
float yaw = -(screenPos.x / screenSize.width() - 0.5f) * MOUSE_YAW_RANGE;
|
||||
float pitch = (screenPos.y / screenSize.height() - 0.5f) * MOUSE_PITCH_RANGE;
|
||||
|
||||
|
@ -1167,7 +1180,7 @@ glm::vec2 ApplicationOverlay::screenToSpherical(glm::vec2 screenPos) const {
|
|||
}
|
||||
|
||||
glm::vec2 ApplicationOverlay::sphericalToScreen(glm::vec2 sphericalPos) const {
|
||||
QSize screenSize = Application::getInstance()->getGLWidget()->getDeviceSize();
|
||||
QSize screenSize = Application::getInstance()->getDeviceSize();
|
||||
float x = (-sphericalPos.x / MOUSE_YAW_RANGE + 0.5f) * screenSize.width();
|
||||
float y = (sphericalPos.y / MOUSE_PITCH_RANGE + 0.5f) * screenSize.height();
|
||||
|
||||
|
@ -1175,7 +1188,7 @@ glm::vec2 ApplicationOverlay::sphericalToScreen(glm::vec2 sphericalPos) const {
|
|||
}
|
||||
|
||||
glm::vec2 ApplicationOverlay::sphericalToOverlay(glm::vec2 sphericalPos) const {
|
||||
QSize screenSize = Application::getInstance()->getGLWidget()->getDeviceSize();
|
||||
QSize screenSize = Application::getInstance()->getDeviceSize();
|
||||
float x = (-sphericalPos.x / (_textureFov * _textureAspectRatio) + 0.5f) * screenSize.width();
|
||||
float y = (sphericalPos.y / _textureFov + 0.5f) * screenSize.height();
|
||||
|
||||
|
@ -1183,7 +1196,7 @@ glm::vec2 ApplicationOverlay::sphericalToOverlay(glm::vec2 sphericalPos) const {
|
|||
}
|
||||
|
||||
glm::vec2 ApplicationOverlay::overlayToSpherical(glm::vec2 overlayPos) const {
|
||||
QSize screenSize = Application::getInstance()->getGLWidget()->getDeviceSize();
|
||||
QSize screenSize = Application::getInstance()->getDeviceSize();
|
||||
float yaw = -(overlayPos.x / screenSize.width() - 0.5f) * _textureFov * _textureAspectRatio;
|
||||
float pitch = (overlayPos.y / screenSize.height() - 0.5f) * _textureFov;
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
class Camera;
|
||||
class Overlays;
|
||||
class QOpenGLFramebufferObject;
|
||||
class QOpenGLTexture;
|
||||
|
||||
const float MAGNIFY_WIDTH = 220.0f;
|
||||
const float MAGNIFY_HEIGHT = 100.0f;
|
||||
|
@ -28,21 +29,26 @@ public:
|
|||
ApplicationOverlay();
|
||||
~ApplicationOverlay();
|
||||
|
||||
void renderOverlay(bool renderToTexture = false);
|
||||
void renderOverlay();
|
||||
|
||||
void displayOverlayTexture();
|
||||
#if 0
|
||||
void displayOverlayTextureOculus(Camera& whichCamera);
|
||||
void displayOverlayTexture3DTV(Camera& whichCamera, float aspectRatio, float fov);
|
||||
|
||||
void computeOculusPickRay(float x, float y, glm::vec3& origin, glm::vec3& direction) const;
|
||||
#endif
|
||||
|
||||
QPoint getPalmClickLocation(const PalmData *palm) const;
|
||||
bool calculateRayUICollisionPoint(const glm::vec3& position, const glm::vec3& direction, glm::vec3& result) const;
|
||||
|
||||
bool hasMagnifier() const { return _magnifier; }
|
||||
void toggleMagnifier() { _magnifier = !_magnifier; }
|
||||
|
||||
#if 0
|
||||
float getOculusUIAngularSize() const { return _oculusUIAngularSize; }
|
||||
void setOculusUIAngularSize(float oculusUIAngularSize) { _oculusUIAngularSize = oculusUIAngularSize; }
|
||||
|
||||
#endif
|
||||
|
||||
// Converter from one frame of reference to another.
|
||||
// Frame of reference:
|
||||
// Direction: Ray that represents the spherical values
|
||||
|
@ -121,7 +127,7 @@ private:
|
|||
float _oculusUIRadius;
|
||||
float _trailingAudioLoudness;
|
||||
|
||||
GLuint _crosshairTexture;
|
||||
QOpenGLTexture * _crosshairTexture;
|
||||
|
||||
int _reticleQuad;
|
||||
int _magnifierQuad;
|
||||
|
|
|
@ -56,10 +56,11 @@ void DialogsManager::showLoginDialog() {
|
|||
void DialogsManager::octreeStatsDetails() {
|
||||
if (!_octreeStatsDialog) {
|
||||
_octreeStatsDialog = new OctreeStatsDialog(qApp->getWindow(), qApp->getOcteeSceneStats());
|
||||
|
||||
#if 0
|
||||
if (_hmdToolsDialog) {
|
||||
_hmdToolsDialog->watchWindow(_octreeStatsDialog->windowHandle());
|
||||
}
|
||||
#endif
|
||||
connect(_octreeStatsDialog, SIGNAL(closed()), _octreeStatsDialog, SLOT(deleteLater()));
|
||||
_octreeStatsDialog->show();
|
||||
}
|
||||
|
@ -107,11 +108,12 @@ void DialogsManager::bandwidthDetails() {
|
|||
if (! _bandwidthDialog) {
|
||||
_bandwidthDialog = new BandwidthDialog(qApp->getWindow());
|
||||
connect(_bandwidthDialog, SIGNAL(closed()), _bandwidthDialog, SLOT(deleteLater()));
|
||||
|
||||
#if 0
|
||||
if (_hmdToolsDialog) {
|
||||
_hmdToolsDialog->watchWindow(_bandwidthDialog->windowHandle());
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
_bandwidthDialog->show();
|
||||
}
|
||||
_bandwidthDialog->raise();
|
||||
|
@ -133,6 +135,7 @@ void DialogsManager::toggleToolWindow() {
|
|||
}
|
||||
|
||||
void DialogsManager::hmdTools(bool showTools) {
|
||||
#if 0
|
||||
if (showTools) {
|
||||
if (!_hmdToolsDialog) {
|
||||
maybeCreateDialog(_hmdToolsDialog);
|
||||
|
@ -144,11 +147,14 @@ void DialogsManager::hmdTools(bool showTools) {
|
|||
hmdToolsClosed();
|
||||
}
|
||||
qApp->getWindow()->activateWindow();
|
||||
#endif
|
||||
}
|
||||
|
||||
void DialogsManager::hmdToolsClosed() {
|
||||
#if 0
|
||||
Menu::getInstance()->getActionForOption(MenuOption::HMDTools)->setChecked(false);
|
||||
_hmdToolsDialog->hide();
|
||||
#endif
|
||||
}
|
||||
|
||||
void DialogsManager::showScriptEditor() {
|
||||
|
|
|
@ -40,7 +40,7 @@ class DialogsManager : public QObject, public Dependency {
|
|||
|
||||
public:
|
||||
QPointer<BandwidthDialog> getBandwidthDialog() const { return _bandwidthDialog; }
|
||||
QPointer<HMDToolsDialog> getHMDToolsDialog() const { return _hmdToolsDialog; }
|
||||
// QPointer<HMDToolsDialog> getHMDToolsDialog() const { return _hmdToolsDialog; }
|
||||
QPointer<LodToolsDialog> getLodToolsDialog() const { return _lodToolsDialog; }
|
||||
QPointer<OctreeStatsDialog> getOctreeStatsDialog() const { return _octreeStatsDialog; }
|
||||
|
||||
|
@ -75,9 +75,12 @@ private:
|
|||
member = new T(parent);
|
||||
Q_CHECK_PTR(member);
|
||||
|
||||
#if 0
|
||||
if (_hmdToolsDialog && member->windowHandle()) {
|
||||
_hmdToolsDialog->watchWindow(member->windowHandle());
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -88,7 +91,7 @@ private:
|
|||
QPointer<CachesSizeDialog> _cachesSizeDialog;
|
||||
QPointer<DiskCacheEditor> _diskCacheEditor;
|
||||
QPointer<QMessageBox> _ircInfoBox;
|
||||
QPointer<HMDToolsDialog> _hmdToolsDialog;
|
||||
// QPointer<HMDToolsDialog> _hmdToolsDialog;
|
||||
QPointer<LodToolsDialog> _lodToolsDialog;
|
||||
QPointer<LoginDialog> _loginDialog;
|
||||
QPointer<OctreeStatsDialog> _octreeStatsDialog;
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
#if 0
|
||||
|
||||
#include <QFormLayout>
|
||||
#include <QGuiApplication>
|
||||
|
@ -340,4 +341,4 @@ void HMDWindowWatcher::windowScreenChanged(QScreen* screen) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
#ifndef hifi_HMDToolsDialog_h
|
||||
#define hifi_HMDToolsDialog_h
|
||||
|
||||
#if 0
|
||||
#include <QDialog>
|
||||
|
||||
class HMDWindowWatcher;
|
||||
|
@ -84,5 +84,6 @@ private:
|
|||
QRect _previousRect;
|
||||
QScreen* _previousScreen;
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif // hifi_HMDToolsDialog_h
|
||||
|
|
|
@ -39,8 +39,7 @@ void NodeBounds::draw() {
|
|||
// Compute ray to find selected nodes later on. We can't use the pre-computed ray in Application because it centers
|
||||
// itself after the cursor disappears.
|
||||
Application* application = Application::getInstance();
|
||||
PickRay pickRay = application->getCamera()->computePickRay(application->getTrueMouseX(),
|
||||
application->getTrueMouseY());
|
||||
PickRay pickRay = application->computePickRay();
|
||||
|
||||
// Variables to keep track of the selected node and properties to draw the cube later if needed
|
||||
Node* selectedNode = NULL;
|
||||
|
|
|
@ -192,9 +192,9 @@ void PreferencesDialog::loadPreferences() {
|
|||
ui.avatarScaleSpin->setValue(myAvatar->getScale());
|
||||
|
||||
ui.maxOctreePPSSpin->setValue(qApp->getOctreeQuery().getMaxOctreePacketsPerSecond());
|
||||
|
||||
#if 0
|
||||
ui.oculusUIAngularSizeSpin->setValue(qApp->getApplicationOverlay().getOculusUIAngularSize());
|
||||
|
||||
#endif
|
||||
SixenseManager& sixense = SixenseManager::getInstance();
|
||||
ui.sixenseReticleMoveSpeedSpin->setValue(sixense.getReticleMoveSpeed());
|
||||
ui.invertSixenseButtonsCheckBox->setChecked(sixense.getInvertButtons());
|
||||
|
@ -266,8 +266,7 @@ void PreferencesDialog::savePreferences() {
|
|||
myAvatar->setLeanScale(ui.leanScaleSpin->value());
|
||||
myAvatar->setClampedTargetScale(ui.avatarScaleSpin->value());
|
||||
|
||||
auto glCanvas = Application::getInstance()->getGLWidget();
|
||||
Application::getInstance()->resizeGL(glCanvas->width(), glCanvas->height());
|
||||
Application::getInstance()->resizeGL();
|
||||
|
||||
DependencyManager::get<AvatarManager>()->getMyAvatar()->setRealWorldFieldOfView(ui.realWorldFieldOfViewSpin->value());
|
||||
|
||||
|
@ -280,9 +279,9 @@ void PreferencesDialog::savePreferences() {
|
|||
faceshift->setHostname(ui.faceshiftHostnameEdit->text());
|
||||
|
||||
qApp->getOctreeQuery().setMaxOctreePacketsPerSecond(ui.maxOctreePPSSpin->value());
|
||||
|
||||
#if 0
|
||||
qApp->getApplicationOverlay().setOculusUIAngularSize(ui.oculusUIAngularSizeSpin->value());
|
||||
|
||||
#endif
|
||||
SixenseManager& sixense = SixenseManager::getInstance();
|
||||
sixense.setReticleMoveSpeed(ui.sixenseReticleMoveSpeedSpin->value());
|
||||
sixense.setInvertButtons(ui.invertSixenseButtonsCheckBox->isChecked());
|
||||
|
@ -305,7 +304,7 @@ void PreferencesDialog::savePreferences() {
|
|||
audio->setOutputStarveDetectionThreshold(ui.outputStarveDetectionThresholdSpinner->value());
|
||||
audio->setOutputStarveDetectionPeriod(ui.outputStarveDetectionPeriodSpinner->value());
|
||||
|
||||
Application::getInstance()->resizeGL(glCanvas->width(), glCanvas->height());
|
||||
Application::getInstance()->resizeGL();
|
||||
|
||||
// LOD items
|
||||
auto lodManager = DependencyManager::get<LODManager>();
|
||||
|
|
|
@ -28,16 +28,15 @@ const char ZOOM_LEVEL_SETTINGS[] = "ZoomLevel";
|
|||
Setting::Handle<int> RearMirrorTools::rearViewZoomLevel(QStringList() << SETTINGS_GROUP_NAME << ZOOM_LEVEL_SETTINGS,
|
||||
ZoomLevel::HEAD);
|
||||
|
||||
RearMirrorTools::RearMirrorTools(QGLWidget* parent, QRect& bounds) :
|
||||
_parent(parent),
|
||||
RearMirrorTools::RearMirrorTools(QRect& bounds) :
|
||||
_bounds(bounds),
|
||||
_windowed(false),
|
||||
_fullScreen(false)
|
||||
{
|
||||
_closeTextureId = _parent->bindTexture(QImage(PathUtils::resourcesPath() + "images/close.svg"));
|
||||
_closeTextureId = new QOpenGLTexture(QImage(PathUtils::resourcesPath() + "images/close.svg"));
|
||||
|
||||
_zoomHeadTextureId = _parent->bindTexture(QImage(PathUtils::resourcesPath() + "images/plus.svg"));
|
||||
_zoomBodyTextureId = _parent->bindTexture(QImage(PathUtils::resourcesPath() + "images/minus.svg"));
|
||||
_zoomHeadTextureId = new QOpenGLTexture(QImage(PathUtils::resourcesPath() + "images/plus.svg"));
|
||||
_zoomBodyTextureId = new QOpenGLTexture(QImage(PathUtils::resourcesPath() + "images/minus.svg"));
|
||||
|
||||
_shrinkIconRect = QRect(ICON_PADDING, ICON_PADDING, ICON_SIZE, ICON_SIZE);
|
||||
_closeIconRect = QRect(_bounds.left() + ICON_PADDING, _bounds.top() + ICON_PADDING, ICON_SIZE, ICON_SIZE);
|
||||
|
@ -47,6 +46,7 @@ RearMirrorTools::RearMirrorTools(QGLWidget* parent, QRect& bounds) :
|
|||
}
|
||||
|
||||
void RearMirrorTools::render(bool fullScreen) {
|
||||
#if 0
|
||||
if (fullScreen) {
|
||||
_fullScreen = true;
|
||||
displayIcon(_parent->geometry(), _shrinkIconRect, _closeTextureId);
|
||||
|
@ -62,6 +62,7 @@ void RearMirrorTools::render(bool fullScreen) {
|
|||
displayIcon(_bounds, _bodyZoomIconRect, _zoomBodyTextureId, zoomLevel == BODY);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
bool RearMirrorTools::mousePressEvent(int x, int y) {
|
||||
|
@ -99,7 +100,7 @@ bool RearMirrorTools::mousePressEvent(int x, int y) {
|
|||
return false;
|
||||
}
|
||||
|
||||
void RearMirrorTools::displayIcon(QRect bounds, QRect iconBounds, GLuint textureId, bool selected) {
|
||||
void RearMirrorTools::displayIcon(QRect bounds, QRect iconBounds, QOpenGLTexture * texture, bool selected) {
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPushMatrix();
|
||||
|
@ -116,13 +117,13 @@ void RearMirrorTools::displayIcon(QRect bounds, QRect iconBounds, GLuint texture
|
|||
} else {
|
||||
quadColor = glm::vec4(1, 1, 1, 1);
|
||||
}
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, textureId);
|
||||
|
||||
texture->bind();
|
||||
|
||||
glm::vec2 topLeft(iconBounds.left(), iconBounds.top());
|
||||
glm::vec2 bottomRight(iconBounds.right(), iconBounds.bottom());
|
||||
glm::vec2 texCoordTopLeft(0.0f, 1.0f);
|
||||
glm::vec2 texCoordBottomRight(1.0f, 0.0f);
|
||||
static const glm::vec2 texCoordTopLeft(0.0f, 1.0f);
|
||||
static const glm::vec2 texCoordBottomRight(1.0f, 0.0f);
|
||||
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight, texCoordTopLeft, texCoordBottomRight, quadColor);
|
||||
|
||||
|
|
|
@ -14,8 +14,7 @@
|
|||
|
||||
#include "InterfaceConfig.h"
|
||||
|
||||
#include <QGLWidget>
|
||||
|
||||
#include <QOpenGLTexture>
|
||||
#include <SettingHandle.h>
|
||||
|
||||
enum ZoomLevel {
|
||||
|
@ -26,7 +25,7 @@ enum ZoomLevel {
|
|||
class RearMirrorTools : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
RearMirrorTools(QGLWidget* parent, QRect& bounds);
|
||||
RearMirrorTools(QRect& bounds);
|
||||
void render(bool fullScreen);
|
||||
bool mousePressEvent(int x, int y);
|
||||
|
||||
|
@ -39,12 +38,10 @@ signals:
|
|||
void restoreView();
|
||||
|
||||
private:
|
||||
QGLWidget* _parent;
|
||||
QRect _bounds;
|
||||
GLuint _closeTextureId;
|
||||
GLuint _resetTextureId;
|
||||
GLuint _zoomBodyTextureId;
|
||||
GLuint _zoomHeadTextureId;
|
||||
QOpenGLTexture * _closeTextureId;
|
||||
QOpenGLTexture * _zoomBodyTextureId;
|
||||
QOpenGLTexture *_zoomHeadTextureId;
|
||||
|
||||
QRect _closeIconRect;
|
||||
QRect _resetIconRect;
|
||||
|
@ -55,7 +52,7 @@ private:
|
|||
bool _windowed;
|
||||
bool _fullScreen;
|
||||
|
||||
void displayIcon(QRect bounds, QRect iconBounds, GLuint textureId, bool selected = false);
|
||||
void displayIcon(QRect bounds, QRect iconBounds, QOpenGLTexture * textureId, bool selected = false);
|
||||
};
|
||||
|
||||
#endif // hifi_RearMirrorTools_h
|
||||
|
|
|
@ -94,6 +94,7 @@ QTemporaryFile* Snapshot::saveTempSnapshot() {
|
|||
}
|
||||
|
||||
QFile* Snapshot::savedFileForSnapshot(bool isTemporary) {
|
||||
#if 0
|
||||
auto glCanvas = Application::getInstance()->getGLWidget();
|
||||
QImage shot = glCanvas->grabFrameBuffer();
|
||||
|
||||
|
@ -157,6 +158,8 @@ QFile* Snapshot::savedFileForSnapshot(bool isTemporary) {
|
|||
|
||||
return imageTempFile;
|
||||
}
|
||||
#endif
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -57,8 +57,8 @@ Stats::Stats():
|
|||
_octreeStatsWidth(STATS_OCTREE_MIN_WIDTH),
|
||||
_lastHorizontalOffset(0)
|
||||
{
|
||||
auto glCanvas = Application::getInstance()->getGLWidget();
|
||||
resetWidth(glCanvas->width(), 0);
|
||||
auto canvasSize = Application::getInstance()->getCanvasSize();
|
||||
resetWidth(canvasSize.x, 0);
|
||||
}
|
||||
|
||||
void Stats::toggleExpanded() {
|
||||
|
@ -68,7 +68,8 @@ void Stats::toggleExpanded() {
|
|||
// called on mouse click release
|
||||
// check for clicks over stats in order to expand or contract them
|
||||
void Stats::checkClick(int mouseX, int mouseY, int mouseDragStartedX, int mouseDragStartedY, int horizontalOffset) {
|
||||
auto glCanvas = Application::getInstance()->getGLWidget();
|
||||
// auto glCanvas = Application::getInstance()->getGLWidget();
|
||||
auto canvasSize = Application::getInstance()->getCanvasSize();
|
||||
|
||||
if (0 != glm::compMax(glm::abs(glm::ivec2(mouseX - mouseDragStartedX, mouseY - mouseDragStartedY)))) {
|
||||
// not worried about dragging on stats
|
||||
|
@ -115,7 +116,7 @@ void Stats::checkClick(int mouseX, int mouseY, int mouseDragStartedX, int mouseD
|
|||
// top-right stats click
|
||||
lines = _expanded ? 11 : 3;
|
||||
statsHeight = lines * STATS_PELS_PER_LINE + 10;
|
||||
statsWidth = glCanvas->width() - statsX;
|
||||
statsWidth = canvasSize.x - statsX;
|
||||
if (mouseX > statsX && mouseX < statsX + statsWidth && mouseY > statsY && mouseY < statsY + statsHeight) {
|
||||
toggleExpanded();
|
||||
return;
|
||||
|
@ -123,8 +124,8 @@ void Stats::checkClick(int mouseX, int mouseY, int mouseDragStartedX, int mouseD
|
|||
}
|
||||
|
||||
void Stats::resetWidth(int width, int horizontalOffset) {
|
||||
auto glCanvas = Application::getInstance()->getGLWidget();
|
||||
int extraSpace = glCanvas->width() - horizontalOffset -2
|
||||
auto canvasSize = Application::getInstance()->getCanvasSize();
|
||||
int extraSpace = canvasSize.x - horizontalOffset - 2
|
||||
- STATS_GENERAL_MIN_WIDTH
|
||||
- (Menu::getInstance()->isOptionChecked(MenuOption::TestPing) ? STATS_PING_MIN_WIDTH -1 : 0)
|
||||
- STATS_GEO_MIN_WIDTH
|
||||
|
@ -148,7 +149,7 @@ void Stats::resetWidth(int width, int horizontalOffset) {
|
|||
_pingStatsWidth += (int) extraSpace / panels;
|
||||
}
|
||||
_geoStatsWidth += (int) extraSpace / panels;
|
||||
_octreeStatsWidth += glCanvas->width() -
|
||||
_octreeStatsWidth += canvasSize.x -
|
||||
(_generalStatsWidth + _pingStatsWidth + _geoStatsWidth + 3);
|
||||
}
|
||||
}
|
||||
|
@ -197,7 +198,7 @@ void Stats::display(
|
|||
int outKbitsPerSecond,
|
||||
int voxelPacketsToProcess)
|
||||
{
|
||||
auto glCanvas = Application::getInstance()->getGLWidget();
|
||||
auto canvasSize = Application::getInstance()->getCanvasSize();
|
||||
|
||||
unsigned int backgroundColor = 0x33333399;
|
||||
int verticalOffset = 0, lines = 0;
|
||||
|
@ -211,7 +212,7 @@ void Stats::display(
|
|||
QSharedPointer<BandwidthRecorder> bandwidthRecorder = DependencyManager::get<BandwidthRecorder>();
|
||||
|
||||
if (_lastHorizontalOffset != horizontalOffset) {
|
||||
resetWidth(glCanvas->width(), horizontalOffset);
|
||||
resetWidth(canvasSize.x, horizontalOffset);
|
||||
_lastHorizontalOffset = horizontalOffset;
|
||||
}
|
||||
|
||||
|
@ -461,7 +462,7 @@ void Stats::display(
|
|||
|
||||
lines = _expanded ? 10 : 2;
|
||||
|
||||
drawBackground(backgroundColor, horizontalOffset, 0, glCanvas->width() - horizontalOffset,
|
||||
drawBackground(backgroundColor, horizontalOffset, 0, canvasSize.x - horizontalOffset,
|
||||
(lines + 1) * STATS_PELS_PER_LINE);
|
||||
horizontalOffset += 5;
|
||||
|
||||
|
|
|
@ -291,10 +291,13 @@ void Overlays::deleteOverlay(unsigned int id) {
|
|||
|
||||
unsigned int Overlays::getOverlayAtPoint(const glm::vec2& point) {
|
||||
glm::vec2 pointCopy = point;
|
||||
|
||||
#if 0
|
||||
if (OculusManager::isConnected()) {
|
||||
pointCopy = Application::getInstance()->getApplicationOverlay().screenToOverlay(point);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
QReadLocker lock(&_lock);
|
||||
QMapIterator<unsigned int, Overlay*> i(_overlaysHUD);
|
||||
i.toBack();
|
||||
|
|
|
@ -45,7 +45,7 @@ public:
|
|||
virtual bool shouldRenderMesh(float largestDimension, float distanceToCamera) = 0;
|
||||
virtual float getSizeScale() const = 0;
|
||||
virtual int getBoundaryLevelAdjust() const = 0;
|
||||
virtual PickRay computePickRay(float x, float y) = 0;
|
||||
virtual PickRay computePickRay(float x, float y) const = 0;
|
||||
|
||||
virtual const glm::vec3& getAvatarPosition() const = 0;
|
||||
};
|
||||
|
|
|
@ -30,7 +30,6 @@ GlowEffect::GlowEffect()
|
|||
_isOddFrame(false),
|
||||
_isFirstFrame(true),
|
||||
_intensity(0.0f),
|
||||
_widget(NULL),
|
||||
_enabled(false) {
|
||||
}
|
||||
|
||||
|
@ -63,7 +62,7 @@ static ProgramObject* createProgram(const QString& name) {
|
|||
return program;
|
||||
}
|
||||
|
||||
void GlowEffect::init(QGLWidget* widget, bool enabled) {
|
||||
void GlowEffect::init(bool enabled) {
|
||||
if (_initialized) {
|
||||
qCDebug(renderutils, "[ERROR] GlowEffeect is already initialized.");
|
||||
return;
|
||||
|
@ -91,23 +90,10 @@ void GlowEffect::init(QGLWidget* widget, bool enabled) {
|
|||
_diffusionScaleLocation = _diffuseProgram->uniformLocation("diffusionScale");
|
||||
|
||||
_initialized = true;
|
||||
_widget = widget;
|
||||
_enabled = enabled;
|
||||
}
|
||||
|
||||
int GlowEffect::getDeviceWidth() const {
|
||||
return _widget->width() * (_widget->windowHandle() ? _widget->windowHandle()->devicePixelRatio() : 1.0f);
|
||||
}
|
||||
|
||||
int GlowEffect::getDeviceHeight() const {
|
||||
return _widget->height() * (_widget->windowHandle() ? _widget->windowHandle()->devicePixelRatio() : 1.0f);
|
||||
}
|
||||
|
||||
|
||||
void GlowEffect::prepare() {
|
||||
DependencyManager::get<TextureCache>()->getPrimaryFramebufferObject()->bind();
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
_isEmpty = true;
|
||||
_isOddFrame = !_isOddFrame;
|
||||
}
|
||||
|
@ -124,24 +110,11 @@ void GlowEffect::end() {
|
|||
glBlendColor(0.0f, 0.0f, 0.0f, _intensity = _intensityStack.pop());
|
||||
}
|
||||
|
||||
static void maybeBind(QOpenGLFramebufferObject* fbo) {
|
||||
if (fbo) {
|
||||
fbo->bind();
|
||||
}
|
||||
}
|
||||
|
||||
static void maybeRelease(QOpenGLFramebufferObject* fbo) {
|
||||
if (fbo) {
|
||||
fbo->release();
|
||||
}
|
||||
}
|
||||
|
||||
QOpenGLFramebufferObject* GlowEffect::render(bool toTexture) {
|
||||
QOpenGLFramebufferObject* GlowEffect::render() {
|
||||
PerformanceTimer perfTimer("glowEffect");
|
||||
|
||||
auto textureCache = DependencyManager::get<TextureCache>();
|
||||
QOpenGLFramebufferObject* primaryFBO = textureCache->getPrimaryFramebufferObject();
|
||||
primaryFBO->release();
|
||||
glBindTexture(GL_TEXTURE_2D, primaryFBO->texture());
|
||||
|
||||
glPushMatrix();
|
||||
|
@ -155,23 +128,19 @@ QOpenGLFramebufferObject* GlowEffect::render(bool toTexture) {
|
|||
glDisable(GL_DEPTH_TEST);
|
||||
glDepthMask(GL_FALSE);
|
||||
|
||||
QOpenGLFramebufferObject* destFBO = toTexture ?
|
||||
textureCache->getSecondaryFramebufferObject() : NULL;
|
||||
QOpenGLFramebufferObject* destFBO = textureCache->getSecondaryFramebufferObject();
|
||||
if (!_enabled || _isEmpty) {
|
||||
// copy the primary to the screen
|
||||
if (destFBO && QOpenGLFramebufferObject::hasOpenGLFramebufferBlit()) {
|
||||
QOpenGLFramebufferObject::blitFramebuffer(destFBO, primaryFBO);
|
||||
} else {
|
||||
maybeBind(destFBO);
|
||||
if (!destFBO) {
|
||||
glViewport(0, 0, getDeviceWidth(), getDeviceHeight());
|
||||
}
|
||||
destFBO->bind();
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glDisable(GL_LIGHTING);
|
||||
renderFullscreenQuad();
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glEnable(GL_LIGHTING);
|
||||
maybeRelease(destFBO);
|
||||
destFBO->release();
|
||||
}
|
||||
} else {
|
||||
// diffuse into the secondary/tertiary (alternating between frames)
|
||||
|
@ -205,21 +174,15 @@ QOpenGLFramebufferObject* GlowEffect::render(bool toTexture) {
|
|||
// add diffused texture to the primary
|
||||
glBindTexture(GL_TEXTURE_2D, newDiffusedFBO->texture());
|
||||
|
||||
if (toTexture) {
|
||||
destFBO = oldDiffusedFBO;
|
||||
}
|
||||
maybeBind(destFBO);
|
||||
if (!destFBO) {
|
||||
glViewport(0, 0, getDeviceWidth(), getDeviceHeight());
|
||||
}
|
||||
destFBO = oldDiffusedFBO;
|
||||
destFBO->bind();
|
||||
_addSeparateProgram->bind();
|
||||
renderFullscreenQuad();
|
||||
_addSeparateProgram->release();
|
||||
maybeRelease(destFBO);
|
||||
destFBO->release();
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
|
||||
}
|
||||
|
||||
glPopMatrix();
|
||||
|
|
|
@ -35,7 +35,7 @@ public:
|
|||
/// (either the secondary or the tertiary).
|
||||
QOpenGLFramebufferObject* getFreeFramebufferObject() const;
|
||||
|
||||
void init(QGLWidget* widget, bool enabled);
|
||||
void init(bool enabled);
|
||||
|
||||
/// Prepares the glow effect for rendering the current frame. To be called before rendering the scene.
|
||||
void prepare();
|
||||
|
@ -53,7 +53,7 @@ public:
|
|||
/// Renders the glow effect. To be called after rendering the scene.
|
||||
/// \param toTexture whether to render to a texture, rather than to the frame buffer
|
||||
/// \return the framebuffer object to which we rendered, or NULL if to the frame buffer
|
||||
QOpenGLFramebufferObject* render(bool toTexture = false);
|
||||
QOpenGLFramebufferObject* render();
|
||||
|
||||
public slots:
|
||||
void toggleGlowEffect(bool enabled);
|
||||
|
@ -81,7 +81,6 @@ private:
|
|||
|
||||
float _intensity;
|
||||
QStack<float> _intensityStack;
|
||||
QGLWidget* _widget;
|
||||
bool _enabled;
|
||||
};
|
||||
|
||||
|
|
43
libraries/render-utils/src/OffscreenGlContext.cpp
Normal file
43
libraries/render-utils/src/OffscreenGlContext.cpp
Normal file
|
@ -0,0 +1,43 @@
|
|||
//
|
||||
// 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();
|
||||
}
|
||||
|
33
libraries/render-utils/src/OffscreenGlContext.h
Normal file
33
libraries/render-utils/src/OffscreenGlContext.h
Normal file
|
@ -0,0 +1,33 @@
|
|||
//
|
||||
// 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_OffscreenGlCanvas_h
|
||||
#define hifi_OffscreenGlCanvas_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
|
|
@ -39,8 +39,7 @@ TextureCache::TextureCache() :
|
|||
_secondaryFramebufferObject(NULL),
|
||||
_tertiaryFramebufferObject(NULL),
|
||||
_shadowFramebufferObject(NULL),
|
||||
_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);
|
||||
|
@ -322,28 +321,6 @@ GLuint TextureCache::getShadowDepthTextureID() {
|
|||
return _shadowDepthTextureID;
|
||||
}
|
||||
|
||||
bool TextureCache::eventFilter(QObject* watched, QEvent* event) {
|
||||
if (event->type() == QEvent::Resize) {
|
||||
QSize size = static_cast<QResizeEvent*>(event)->size();
|
||||
if (_primaryFramebufferObject && _primaryFramebufferObject->size() != size) {
|
||||
delete _primaryFramebufferObject;
|
||||
_primaryFramebufferObject = NULL;
|
||||
glDeleteTextures(1, &_primaryDepthTextureID);
|
||||
glDeleteTextures(1, &_primaryNormalTextureID);
|
||||
glDeleteTextures(1, &_primarySpecularTextureID);
|
||||
}
|
||||
if (_secondaryFramebufferObject && _secondaryFramebufferObject->size() != size) {
|
||||
delete _secondaryFramebufferObject;
|
||||
_secondaryFramebufferObject = NULL;
|
||||
}
|
||||
if (_tertiaryFramebufferObject && _tertiaryFramebufferObject->size() != size) {
|
||||
delete _tertiaryFramebufferObject;
|
||||
_tertiaryFramebufferObject = NULL;
|
||||
}
|
||||
}
|
||||
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);
|
||||
|
@ -351,14 +328,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);
|
||||
}
|
||||
|
||||
QOpenGLFramebufferObject* TextureCache::createFramebufferObject() {
|
||||
QOpenGLFramebufferObject* fbo = new QOpenGLFramebufferObject(_frameBufferSize);
|
||||
|
||||
|
|
|
@ -36,9 +36,6 @@ class TextureCache : public ResourceCache, public Dependency {
|
|||
SINGLETON_DEPENDENCY
|
||||
|
||||
public:
|
||||
|
||||
void associateWithWidget(QGLWidget* widget);
|
||||
|
||||
/// Sets the desired texture resolution for the framebuffer objects.
|
||||
void setFrameBufferSize(QSize frameBufferSize);
|
||||
const QSize& getFrameBufferSize() const { return _frameBufferSize; }
|
||||
|
@ -88,8 +85,6 @@ public:
|
|||
/// Returns the ID of the shadow framebuffer object's depth texture.
|
||||
GLuint getShadowDepthTextureID();
|
||||
|
||||
virtual bool eventFilter(QObject* watched, QEvent* event);
|
||||
|
||||
protected:
|
||||
|
||||
virtual QSharedPointer<Resource> createResource(const QUrl& url,
|
||||
|
@ -119,7 +114,6 @@ private:
|
|||
GLuint _shadowDepthTextureID;
|
||||
|
||||
QSize _frameBufferSize;
|
||||
QGLWidget* _associatedWidget;
|
||||
};
|
||||
|
||||
/// A simple object wrapper for an OpenGL texture.
|
||||
|
|
Loading…
Reference in a new issue