From 5c379f3ff0471c51827577d047c93bab88ad44ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Thu, 19 Mar 2015 10:55:56 +0100 Subject: 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 --- src/opengl/qgl.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/opengl') 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) -- cgit v1.2.3