From f1a2e3485d9bb42bfcc70b9cc842772039914b9e Mon Sep 17 00:00:00 2001 From: Youness Alaoui Date: Mon, 26 Oct 2015 14:21:43 -0400 Subject: [PATCH] Fix object selection on windows 8. The issue is that the GL_UNSIGNED_INT_8_8_8_8 format is apparently not supported on some version of windows and leads to a glReadPixels that returns 0 everywhere which selects the first object only wherever you click. The issue with using GL_UNSIGNED_INT is that the result is also different from linux and windows, for some reason the value on window is mangled and not all bytes have the correct value. So we are forced to use GL_UNSIGNED_BYTE and convert the byte into an int to get the position of the object selected, since GL_UNSIGNED_BYTE seems to have the same behavior across platforms. Fixes T24 --- Cura/gui/sceneView.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cura/gui/sceneView.py b/Cura/gui/sceneView.py index 0ebcdd83..f96cf0fd 100644 --- a/Cura/gui/sceneView.py +++ b/Cura/gui/sceneView.py @@ -1152,7 +1152,7 @@ class SceneView(openglGui.glGuiPanel): if self._mouseX > -1: # mouse has not passed over the opengl window. glFlush() - n = glReadPixels(self._mouseX, self.GetSize().GetHeight() - 1 - self._mouseY, 1, 1, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8)[0][0] >> 8 + n = int(glReadPixels(self._mouseX, self.GetSize().GetHeight() - 1 - self._mouseY, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE)[2].encode('hex'), 16) if n < len(self._scene.objects()): self._focusObj = self._scene.objects()[n] else: -- 2.30.2