chiark / gitweb /
Fix object selection on windows 8.
authorYouness Alaoui <kakaroto@kakaroto.homelinux.net>
Mon, 26 Oct 2015 18:21:43 +0000 (14:21 -0400)
committerYouness Alaoui <kakaroto@kakaroto.homelinux.net>
Mon, 26 Oct 2015 18:24:42 +0000 (14:24 -0400)
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

index 0ebcdd83214dbd43a57e0c97f1182a7ef5977e02..f96cf0fdb72d9ad0f50f999d6cb0454385d642a5 100644 (file)
@@ -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: