mirror of
https://github.com/overte-org/overte.git
synced 2025-07-23 09:03:53 +02:00
Fixing scale resolution issues
This commit is contained in:
parent
12c26f9c3c
commit
c31d36be59
13 changed files with 99 additions and 71 deletions
|
@ -807,8 +807,7 @@ void Application::initializeUi() {
|
||||||
if (devicePixelRatio != oldDevicePixelRatio) {
|
if (devicePixelRatio != oldDevicePixelRatio) {
|
||||||
oldDevicePixelRatio = devicePixelRatio;
|
oldDevicePixelRatio = devicePixelRatio;
|
||||||
qDebug() << "Device pixel ratio changed, triggering GL resize";
|
qDebug() << "Device pixel ratio changed, triggering GL resize";
|
||||||
resizeGL(_glWidget->width(),
|
resizeGL();
|
||||||
_glWidget->height());
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -825,15 +824,7 @@ void Application::paintGL() {
|
||||||
PerformanceWarning::setSuppressShortTimings(Menu::getInstance()->isOptionChecked(MenuOption::SuppressShortTimings));
|
PerformanceWarning::setSuppressShortTimings(Menu::getInstance()->isOptionChecked(MenuOption::SuppressShortTimings));
|
||||||
bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
|
bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
|
||||||
PerformanceWarning warn(showWarnings, "Application::paintGL()");
|
PerformanceWarning warn(showWarnings, "Application::paintGL()");
|
||||||
|
resizeGL();
|
||||||
// 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
glEnable(GL_LINE_SMOOTH);
|
glEnable(GL_LINE_SMOOTH);
|
||||||
|
|
||||||
|
@ -910,7 +901,14 @@ void Application::paintGL() {
|
||||||
renderRearViewMirror(_mirrorViewRect);
|
renderRearViewMirror(_mirrorViewRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
DependencyManager::get<GlowEffect>()->render();
|
auto finalFbo = DependencyManager::get<GlowEffect>()->render();
|
||||||
|
|
||||||
|
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
||||||
|
glBindFramebuffer(GL_READ_FRAMEBUFFER, gpu::GLBackend::getFramebufferID(finalFbo));
|
||||||
|
glBlitFramebuffer(0, 0, _renderResolution.x, _renderResolution.y,
|
||||||
|
0, 0, _glWidget->getDeviceSize().width(), _glWidget->getDeviceSize().height(),
|
||||||
|
GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
PerformanceTimer perfTimer("renderOverlay");
|
PerformanceTimer perfTimer("renderOverlay");
|
||||||
|
@ -955,33 +953,47 @@ void Application::showEditEntitiesHelp() {
|
||||||
InfoView::show(INFO_EDIT_ENTITIES_PATH);
|
InfoView::show(INFO_EDIT_ENTITIES_PATH);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::resetCamerasOnResizeGL(Camera& camera, int width, int height) {
|
void Application::resetCamerasOnResizeGL(Camera& camera, const glm::uvec2& size) {
|
||||||
if (OculusManager::isConnected()) {
|
if (OculusManager::isConnected()) {
|
||||||
OculusManager::configureCamera(camera, width, height);
|
OculusManager::configureCamera(camera, size.x, size.y);
|
||||||
} else if (TV3DManager::isConnected()) {
|
} else if (TV3DManager::isConnected()) {
|
||||||
TV3DManager::configureCamera(camera, width, height);
|
TV3DManager::configureCamera(camera, size.x, size.y);
|
||||||
} else {
|
} else {
|
||||||
camera.setAspectRatio((float)width / height);
|
camera.setAspectRatio((float)size.x / size.y);
|
||||||
camera.setFieldOfView(_fieldOfView.get());
|
camera.setFieldOfView(_fieldOfView.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::resizeGL(int width, int height) {
|
void Application::resizeGL() {
|
||||||
DependencyManager::get<TextureCache>()->setFrameBufferSize(QSize(width, height));
|
// Set the desired FBO texture size. If it hasn't changed, this does nothing.
|
||||||
resetCamerasOnResizeGL(_myCamera, width, height);
|
// Otherwise, it must rebuild the FBOs
|
||||||
|
QSize renderSize;
|
||||||
|
if (OculusManager::isConnected()) {
|
||||||
|
renderSize = OculusManager::getRenderTargetSize();
|
||||||
|
} else {
|
||||||
|
renderSize = _glWidget->getDeviceSize() * getRenderResolutionScale();
|
||||||
|
}
|
||||||
|
if (_renderResolution == toGlm(renderSize)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
glViewport(0, 0, width, height); // shouldn't this account for the menu???
|
_renderResolution = toGlm(renderSize);
|
||||||
|
DependencyManager::get<TextureCache>()->setFrameBufferSize(renderSize);
|
||||||
|
resetCamerasOnResizeGL(_myCamera, _renderResolution);
|
||||||
|
|
||||||
|
glViewport(0, 0, _renderResolution.x, _renderResolution.y); // shouldn't this account for the menu???
|
||||||
|
|
||||||
updateProjectionMatrix();
|
updateProjectionMatrix();
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
|
|
||||||
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
||||||
offscreenUi->resize(_glWidget->size());
|
offscreenUi->resize(_glWidget->size());
|
||||||
|
_glWidget->makeCurrent();
|
||||||
|
|
||||||
// update Stats width
|
// update Stats width
|
||||||
// let's set horizontal offset to give stats some margin to mirror
|
// let's set horizontal offset to give stats some margin to mirror
|
||||||
int horizontalOffset = MIRROR_VIEW_WIDTH + MIRROR_VIEW_LEFT_PADDING * 2;
|
int horizontalOffset = MIRROR_VIEW_WIDTH + MIRROR_VIEW_LEFT_PADDING * 2;
|
||||||
Stats::getInstance()->resetWidth(width, horizontalOffset);
|
Stats::getInstance()->resetWidth(_renderResolution.x, horizontalOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::updateProjectionMatrix() {
|
void Application::updateProjectionMatrix() {
|
||||||
|
@ -1819,7 +1831,7 @@ void Application::setFullscreen(bool fullscreen) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::setEnable3DTVMode(bool enable3DTVMode) {
|
void Application::setEnable3DTVMode(bool enable3DTVMode) {
|
||||||
resizeGL(_glWidget->getDeviceWidth(), _glWidget->getDeviceHeight());
|
resizeGL();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::setEnableVRMode(bool enableVRMode) {
|
void Application::setEnableVRMode(bool enableVRMode) {
|
||||||
|
@ -1844,7 +1856,7 @@ void Application::setEnableVRMode(bool enableVRMode) {
|
||||||
_myCamera.setHmdRotation(glm::quat());
|
_myCamera.setHmdRotation(glm::quat());
|
||||||
}
|
}
|
||||||
|
|
||||||
resizeGL(_glWidget->getDeviceWidth(), _glWidget->getDeviceHeight());
|
resizeGL();
|
||||||
|
|
||||||
updateCursorVisibility();
|
updateCursorVisibility();
|
||||||
}
|
}
|
||||||
|
@ -3200,12 +3212,12 @@ void Application::displaySide(Camera& theCamera, bool selfAvatarOnly, RenderArgs
|
||||||
_stars.render(theCamera.getFieldOfView(), theCamera.getAspectRatio(), theCamera.getNearClip(), alpha);
|
_stars.render(theCamera.getFieldOfView(), theCamera.getAspectRatio(), theCamera.getNearClip(), alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
// draw the sky dome
|
// draw the sky dome
|
||||||
if (!selfAvatarOnly && Menu::getInstance()->isOptionChecked(MenuOption::Atmosphere)) {
|
if (!selfAvatarOnly && Menu::getInstance()->isOptionChecked(MenuOption::Atmosphere)) {
|
||||||
PerformanceTimer perfTimer("atmosphere");
|
PerformanceTimer perfTimer("atmosphere");
|
||||||
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
|
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
|
||||||
"Application::displaySide() ... atmosphere...");
|
"Application::displaySide() ... atmosphere...");
|
||||||
_environment.renderAtmospheres(theCamera);
|
_environment.renderAtmospheres(theCamera);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4605,7 +4617,3 @@ PickRay Application::computePickRay() const {
|
||||||
bool Application::hasFocus() const {
|
bool Application::hasFocus() const {
|
||||||
return _glWidget->hasFocus();
|
return _glWidget->hasFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::resizeGL() {
|
|
||||||
this->resizeGL(_glWidget->getDeviceWidth(), _glWidget->getDeviceHeight());
|
|
||||||
}
|
|
||||||
|
|
|
@ -161,7 +161,7 @@ public:
|
||||||
void initializeGL();
|
void initializeGL();
|
||||||
void initializeUi();
|
void initializeUi();
|
||||||
void paintGL();
|
void paintGL();
|
||||||
void resizeGL(int width, int height);
|
void resizeGL();
|
||||||
|
|
||||||
void resizeEvent(QResizeEvent * size);
|
void resizeEvent(QResizeEvent * size);
|
||||||
|
|
||||||
|
@ -192,7 +192,6 @@ public:
|
||||||
bool hasFocus() const;
|
bool hasFocus() const;
|
||||||
PickRay computePickRay() const;
|
PickRay computePickRay() const;
|
||||||
PickRay computeViewPickRay(float xRatio, float yRatio) const;
|
PickRay computeViewPickRay(float xRatio, float yRatio) const;
|
||||||
void resizeGL();
|
|
||||||
|
|
||||||
bool isThrottleRendering() const;
|
bool isThrottleRendering() const;
|
||||||
|
|
||||||
|
@ -460,7 +459,7 @@ private slots:
|
||||||
void setCursorVisible(bool visible);
|
void setCursorVisible(bool visible);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void resetCamerasOnResizeGL(Camera& camera, int width, int height);
|
void resetCamerasOnResizeGL(Camera& camera, const glm::uvec2& size);
|
||||||
void updateProjectionMatrix();
|
void updateProjectionMatrix();
|
||||||
void updateProjectionMatrix(Camera& camera, bool updateViewFrustum = true);
|
void updateProjectionMatrix(Camera& camera, bool updateViewFrustum = true);
|
||||||
|
|
||||||
|
@ -657,6 +656,7 @@ private:
|
||||||
QHash<QString, AcceptURLMethod> _acceptedExtensions;
|
QHash<QString, AcceptURLMethod> _acceptedExtensions;
|
||||||
|
|
||||||
QList<QString> _domainConnectionRefusals;
|
QList<QString> _domainConnectionRefusals;
|
||||||
|
glm::uvec2 _renderResolution;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_Application_h
|
#endif // hifi_Application_h
|
||||||
|
|
|
@ -64,7 +64,7 @@ void GLCanvas::paintGL() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLCanvas::resizeGL(int width, int height) {
|
void GLCanvas::resizeGL(int width, int height) {
|
||||||
Application::getInstance()->resizeGL(width, height);
|
Application::getInstance()->resizeGL();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLCanvas::activeChanged(Qt::ApplicationState state) {
|
void GLCanvas::activeChanged(Qt::ApplicationState state) {
|
||||||
|
|
|
@ -181,7 +181,7 @@ namespace MenuOption {
|
||||||
const QString EditEntitiesHelp = "Edit Entities Help...";
|
const QString EditEntitiesHelp = "Edit Entities Help...";
|
||||||
const QString Enable3DTVMode = "Enable 3DTV Mode";
|
const QString Enable3DTVMode = "Enable 3DTV Mode";
|
||||||
const QString EnableCharacterController = "Enable avatar collisions";
|
const QString EnableCharacterController = "Enable avatar collisions";
|
||||||
const QString EnableGlowEffect = "Enable Glow Effect (Warning: Poor Oculus Performance)";
|
const QString EnableGlowEffect = "Enable Glow Effect";
|
||||||
const QString EnableVRMode = "Enable VR Mode";
|
const QString EnableVRMode = "Enable VR Mode";
|
||||||
const QString ExpandMyAvatarSimulateTiming = "Expand /myAvatar/simulation";
|
const QString ExpandMyAvatarSimulateTiming = "Expand /myAvatar/simulation";
|
||||||
const QString ExpandMyAvatarTiming = "Expand /myAvatar";
|
const QString ExpandMyAvatarTiming = "Expand /myAvatar";
|
||||||
|
|
|
@ -627,7 +627,7 @@ void OculusManager::display(QGLWidget * glCanvas, const glm::quat &bodyOrientati
|
||||||
if (Menu::getInstance()->isOptionChecked(MenuOption::EnableGlowEffect)) {
|
if (Menu::getInstance()->isOptionChecked(MenuOption::EnableGlowEffect)) {
|
||||||
//Full texture viewport for glow effect
|
//Full texture viewport for glow effect
|
||||||
glViewport(0, 0, _renderTargetSize.w, _renderTargetSize.h);
|
glViewport(0, 0, _renderTargetSize.w, _renderTargetSize.h);
|
||||||
finalFbo = DependencyManager::get<GlowEffect>()->render(true);
|
finalFbo = DependencyManager::get<GlowEffect>()->render();
|
||||||
} else {
|
} else {
|
||||||
finalFbo = DependencyManager::get<TextureCache>()->getPrimaryFramebuffer();
|
finalFbo = DependencyManager::get<TextureCache>()->getPrimaryFramebuffer();
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
|
|
||||||
#include <GlowEffect.h>
|
#include <GlowEffect.h>
|
||||||
|
#include "gpu/GLBackend.h"
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
|
|
||||||
#include "TV3DManager.h"
|
#include "TV3DManager.h"
|
||||||
|
@ -163,10 +163,18 @@ void TV3DManager::display(Camera& whichCamera) {
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
glDisable(GL_SCISSOR_TEST);
|
glDisable(GL_SCISSOR_TEST);
|
||||||
|
|
||||||
|
auto finalFbo = DependencyManager::get<GlowEffect>()->render();
|
||||||
|
auto fboSize = finalFbo->getSize();
|
||||||
|
// Get the ACTUAL device size for the BLIT
|
||||||
|
deviceSize = qApp->getDeviceSize();
|
||||||
|
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
||||||
|
glBindFramebuffer(GL_READ_FRAMEBUFFER, gpu::GLBackend::getFramebufferID(finalFbo));
|
||||||
|
glBlitFramebuffer(0, 0, fboSize.x, fboSize.y,
|
||||||
|
0, 0, deviceSize.width(), deviceSize.height(),
|
||||||
|
GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
||||||
|
|
||||||
// reset the viewport to how we started
|
// reset the viewport to how we started
|
||||||
glViewport(0, 0, deviceSize.width(), deviceSize.height());
|
glViewport(0, 0, deviceSize.width(), deviceSize.height());
|
||||||
|
|
||||||
DependencyManager::get<GlowEffect>()->render();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TV3DManager::overrideOffAxisFrustum(float& left, float& right, float& bottom, float& top, float& nearVal,
|
void TV3DManager::overrideOffAxisFrustum(float& left, float& right, float& bottom, float& top, float& nearVal,
|
||||||
|
|
|
@ -190,8 +190,8 @@ void ApplicationOverlay::renderOverlay() {
|
||||||
Overlays& overlays = qApp->getOverlays();
|
Overlays& overlays = qApp->getOverlays();
|
||||||
|
|
||||||
_textureFov = glm::radians(_hmdUIAngularSize);
|
_textureFov = glm::radians(_hmdUIAngularSize);
|
||||||
glm::vec2 deviceSize = qApp->getCanvasSize();
|
glm::vec2 size = qApp->getCanvasSize();
|
||||||
_textureAspectRatio = (float)deviceSize.x / (float)deviceSize.y;
|
_textureAspectRatio = aspect(size);
|
||||||
|
|
||||||
//Handle fading and deactivation/activation of UI
|
//Handle fading and deactivation/activation of UI
|
||||||
|
|
||||||
|
@ -204,12 +204,13 @@ void ApplicationOverlay::renderOverlay() {
|
||||||
_overlays.buildFramebufferObject();
|
_overlays.buildFramebufferObject();
|
||||||
_overlays.bind();
|
_overlays.bind();
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
glViewport(0, 0, size.x, size.y);
|
||||||
|
|
||||||
glPushMatrix(); {
|
glPushMatrix(); {
|
||||||
const float NEAR_CLIP = -10000;
|
const float NEAR_CLIP = -10000;
|
||||||
const float FAR_CLIP = 10000;
|
const float FAR_CLIP = 10000;
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
glOrtho(0, deviceSize.x, deviceSize.y, 0, NEAR_CLIP, FAR_CLIP);
|
glOrtho(0, size.x, size.y, 0, NEAR_CLIP, FAR_CLIP);
|
||||||
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
|
||||||
|
@ -269,6 +270,7 @@ void ApplicationOverlay::displayOverlayTexture() {
|
||||||
if (_alpha < 1.0) {
|
if (_alpha < 1.0) {
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
}
|
}
|
||||||
|
glViewport(0, 0, qApp->getDeviceSize().width(), qApp->getDeviceSize().height());
|
||||||
|
|
||||||
static const glm::vec2 topLeft(-1, 1);
|
static const glm::vec2 topLeft(-1, 1);
|
||||||
static const glm::vec2 bottomRight(1, -1);
|
static const glm::vec2 bottomRight(1, -1);
|
||||||
|
@ -1129,8 +1131,9 @@ void ApplicationOverlay::TexturedHemisphere::cleanupVBO() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApplicationOverlay::TexturedHemisphere::buildFramebufferObject() {
|
void ApplicationOverlay::TexturedHemisphere::buildFramebufferObject() {
|
||||||
auto deviceSize = qApp->getDeviceSize();
|
auto canvasSize = qApp->getCanvasSize();
|
||||||
if (_framebufferObject != NULL && deviceSize == _framebufferObject->size()) {
|
QSize fboSize = QSize(canvasSize.x, canvasSize.y);
|
||||||
|
if (_framebufferObject != NULL && fboSize == _framebufferObject->size()) {
|
||||||
// Already build
|
// Already build
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1139,7 +1142,7 @@ void ApplicationOverlay::TexturedHemisphere::buildFramebufferObject() {
|
||||||
delete _framebufferObject;
|
delete _framebufferObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
_framebufferObject = new QOpenGLFramebufferObject(deviceSize, QOpenGLFramebufferObject::Depth);
|
_framebufferObject = new QOpenGLFramebufferObject(fboSize, QOpenGLFramebufferObject::Depth);
|
||||||
glBindTexture(GL_TEXTURE_2D, getTexture());
|
glBindTexture(GL_TEXTURE_2D, getTexture());
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
|
|
|
@ -95,4 +95,7 @@ void FboCache::setSize(const QSize& newSize) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QSize& FboCache::getSize() {
|
||||||
|
return _size;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,8 @@ public:
|
||||||
// internal locks and pointers but execute no OpenGL opreations.
|
// internal locks and pointers but execute no OpenGL opreations.
|
||||||
void lockTexture(int texture);
|
void lockTexture(int texture);
|
||||||
void releaseTexture(int texture);
|
void releaseTexture(int texture);
|
||||||
|
|
||||||
|
const QSize& getSize();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QMap<int, QSharedPointer<QOpenGLFramebufferObject>> _fboMap;
|
QMap<int, QSharedPointer<QOpenGLFramebufferObject>> _fboMap;
|
||||||
|
|
|
@ -129,7 +129,7 @@ static void maybeRelease(const gpu::FramebufferPointer& fbo) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gpu::FramebufferPointer GlowEffect::render(bool toTexture) {
|
gpu::FramebufferPointer GlowEffect::render() {
|
||||||
PerformanceTimer perfTimer("glowEffect");
|
PerformanceTimer perfTimer("glowEffect");
|
||||||
|
|
||||||
auto textureCache = DependencyManager::get<TextureCache>();
|
auto textureCache = DependencyManager::get<TextureCache>();
|
||||||
|
@ -151,26 +151,24 @@ gpu::FramebufferPointer GlowEffect::render(bool toTexture) {
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
glDepthMask(GL_FALSE);
|
glDepthMask(GL_FALSE);
|
||||||
|
|
||||||
gpu::FramebufferPointer destFBO = toTexture ?
|
gpu::FramebufferPointer destFBO = textureCache->getSecondaryFramebuffer();
|
||||||
textureCache->getSecondaryFramebuffer() : nullptr;
|
|
||||||
if (!_enabled || _isEmpty) {
|
if (!_enabled || _isEmpty) {
|
||||||
// copy the primary to the screen
|
// copy the primary to the screen
|
||||||
if (destFBO && QOpenGLFramebufferObject::hasOpenGLFramebufferBlit()) {
|
if (QOpenGLFramebufferObject::hasOpenGLFramebufferBlit()) {
|
||||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, primaryFBO);
|
|
||||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, gpu::GLBackend::getFramebufferID(destFBO));
|
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, gpu::GLBackend::getFramebufferID(destFBO));
|
||||||
glBlitFramebuffer(0, 0, framebufferSize.width(), framebufferSize.height(), 0, 0, framebufferSize.width(), framebufferSize.height(), GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
glBindFramebuffer(GL_READ_FRAMEBUFFER, primaryFBO);
|
||||||
|
glBlitFramebuffer(0, 0, framebufferSize.width(), framebufferSize.height(),
|
||||||
|
0, 0, framebufferSize.width(), framebufferSize.height(),
|
||||||
|
GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
||||||
} else {
|
} else {
|
||||||
maybeBind(destFBO);
|
glBindFramebuffer(GL_FRAMEBUFFER, gpu::GLBackend::getFramebufferID(destFBO));
|
||||||
if (!destFBO) {
|
glViewport(0, 0, framebufferSize.width(), framebufferSize.height());
|
||||||
//destFBO->getSize();
|
|
||||||
glViewport(0, 0, framebufferSize.width(), framebufferSize.height());
|
|
||||||
}
|
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
glDisable(GL_LIGHTING);
|
glDisable(GL_LIGHTING);
|
||||||
renderFullscreenQuad();
|
renderFullscreenQuad();
|
||||||
glDisable(GL_TEXTURE_2D);
|
glDisable(GL_TEXTURE_2D);
|
||||||
glEnable(GL_LIGHTING);
|
glEnable(GL_LIGHTING);
|
||||||
maybeRelease(destFBO);
|
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// diffuse into the secondary/tertiary (alternating between frames)
|
// diffuse into the secondary/tertiary (alternating between frames)
|
||||||
|
@ -199,22 +197,18 @@ gpu::FramebufferPointer GlowEffect::render(bool toTexture) {
|
||||||
_diffuseProgram->release();
|
_diffuseProgram->release();
|
||||||
}
|
}
|
||||||
|
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
destFBO = oldDiffusedFBO;
|
||||||
|
|
||||||
|
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||||
// add diffused texture to the primary
|
// add diffused texture to the primary
|
||||||
glBindTexture(GL_TEXTURE_2D, gpu::GLBackend::getTextureID(newDiffusedFBO->getRenderBuffer(0)));
|
glBindTexture(GL_TEXTURE_2D, gpu::GLBackend::getTextureID(newDiffusedFBO->getRenderBuffer(0)));
|
||||||
|
|
||||||
if (toTexture) {
|
glBindFramebuffer(GL_FRAMEBUFFER, gpu::GLBackend::getFramebufferID(destFBO));
|
||||||
destFBO = oldDiffusedFBO;
|
glViewport(0, 0, framebufferSize.width(), framebufferSize.height());
|
||||||
}
|
|
||||||
maybeBind(destFBO);
|
|
||||||
if (!destFBO) {
|
|
||||||
glViewport(0, 0, framebufferSize.width(), framebufferSize.height());
|
|
||||||
}
|
|
||||||
_addSeparateProgram->bind();
|
_addSeparateProgram->bind();
|
||||||
renderFullscreenQuad();
|
renderFullscreenQuad();
|
||||||
_addSeparateProgram->release();
|
_addSeparateProgram->release();
|
||||||
maybeRelease(destFBO);
|
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
|
|
@ -52,7 +52,7 @@ public:
|
||||||
/// Renders the glow effect. To be called after rendering the scene.
|
/// 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
|
/// \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
|
/// \return the framebuffer object to which we rendered, or NULL if to the frame buffer
|
||||||
gpu::FramebufferPointer render(bool toTexture = false);
|
gpu::FramebufferPointer render();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void toggleGlowEffect(bool enabled);
|
void toggleGlowEffect(bool enabled);
|
||||||
|
|
|
@ -117,6 +117,11 @@ QMatrix4x4 fromGlm(const glm::mat4 & m);
|
||||||
|
|
||||||
QRectF glmToRect(const glm::vec2 & pos, const glm::vec2 & size);
|
QRectF glmToRect(const glm::vec2 & pos, const glm::vec2 & size);
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
float aspect(const T& t) {
|
||||||
|
return (float)t.x / (float)t.y;
|
||||||
|
}
|
||||||
|
|
||||||
#define YAW(euler) euler.y
|
#define YAW(euler) euler.y
|
||||||
#define PITCH(euler) euler.x
|
#define PITCH(euler) euler.x
|
||||||
#define ROLL(euler) euler.z
|
#define ROLL(euler) euler.z
|
||||||
|
|
|
@ -117,8 +117,13 @@ void OffscreenUi::addImportPath(const QString& path) {
|
||||||
void OffscreenUi::resize(const QSize& newSize) {
|
void OffscreenUi::resize(const QSize& newSize) {
|
||||||
makeCurrent();
|
makeCurrent();
|
||||||
|
|
||||||
// Clear out any fbos with the old size
|
|
||||||
qreal pixelRatio = _renderControl->_renderWindow ? _renderControl->_renderWindow->devicePixelRatio() : 1.0;
|
qreal pixelRatio = _renderControl->_renderWindow ? _renderControl->_renderWindow->devicePixelRatio() : 1.0;
|
||||||
|
QSize newOffscreenSize = newSize * pixelRatio;
|
||||||
|
if (newOffscreenSize == _fboCache.getSize()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clear out any fbos with the old size
|
||||||
qDebug() << "Offscreen UI resizing to " << newSize.width() << "x" << newSize.height() << " with pixel ratio " << pixelRatio;
|
qDebug() << "Offscreen UI resizing to " << newSize.width() << "x" << newSize.height() << " with pixel ratio " << pixelRatio;
|
||||||
_fboCache.setSize(newSize * pixelRatio);
|
_fboCache.setSize(newSize * pixelRatio);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue