[Bf-blender-cvs] [f86461e] wiggly-widgets: Cleanup: De-duplicate multi-sample handling

Julian Eisel noreply at git.blender.org
Thu Nov 19 22:55:01 CET 2015


Commit: f86461e36829c111f509a67bf2648cc87b205682
Author: Julian Eisel
Date:   Thu Nov 19 22:53:36 2015 +0100
Branches: wiggly-widgets
https://developer.blender.org/rBf86461e36829c111f509a67bf2648cc87b205682

Cleanup: De-duplicate multi-sample handling

===================================================================

M	source/blender/windowmanager/intern/wm_generic_widgets.c
M	source/blender/windowmanager/intern/wm_widgets.c

===================================================================

diff --git a/source/blender/windowmanager/intern/wm_generic_widgets.c b/source/blender/windowmanager/intern/wm_generic_widgets.c
index 6cd7faf..e0874d7 100644
--- a/source/blender/windowmanager/intern/wm_generic_widgets.c
+++ b/source/blender/windowmanager/intern/wm_generic_widgets.c
@@ -211,8 +211,6 @@ static void widget_arrow_get_final_pos(wmWidget *widget, float r_pos[3])
 
 static void arrow_draw_geom(const ArrowWidget *arrow, const bool select)
 {
-	glEnable(GL_MULTISAMPLE_ARB);
-
 	if (arrow->style & WIDGET_ARROW_STYLE_CROSS) {
 		glPushAttrib(GL_ENABLE_BIT);
 		glDisable(GL_LIGHTING);
@@ -301,8 +299,6 @@ static void arrow_draw_geom(const ArrowWidget *arrow, const bool select)
 		glPopMatrix();
 #endif
 	}
-
-	glDisable(GL_MULTISAMPLE_ARB);
 }
 
 static void arrow_draw_intern(ArrowWidget *arrow, const bool select, const bool highlight)
@@ -752,16 +748,12 @@ typedef struct DialWidget {
 static void dial_draw_geom(const DialWidget *dial, const bool select)
 {
 #ifdef WIDGET_USE_CUSTOM_DIAS
-	glEnable(GL_MULTISAMPLE_ARB);
-
 	widget_draw_intern(&dial_draw_info, select);
 #else
 	GLUquadricObj *qobj = gluNewQuadric();
 	const float width = 1.0f;
 	const int resol = 32;
 
-	glEnable(GL_MULTISAMPLE_ARB);
-
 	glLineWidth(dial->widget.line_width);
 	gluQuadricDrawStyle(qobj, GLU_SILHOUETTE);
 	gluDisk(qobj, 0.0, width, resol, 1);
@@ -769,8 +761,6 @@ static void dial_draw_geom(const DialWidget *dial, const bool select)
 
 	UNUSED_VARS(select);
 #endif
-
-	glDisable(GL_MULTISAMPLE_ARB);
 }
 
 static void dial_draw_intern(DialWidget *dial, const bool select, const bool highlight, const float scale)
@@ -926,8 +916,6 @@ static void widget_plane_draw_geom(const float col_inner[4], const float col_out
 		{-1,  1, 0},
 	};
 
-	glEnable(GL_MULTISAMPLE_ARB);
-
 	glEnableClientState(GL_VERTEX_ARRAY);
 	glVertexPointer(3, GL_FLOAT, 0, vec);
 	glColor4fv(col_inner);
@@ -935,8 +923,6 @@ static void widget_plane_draw_geom(const float col_inner[4], const float col_out
 	glColor4fv(col_outer);
 	glDrawArrays(GL_LINE_LOOP, 0, ARRAY_SIZE(vec));
 	glDisableClientState(GL_VERTEX_ARRAY);
-
-	glDisable(GL_MULTISAMPLE_ARB);
 }
 
 static void widget_plane_draw_intern(PlaneWidget *plane, const bool UNUSED(select), const bool highlight)
@@ -1568,9 +1554,7 @@ static void widget_facemap_draw(const bContext *C, wmWidget *widget)
 	glPushMatrix();
 	glMultMatrixf(fmap_widget->ob->obmat);
 	glTranslate3fv(widget->offset);
-	glEnable(GL_MULTISAMPLE_ARB);
 	ED_draw_object_facemap(CTX_data_scene(C), fmap_widget->ob, col, fmap_widget->facemap);
-	glDisable(GL_MULTISAMPLE_ARB);
 	glPopMatrix();
 }
 
diff --git a/source/blender/windowmanager/intern/wm_widgets.c b/source/blender/windowmanager/intern/wm_widgets.c
index 37bae38..8d8c865 100644
--- a/source/blender/windowmanager/intern/wm_widgets.c
+++ b/source/blender/windowmanager/intern/wm_widgets.c
@@ -320,18 +320,23 @@ BLI_INLINE bool widgetgroup_poll_check(const bContext *C, const wmWidgetGroup *w
 void WM_widgets_draw(const bContext *C, const wmWidgetMap *wmap, const bool in_scene)
 {
 	wmWidget *widget;
-	bool use_lighting;
+	const bool draw_multisample = (U.ogl_multisamples != USER_MULTISAMPLE_NONE);
+	const bool use_lighting = (U.tw_flag & V3D_SHADED_WIDGETS) != 0;
 
 	if (!wmap)
 		return;
 
-	use_lighting = (U.tw_flag & V3D_SHADED_WIDGETS) != 0;
+	/* enable multisampling */
+	if (draw_multisample) {
+		glEnable(GL_MULTISAMPLE_ARB);
+	}
 
 	if (use_lighting) {
 		const float lightpos[4] = {0.0, 0.0, 1.0, 0.0};
 		const float diffuse[4] = {1.0, 1.0, 1.0, 0.0};
 
 		glPushAttrib(GL_LIGHTING_BIT | GL_ENABLE_BIT);
+
 		glEnable(GL_LIGHTING);
 		glEnable(GL_LIGHT0);
 		glEnable(GL_COLOR_MATERIAL);
@@ -379,6 +384,8 @@ void WM_widgets_draw(const bContext *C, const wmWidgetMap *wmap, const bool in_s
 		}
 	}
 
+	if (draw_multisample)
+		glDisable(GL_MULTISAMPLE_ARB);
 	if (use_lighting)
 		glPopAttrib();
 }




More information about the Bf-blender-cvs mailing list