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>
bb10
Morten Johan Sørvig 2015-03-19 10:55:56 +01:00 committed by Morten Johan Sørvig
parent 615dc2294a
commit 5c379f3ff0
1 changed files with 4 additions and 1 deletions

View File

@ -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)