From d2de64d51a56908f0eacac04eeef17b1008c8c45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Mon, 25 May 2015 17:38:27 +0200 Subject: [PATCH] fixed bug in flow_gl when a devicePixelRatio <> 1 was used --- common/gl/yacreader_flow_gl.cpp | 17 ++++++++++------- common/gl_legacy/yacreader_flow_gl.cpp | 13 ++++++++----- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/common/gl/yacreader_flow_gl.cpp b/common/gl/yacreader_flow_gl.cpp index 6e80d1f7..c559f9af 100644 --- a/common/gl/yacreader_flow_gl.cpp +++ b/common/gl/yacreader_flow_gl.cpp @@ -368,12 +368,13 @@ void YACReaderFlowGL::resizeGL(int width, int height) void YACReaderFlowGL::udpatePerspective(int width, int height) { - glViewport(0, 0, width, height); + float pixelRatio = devicePixelRatio(); + glViewport(0, 0, width*pixelRatio, height*pixelRatio); glMatrixMode(GL_PROJECTION); glLoadIdentity(); - gluPerspective(20.0, GLdouble(width) / (float)height, 1.0, 200.0); + gluPerspective(20.0, GLdouble(width) / (float)height, 1.0, 200.0); glMatrixMode(GL_MODELVIEW); } @@ -384,7 +385,7 @@ void YACReaderFlowGL::calcPos(YACReader3DImage & image, int pos) { if(pos == 0){ image.current = centerPos; - }else{ + }else{ if(pos > 0){ image.current.x = (config.centerDistance)+(config.xDistance*pos); image.current.y = config.yDistance*pos*-1; @@ -1101,8 +1102,9 @@ void YACReaderFlowGL::mousePressEvent(QMouseEvent *event) if(event->button() == Qt::LeftButton) { float x,y; - x = event->x(); - y = event->y(); + float pixelRatio = devicePixelRatio(); + x = event->x()*pixelRatio; + y = event->y()*pixelRatio; GLint viewport[4]; GLdouble modelview[16]; GLdouble projection[16]; @@ -1139,8 +1141,9 @@ void YACReaderFlowGL::mouseDoubleClickEvent(QMouseEvent* event) { makeCurrent(); float x,y; - x = event->x(); - y = event->y(); + float pixelRatio = devicePixelRatio(); + x = event->x()*pixelRatio; + y = event->y()*pixelRatio; GLint viewport[4]; GLdouble modelview[16]; GLdouble projection[16]; diff --git a/common/gl_legacy/yacreader_flow_gl.cpp b/common/gl_legacy/yacreader_flow_gl.cpp index 1aa27beb..5e02ecd2 100644 --- a/common/gl_legacy/yacreader_flow_gl.cpp +++ b/common/gl_legacy/yacreader_flow_gl.cpp @@ -339,7 +339,8 @@ void YACReaderFlowGL::resizeGL(int width, int height) void YACReaderFlowGL::udpatePerspective(int width, int height) { - glViewport(0, 0, width, height); + float pixelRatio = devicePixelRatio(); + glViewport(0, 0, width*pixelRatio, height*pixelRatio); glMatrixMode(GL_PROJECTION); glLoadIdentity(); @@ -1078,8 +1079,9 @@ void YACReaderFlowGL::mousePressEvent(QMouseEvent *event) if(event->button() == Qt::LeftButton) { float x,y; - x = event->x(); - y = event->y(); + float pixelRatio = devicePixelRatio(); + x = event->x()*pixelRatio; + y = event->y()*pixelRatio; GLint viewport[4]; GLdouble modelview[16]; GLdouble projection[16]; @@ -1113,8 +1115,9 @@ void YACReaderFlowGL::mousePressEvent(QMouseEvent *event) void YACReaderFlowGL::mouseDoubleClickEvent(QMouseEvent* event) { float x,y; - x = event->x(); - y = event->y(); + float pixelRatio = devicePixelRatio(); + x = event->x()*pixelRatio; + y = event->y()*pixelRatio; GLint viewport[4]; GLdouble modelview[16]; GLdouble projection[16];