Fix incorrect matrix stack push/pop
authorCampbell Barton <ideasman42@gmail.com>
Mon, 14 May 2018 11:03:04 +0000 (13:03 +0200)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 14 May 2018 11:29:17 +0000 (13:29 +0200)
source/blender/editors/manipulator_library/manipulator_types/button2d_manipulator.c

index a69643595959685096f1522da4f981d4f1c06c06..73520d1801d9f9e9e08b01328e000b08d62f6810 100644 (file)
@@ -127,12 +127,12 @@ static void button2d_draw_intern(
        manipulator_color_get(mpr, highlight, color);
        WM_manipulator_calc_matrix_final(mpr, matrix_final);
 
+       bool need_to_pop = true;
        gpuPushMatrix();
        gpuMultMatrix(matrix_final);
 
-       glEnable(GL_BLEND);
-
        if (select == false) {
+               glEnable(GL_BLEND);
                if (button->shape_batch[0] != NULL) {
                        glEnable(GL_LINE_SMOOTH);
                        glLineWidth(1.0f);
@@ -147,21 +147,22 @@ static void button2d_draw_intern(
                                GWN_batch_draw(button->shape_batch[i]);
                        }
                        glDisable(GL_LINE_SMOOTH);
-                       gpuPopMatrix();
                }
                else if (button->icon != ICON_NONE) {
                        button2d_geom_draw_backdrop(mpr, color, select);
                        gpuPopMatrix();
+                       need_to_pop = false;
                        UI_icon_draw(
                                mpr->matrix_basis[3][0] - (ICON_DEFAULT_WIDTH / 2.0) * UI_DPI_FAC,
                                mpr->matrix_basis[3][1] - (ICON_DEFAULT_HEIGHT / 2.0) * UI_DPI_FAC,
                                button->icon);
                }
-               else {
-                       gpuPopMatrix();
-               }
+               glDisable(GL_BLEND);
+       }
+
+       if (need_to_pop) {
+               gpuPopMatrix();
        }
-       glDisable(GL_BLEND);
 }
 
 static void manipulator_button2d_draw_select(const bContext *C, wmManipulator *mpr, int select_id)