Skip to content

Commit

Permalink
gl: fix devicePixelRatio in qt5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
wang-bin committed Jul 5, 2016
1 parent cfe4bee commit f45954f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion widgets/OpenGLWidgetRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

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

Expand Down Expand Up @@ -62,10 +63,12 @@ void OpenGLWidgetRenderer::resizeGL(int w, int 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
#elif QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
// qApp->devicePixelRatio() is global, window()->windowHandle()->devicePixelRatio() depends on screen, check window() and windowHandle() is required.
// QWidget.devicePixelRatio() is int, but float value is not implemented in old qt, so just use int is fine.
const qreal dpr = devicePixelRatio();
#else
const qreal dpr = qApp->devicePixelRatio();
#endif
onResizeGL(w*dpr, h*dpr);
}
Expand Down

0 comments on commit f45954f

Please sign in to comment.