mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 12:04:18 +02:00
Fixing offscreen rendering on retina display, even without a proxy window
This commit is contained in:
parent
ad5f1214bf
commit
a0097bcff8
4 changed files with 16 additions and 3 deletions
|
@ -4690,6 +4690,11 @@ int Application::getMaxOctreePacketsPerSecond() {
|
|||
return _maxOctreePPS;
|
||||
}
|
||||
|
||||
qreal Application::getDevicePixelRatio() {
|
||||
return _window ? _window->windowHandle()->devicePixelRatio() : 1.0;
|
||||
}
|
||||
|
||||
|
||||
AbstractViewStateInterface* AbstractViewStateInterface::instance() {
|
||||
return qApp;
|
||||
}
|
||||
|
|
|
@ -300,7 +300,7 @@ public:
|
|||
virtual const glm::vec3& getAvatarPosition() const { return _myAvatar->getPosition(); }
|
||||
virtual void overrideEnvironmentData(const EnvironmentData& newData) { _environment.override(newData); }
|
||||
virtual void endOverrideEnvironmentData() { _environment.endOverride(); }
|
||||
|
||||
virtual qreal getDevicePixelRatio();
|
||||
|
||||
NodeBounds& getNodeBoundsDisplay() { return _nodeBoundsDisplay; }
|
||||
|
||||
|
|
|
@ -56,6 +56,7 @@ public:
|
|||
virtual const glm::vec3& getAvatarPosition() const = 0;
|
||||
|
||||
virtual void postLambdaEvent(std::function<void()> f) = 0;
|
||||
virtual qreal getDevicePixelRatio() = 0;
|
||||
|
||||
static AbstractViewStateInterface* instance();
|
||||
};
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <QOpenGLDebugLogger>
|
||||
#include <QGLWidget>
|
||||
#include <QtQml>
|
||||
#include "AbstractViewStateInterface.h"
|
||||
|
||||
Q_DECLARE_LOGGING_CATEGORY(offscreenFocus)
|
||||
Q_LOGGING_CATEGORY(offscreenFocus, "hifi.offscreen.focus")
|
||||
|
@ -87,8 +88,14 @@ void OffscreenQmlSurface::create(QOpenGLContext* shareContext) {
|
|||
}
|
||||
|
||||
void OffscreenQmlSurface::resize(const QSize& newSize) {
|
||||
|
||||
qreal pixelRatio = _renderControl->_renderWindow ? _renderControl->_renderWindow->devicePixelRatio() : 1.0;
|
||||
// Qt bug in 5.4 forces this check of pixel ratio,
|
||||
// even though we're rendering offscreen.
|
||||
qreal pixelRatio = 1.0;
|
||||
if (_renderControl && _renderControl->_renderWindow) {
|
||||
pixelRatio = _renderControl->_renderWindow->devicePixelRatio();
|
||||
} else {
|
||||
pixelRatio = AbstractViewStateInterface::instance()->getDevicePixelRatio();
|
||||
}
|
||||
QSize newOffscreenSize = newSize * pixelRatio;
|
||||
if (newOffscreenSize == _fboCache.getSize()) {
|
||||
return;
|
||||
|
|
Loading…
Reference in a new issue