Bug 1206 - Picking disabled dithering
authorNeil Roberts <neil@openedhand.com>
Wed, 29 Oct 2008 12:19:27 +0000 (12:19 +0000)
committerNeil Roberts <neil@openedhand.com>
Wed, 29 Oct 2008 12:19:27 +0000 (12:19 +0000)
* clutter/clutter-main.c (_clutter_do_pick): After picking is
finished, restore the state of glEnable (GL_DITHER). Otherwise it
will cause the scene to look different after the first pick on low
depth displays. (Thanks to Michael Boccara for the patch)

ChangeLog
clutter/clutter-main.c

index 64bceef..af8201b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2008-10-29  Neil Roberts  <neil@linux.intel.com>
+
+       Bug 1206 - Picking disabled dithering
+
+       * clutter/clutter-main.c (_clutter_do_pick): After picking is
+       finished, restore the state of glEnable (GL_DITHER). Otherwise it
+       will cause the scene to look different after the first pick on low
+       depth displays. (Thanks to Michael Boccara for the patch)
+
 2008-10-28  Thomas Wood  <thomas@linux.intel.com>
 
        * clutter/clutter-color.c (param_color_set_default): Set the no copy
index ef0187e..ebd528a 100644 (file)
@@ -353,6 +353,7 @@ _clutter_do_pick (ClutterStage   *stage,
   GLint               viewport[4];
   ClutterColor        white = { 0xff, 0xff, 0xff, 0xff };
   guint32             id;
+  GLboolean           dither_was_on;
 
   context = clutter_context_get_default ();
 
@@ -364,6 +365,7 @@ _clutter_do_pick (ClutterStage   *stage,
   cogl_paint_init (&white);
 
   /* Disable dithering (if any) when doing the painting in pick mode */
+  dither_was_on = glIsEnabled (GL_DITHER);
   glDisable (GL_DITHER);
 
   /* Render the entire scence in pick mode - just single colored silhouette's
@@ -381,8 +383,9 @@ _clutter_do_pick (ClutterStage   *stage,
   */
   glFinish();
 
-  /* glEnable (GL_DITHER); we never enabled this originally, so its
-     probably not safe to then enable it */
+  /* Restore whether GL_DITHER was enabled */
+  if (dither_was_on)
+    glEnable (GL_DITHER);
 
   /* Read the color of the screen co-ords pixel */
   glReadPixels (x, viewport[3] - y -1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixel);