diff options
author | Morten Johan Sørvig <morten.sorvig@digia.com> | 2015-03-19 10:55:56 +0100 |
---|---|---|
committer | Morten Johan Sørvig <morten.sorvig@theqtcompany.com> | 2015-03-23 08:05:30 +0000 |
commit | 5c379f3ff0471c51827577d047c93bab88ad44ce (patch) | |
tree | b47a146c631bd03dd27cf33d9115fd3ca7f0f740 /src/opengl | |
parent | 615dc2294a7b12344e3e88cde481326c9e94c279 (diff) |
QGLWidget: make renderText() work in high-dpi mode
Keep the win_x/y position in device independent
pixels. Call glViewport with the device pixel size.
Change-Id: I96fa038b1a0a3e18cb7f467b65def09cb89692a3
Task-number: QTBUG-38778
Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
Diffstat (limited to 'src/opengl')
-rw-r--r-- | src/opengl/qgl.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 490b79664f..fc1280bfc4 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -4906,6 +4906,9 @@ void QGLWidget::renderText(double x, double y, double z, const QString &str, con GLdouble win_x = 0, win_y = 0, win_z = 0; qgluProject(x, y, z, &model[0], &proj[0], &view[0], &win_x, &win_y, &win_z); + const int dpr = d->glcx->device()->devicePixelRatio(); + win_x /= dpr; + win_y /= dpr; win_y = height - win_y; // y is inverted QPaintEngine *engine = paintEngine(); @@ -4934,7 +4937,7 @@ void QGLWidget::renderText(double x, double y, double z, const QString &str, con } else if (use_scissor_testing) { funcs->glEnable(GL_SCISSOR_TEST); } - funcs->glViewport(0, 0, width, height); + funcs->glViewport(0, 0, width * dpr, height * dpr); gl1funcs->glAlphaFunc(GL_GREATER, 0.0); funcs->glEnable(GL_ALPHA_TEST); if (use_depth_testing) |