diff --git a/src/Mod/Mesh/Gui/SoFCIndexedFaceSet.cpp b/src/Mod/Mesh/Gui/SoFCIndexedFaceSet.cpp index e2852e924..4a985d65c 100644 --- a/src/Mod/Mesh/Gui/SoFCIndexedFaceSet.cpp +++ b/src/Mod/Mesh/Gui/SoFCIndexedFaceSet.cpp @@ -267,7 +267,12 @@ void SoFCIndexedFaceSet::startSelection(SoAction * action) //glGetDoublev(GL_PROJECTION_MATRIX ,mp); glPushMatrix(); glLoadIdentity(); - gluPickMatrix(x, y, w, h, viewport); + // See https://www.opengl.org/discussion_boards/showthread.php/184308-gluPickMatrix-Implementation?p=1259884&viewfull=1#post1259884 + //gluPickMatrix(x, y, w, h, viewport); + if (w > 0 && h > 0) { + glTranslatef((viewport[2] - 2 * (x - viewport[0])) / w, (viewport[3] - 2 * (y - viewport[1])) / h, 0); + glScalef(viewport[2] / w, viewport[3] / h, 1.0); + } glMultMatrixf(/*mp*/(float*)proj); glMatrixMode(GL_MODELVIEW); glPushMatrix(); diff --git a/src/Mod/Mesh/Gui/SoFCMeshObject.cpp b/src/Mod/Mesh/Gui/SoFCMeshObject.cpp index 7506069be..8db69e00a 100644 --- a/src/Mod/Mesh/Gui/SoFCMeshObject.cpp +++ b/src/Mod/Mesh/Gui/SoFCMeshObject.cpp @@ -899,7 +899,12 @@ void SoFCMeshObjectShape::startSelection(SoAction * action, const Mesh::MeshObje //glGetDoublev(GL_PROJECTION_MATRIX ,mp); glPushMatrix(); glLoadIdentity(); - gluPickMatrix(x, y, w, h, viewport); + // See https://www.opengl.org/discussion_boards/showthread.php/184308-gluPickMatrix-Implementation?p=1259884&viewfull=1#post1259884 + //gluPickMatrix(x, y, w, h, viewport); + if (w > 0 && h > 0) { + glTranslatef((viewport[2] - 2 * (x - viewport[0])) / w, (viewport[3] - 2 * (y - viewport[1])) / h, 0); + glScalef(viewport[2] / w, viewport[3] / h, 1.0); + } glMultMatrixf(/*mp*/this->projection); glMatrixMode(GL_MODELVIEW); glPushMatrix();