Skip to content

Commit

Permalink
gl: fix OpenGLWidgetRenderer hi-dpi rendering
Browse files Browse the repository at this point in the history
size passed to QOpenGLWidget.resizeGL is not scaled, while the one to
QGLWidget.resizeGL is scaled
  • Loading branch information
wang-bin committed Jul 1, 2016
1 parent a6d55cd commit ba14c2a
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions widgets/OpenGLWidgetRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@

#include "QtAVWidgets/OpenGLWidgetRenderer.h"
#include "QtAV/private/OpenGLRendererBase_p.h"
#include <QResizeEvent>
#include <QtGui/QGuiApplication>
#include <QtGui/QResizeEvent>
#include <QtGui/QScreen>

namespace QtAV {

Expand Down Expand Up @@ -58,7 +60,13 @@ void OpenGLWidgetRenderer::paintGL()

void OpenGLWidgetRenderer::resizeGL(int w, int h)
{
onResizeGL(w, h);
// QGLWidget uses window()->windowHandle()->devicePixelRatio() for resizeGL(), while QOpenGLWidget does not, so scale here
#if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)
const qreal dpr = context()->screen()->devicePixelRatio();
#else
const qreal dpr = qApp->devicePixelRatio(); //TODO: window()->devicePixelRatio() is the window screen's
#endif
onResizeGL(w*dpr, h*dpr);
}

void OpenGLWidgetRenderer::resizeEvent(QResizeEvent *e)
Expand Down

0 comments on commit ba14c2a

Please sign in to comment.