[Bf-blender-cvs] [54343b8] master: GPU: use basic-shader for line-stipple

Campbell Barton noreply at git.blender.org
Thu Jun 9 23:51:26 CEST 2016


Commit: 54343b821d6bea408aa84a087e6e4f64ba460019
Author: Campbell Barton
Date:   Fri Jun 10 07:39:12 2016 +1000
Branches: master
https://developer.blender.org/rB54343b821d6bea408aa84a087e6e4f64ba460019

GPU: use basic-shader for line-stipple

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

M	source/blender/editors/interface/interface_draw.c
M	source/blender/editors/mask/mask_draw.c
M	source/blender/editors/sculpt_paint/paint_stroke.c
M	source/blender/editors/space_clip/clip_draw.c
M	source/blender/editors/space_view3d/drawmesh.c
M	source/blender/editors/space_view3d/drawobject.c

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

diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c
index 3afea54..72a6a04 100644
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.c
@@ -1537,10 +1537,12 @@ void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wc
 			          BLI_rctf_size_x(&rect),
 			          BLI_rctf_size_y(&rect));
 
+			GPU_basic_shader_bind_enable(GPU_SHADER_LINE);
+
 			for (int a = 0; a < 2; a++) {
 				if (a == 1) {
-					glLineStipple(3, 0xaaaa);
-					glEnable(GL_LINE_STIPPLE);
+					GPU_basic_shader_bind_enable(GPU_SHADER_STIPPLE);
+					GPU_basic_shader_line_stipple(3, 0xAAAA);
 					UI_ThemeColor(TH_SEL_MARKER);
 				}
 				else {
@@ -1554,9 +1556,10 @@ void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wc
 				glVertex2f(0.0f, 10.0f);
 				glEnd();
 			}
+
+			GPU_basic_shader_bind_disable(GPU_SHADER_LINE | GPU_SHADER_STIPPLE);
 		}
 
-		glDisable(GL_LINE_STIPPLE);
 		glPopMatrix();
 
 		ok = true;
diff --git a/source/blender/editors/mask/mask_draw.c b/source/blender/editors/mask/mask_draw.c
index 9a8382b..2b4f94a 100644
--- a/source/blender/editors/mask/mask_draw.c
+++ b/source/blender/editors/mask/mask_draw.c
@@ -51,6 +51,8 @@
 #include "BIF_gl.h"
 #include "BIF_glutil.h"
 
+#include "GPU_basic_shader.h"
+
 #include "UI_resources.h"
 #include "UI_view2d.h"
 
@@ -100,10 +102,10 @@ static void draw_spline_parents(MaskLayer *UNUSED(masklay), MaskSpline *spline)
 	if (!spline->tot_point)
 		return;
 
-	glColor3ub(0, 0, 0);
-	glEnable(GL_LINE_STIPPLE);
-	glLineStipple(1, 0xAAAA);
+	GPU_basic_shader_bind_enable(GPU_SHADER_LINE | GPU_SHADER_STIPPLE);
+	GPU_basic_shader_line_stipple(1, 0xAAAA);
 
+	glColor3ub(0, 0, 0);
 	glBegin(GL_LINES);
 
 	for (i = 0; i < spline->tot_point; i++) {
@@ -121,7 +123,7 @@ static void draw_spline_parents(MaskLayer *UNUSED(masklay), MaskSpline *spline)
 
 	glEnd();
 
-	glDisable(GL_LINE_STIPPLE);
+	GPU_basic_shader_bind_disable(GPU_SHADER_LINE | GPU_SHADER_STIPPLE);
 }
 #endif
 
@@ -455,7 +457,8 @@ static void mask_draw_curve_type(const bContext *C, MaskSpline *spline, float (*
 
 		case MASK_DT_DASH:
 		default:
-			glEnable(GL_LINE_STIPPLE);
+			GPU_basic_shader_bind_enable(GPU_SHADER_LINE | GPU_SHADER_STIPPLE);
+			GPU_basic_shader_line_stipple(3, 0xAAAA);
 
 #ifdef USE_XOR
 			glEnable(GL_COLOR_LOGIC_OP);
@@ -463,7 +466,6 @@ static void mask_draw_curve_type(const bContext *C, MaskSpline *spline, float (*
 #endif
 			mask_color_active_tint(rgb_tmp, rgb_spline, is_active);
 			glColor4ubv(rgb_tmp);
-			glLineStipple(3, 0xaaaa);
 			glEnableClientState(GL_VERTEX_ARRAY);
 			glVertexPointer(2, GL_FLOAT, 0, points);
 			glDrawArrays(draw_method, 0, tot_point);
@@ -473,10 +475,10 @@ static void mask_draw_curve_type(const bContext *C, MaskSpline *spline, float (*
 #endif
 			mask_color_active_tint(rgb_tmp, rgb_black, is_active);
 			glColor4ubv(rgb_tmp);
-			glLineStipple(3, 0x5555);
+			GPU_basic_shader_line_stipple(3, 0x5555);
 			glDrawArrays(draw_method, 0, tot_point);
 
-			glDisable(GL_LINE_STIPPLE);
+			GPU_basic_shader_bind_disable(GPU_SHADER_LINE | GPU_SHADER_STIPPLE);
 			break;
 
 
diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c
index 65857cc..67fbd00 100644
--- a/source/blender/editors/sculpt_paint/paint_stroke.c
+++ b/source/blender/editors/sculpt_paint/paint_stroke.c
@@ -58,6 +58,8 @@
 #include "BIF_gl.h"
 #include "BIF_glutil.h"
 
+#include "GPU_basic_shader.h"
+
 #include "ED_screen.h"
 #include "ED_view3d.h"
 
@@ -160,11 +162,11 @@ static void paint_draw_line_cursor(bContext *C, int x, int y, void *customdata)
 	glEnable(GL_LINE_SMOOTH);
 	glEnable(GL_BLEND);
 
-	glEnable(GL_LINE_STIPPLE);
-	glLineStipple(3, 0xAAAA);
+	GPU_basic_shader_bind_enable(GPU_SHADER_LINE | GPU_SHADER_STIPPLE);
+	GPU_basic_shader_line_stipple(3, 0xAAAA);
+	GPU_basic_shader_line_width(3.0);
 
 	glColor4ub(0, 0, 0, paint->paint_cursor_col[3]);
-	glLineWidth(3.0);
 	if (stroke->constrain_line) {
 		sdrawline((int)stroke->last_mouse_position[0], (int)stroke->last_mouse_position[1],
 		        stroke->constrained_pos[0], stroke->constrained_pos[1]);
@@ -175,7 +177,7 @@ static void paint_draw_line_cursor(bContext *C, int x, int y, void *customdata)
 	}
 
 	glColor4ub(255, 255, 255, paint->paint_cursor_col[3]);
-	glLineWidth(1.0);
+	GPU_basic_shader_line_width(1.0);
 	if (stroke->constrain_line) {
 		sdrawline((int)stroke->last_mouse_position[0], (int)stroke->last_mouse_position[1],
 		        stroke->constrained_pos[0], stroke->constrained_pos[1]);
@@ -185,7 +187,7 @@ static void paint_draw_line_cursor(bContext *C, int x, int y, void *customdata)
 		        x, y);
 	}
 
-	glDisable(GL_LINE_STIPPLE);
+	GPU_basic_shader_bind_disable(GPU_SHADER_LINE | GPU_SHADER_STIPPLE);
 
 	glDisable(GL_BLEND);
 	glDisable(GL_LINE_SMOOTH);
diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c
index 1c5be3d..695d04d 100644
--- a/source/blender/editors/space_clip/clip_draw.c
+++ b/source/blender/editors/space_clip/clip_draw.c
@@ -336,8 +336,10 @@ static void draw_stabilization_border(SpaceClip *sc, ARegion *ar, int width, int
 	/* draw boundary border for frame if stabilization is enabled */
 	if (sc->flag & SC_SHOW_STABLE && clip->tracking.stabilization.flag & TRACKING_2D_STABILIZATION) {
 		glColor3f(0.0f, 0.0f, 0.0f);
-		glLineStipple(3, 0xaaaa);
-		glEnable(GL_LINE_STIPPLE);
+
+		GPU_basic_shader_bind_enable(GPU_SHADER_LINE | GPU_SHADER_STIPPLE);
+		GPU_basic_shader_line_stipple(3, 0xAAAA);
+
 		glEnable(GL_COLOR_LOGIC_OP);
 		glLogicOp(GL_NOR);
 
@@ -357,7 +359,7 @@ static void draw_stabilization_border(SpaceClip *sc, ARegion *ar, int width, int
 		glPopMatrix();
 
 		glDisable(GL_COLOR_LOGIC_OP);
-		glDisable(GL_LINE_STIPPLE);
+		GPU_basic_shader_bind_disable(GPU_SHADER_LINE | GPU_SHADER_STIPPLE);
 	}
 }
 
@@ -627,8 +629,8 @@ static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTra
 			glEnd();
 
 			glColor3f(0.0f, 0.0f, 0.0f);
-			glLineStipple(3, 0xaaaa);
-			glEnable(GL_LINE_STIPPLE);
+			GPU_basic_shader_bind_enable(GPU_SHADER_LINE | GPU_SHADER_STIPPLE);
+			GPU_basic_shader_line_stipple(3, 0xAAAA);
 			glEnable(GL_COLOR_LOGIC_OP);
 			glLogicOp(GL_NOR);
 
@@ -638,7 +640,7 @@ static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTra
 			glEnd();
 
 			glDisable(GL_COLOR_LOGIC_OP);
-			glDisable(GL_LINE_STIPPLE);
+			GPU_basic_shader_bind_disable(GPU_SHADER_LINE | GPU_SHADER_STIPPLE);
 		}
 	}
 
@@ -647,8 +649,11 @@ static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTra
 	glTranslate2fv(marker_pos);
 
 	if (tiny) {
-		glLineStipple(3, 0xaaaa);
-		glEnable(GL_LINE_STIPPLE);
+		GPU_basic_shader_bind_enable(GPU_SHADER_LINE | GPU_SHADER_STIPPLE);
+		GPU_basic_shader_line_stipple(3, 0xAAAA);
+	}
+	else {
+		GPU_basic_shader_bind_enable(GPU_SHADER_LINE);
 	}
 
 	if ((track->pat_flag & SELECT) == sel && (sc->flag & SC_SHOW_MARKER_PATTERN)) {
@@ -713,8 +718,12 @@ static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTra
 		glEnd();
 	}
 
-	if (tiny)
-		glDisable(GL_LINE_STIPPLE);
+	if (tiny) {
+		GPU_basic_shader_bind_disable(GPU_SHADER_LINE | GPU_SHADER_STIPPLE);
+	}
+	else {
+		GPU_basic_shader_bind_disable(GPU_SHADER_LINE);
+	}
 
 	glPopMatrix();
 }
@@ -852,16 +861,12 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo
 
 		glLineWidth(outline ? 3.0f : 1.0f);
 
-		glEnable(GL_LINE_STIPPLE);
-		glLineStipple(3, 0xaaaa);
-
 		glBegin(GL_LINES);
 		glVertex2f(0.0f, 0.0f);
 		glVertex2fv(tilt_ctrl);
 		glEnd();
 
-		glDisable(GL_LINE_STIPPLE);
-
+		GPU_basic_shader_bind_disable(GPU_SHADER_LINE | GPU_SHADER_STIPPLE);
 
 		/* slider to control pattern tilt */
 		draw_marker_slide_square(tilt_ctrl[0], tilt_ctrl[1], patdx, patdy, outline, px);
@@ -1133,11 +1138,14 @@ static void draw_plane_marker_ex(SpaceClip *sc, Scene *scene, MovieTrackingPlane
 		const bool thick = draw_outline && !tiny;
 
 		if (stipple) {
-			glLineStipple(3, 0xaaaa);
-			glEnable(GL_LINE_STIPPLE);
+			GPU_basic_shader_bind_enable(GPU_SHADER_LINE | GPU_SHADER_STIPPLE);
+			GPU_basic_shader_line_stipple(3, 0xAAAA);
+		}
+		else {
+			GPU_basic_shader_bind_enable(GPU_SHADER_LINE);
 		}
 
-		glLineWidth(thick ? 3.0f : 1.0f);
+		GPU_basic_shader_line_width(thick ? 3.0f : 1.0f);
 
 		/* Draw rectangle itself. */
 		glBegin(GL_LINE_LOOP);
@@ -1169,8 +1177,12 @@ static void draw_plane_marker_ex(SpaceClip *sc, Scene *scene, MovieTrackingPlane
 			glPopAttrib();
 		}
 
-		if (stipple)
-			glDisable(GL_LINE_STIPPLE);
+		if (stipple) {
+			GPU_basic_shader_bind_disable(GPU_SHADER_LINE | GPU_SHADER_STIPPLE);
+		}
+		else {
+			GPU_basic_shader_bind_disable(GPU_SHADER_LINE);
+		}
 	}
 
 	/* Draw sliders. */
diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c
index d836401..ee82a4c 100644
--- a/source/blender/editors/space_view3d/drawmesh.c
+++ b/source/blender/editors/space_view3d/drawmesh.c
@@ -1310,8 +1310,8 @@ void draw_mesh_paint_weight_edges(RegionView3D *rv3d, DerivedMesh *dm,
 	}
 
 	glColor4ub(255, 255, 255, 96);
-	glEnable(GL_LINE_STIPPLE);
-	glLineStipple(1, 0xAAAA);
+	GPU_basic_shader_bind_enable(GPU_SHADER_LINE | GPU_SHADER_STIPPLE);
+	GPU_basic_shader_line_stipple(1, 0xAAAA);
 
 	dm->drawMappedEdges(dm, (DMSetDrawOptions)edgemask_cb, user_data);
 
@@ -1323,7 +1323,7 @@ void draw_mesh_paint_weight_edges(RegionView3D *rv3d, DerivedMesh *dm,
 		glEnable(GL_DEPTH_TEST);
 	}
 
-	glDisable(GL_LINE_STIPPLE);
+	GPU_basic_shader_bind_disable(GPU_SHADER_LINE | GPU_SHADER_STIPPLE);
 
 	if (use_alpha) {
 		glDisable(GL_BLEND);
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index e61ef0c..830e82d 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -1924,13 +1924,15 @@ static void drawcamera_stereo3d(
 
 	if (is_stereo3d_cameras) {
 		/* draw connecting lines */
-		glLineStipple(2, 0xAAAA);
-		glEnable(GL_LINE_ST

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list