[Bf-blender-cvs] [88a7d3438dc] blender2.8: Move imm_draw_line_box_dashed to GPU_immediate_util.

Bastien Montagne noreply at git.blender.org
Wed Apr 26 12:13:42 CEST 2017


Commit: 88a7d3438dc61674e4fd95698a7feffd3c9c05bb
Author: Bastien Montagne
Date:   Wed Apr 26 12:11:40 2017 +0200
Branches: blender2.8
https://developer.blender.org/rB88a7d3438dc61674e4fd95698a7feffd3c9c05bb

Move imm_draw_line_box_dashed to GPU_immediate_util.

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

M	source/blender/gpu/GPU_immediate_util.h
M	source/blender/gpu/intern/gpu_immediate_util.c
M	source/blender/windowmanager/intern/wm_gesture.c

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

diff --git a/source/blender/gpu/GPU_immediate_util.h b/source/blender/gpu/GPU_immediate_util.h
index 730b31ed277..3131dda2a48 100644
--- a/source/blender/gpu/GPU_immediate_util.h
+++ b/source/blender/gpu/GPU_immediate_util.h
@@ -44,6 +44,8 @@ void imm_draw_line_box(unsigned pos, float x1, float y1, float x2, float y2);
 
 void imm_draw_line_box_3d(unsigned pos, float x1, float y1, float x2, float y2);
 
+void imm_draw_line_box_dashed(uint pos, uint line_origin, float x1, float y1, float x2, float y2);
+
 void imm_draw_checker_box(float x1, float y1, float x2, float y2);
 
 void imm_draw_cylinder_fill_normal_3d(
diff --git a/source/blender/gpu/intern/gpu_immediate_util.c b/source/blender/gpu/intern/gpu_immediate_util.c
index 52829c6956b..49ced32cd51 100644
--- a/source/blender/gpu/intern/gpu_immediate_util.c
+++ b/source/blender/gpu/intern/gpu_immediate_util.c
@@ -181,6 +181,32 @@ void imm_draw_line_box_3d(unsigned pos, float x1, float y1, float x2, float y2)
 	immEnd();
 }
 
+/** Same as \a imm_draw_line_box, but for dashed shader. */
+/* TODO find a way to generate screen-space dashed lines without that line_origin ugly hack
+ * (would not bet it's possible with current GLSL though :( ). */
+void imm_draw_line_box_dashed(uint pos, uint line_origin, float x1, float y1, float x2, float y2)
+{
+	immBegin(PRIM_LINES, 8);
+
+	immAttrib2f(line_origin, x1, y1);
+	immVertex2f(pos, x1, y1);
+	immVertex2f(pos, x1, y2);
+
+	immAttrib2f(line_origin, x1, y2);
+	immVertex2f(pos, x1, y2);
+	immVertex2f(pos, x2, y2);
+
+	immAttrib2f(line_origin, x2, y1);
+	immVertex2f(pos, x2, y2);
+	immVertex2f(pos, x2, y1);
+
+	immAttrib2f(line_origin, x1, y1);
+	immVertex2f(pos, x2, y1);
+	immVertex2f(pos, x1, y1);
+
+	immEnd();
+}
+
 /**
  * Draw a standard checkerboard to indicate transparent backgrounds.
  */
diff --git a/source/blender/windowmanager/intern/wm_gesture.c b/source/blender/windowmanager/intern/wm_gesture.c
index 38b843772ab..cfe62846bfd 100644
--- a/source/blender/windowmanager/intern/wm_gesture.c
+++ b/source/blender/windowmanager/intern/wm_gesture.c
@@ -199,24 +199,6 @@ static void wm_gesture_draw_line(wmGesture *gt)
 	immUnbindProgram();
 }
 
-static void imm_draw_line_box_dashed(unsigned pos, unsigned line_origin, float x1, float y1, float x2, float y2)
-{
-	immBegin(PRIM_LINES, 8);
-	immAttrib2f(line_origin, x1, y1);
-	immVertex2f(pos, x1, y1);
-	immVertex2f(pos, x1, y2);
-	immAttrib2f(line_origin, x1, y2);
-	immVertex2f(pos, x1, y2);
-	immVertex2f(pos, x2, y2);
-	immAttrib2f(line_origin, x2, y1);
-	immVertex2f(pos, x2, y2);
-	immVertex2f(pos, x2, y1);
-	immAttrib2f(line_origin, x1, y1);
-	immVertex2f(pos, x2, y1);
-	immVertex2f(pos, x1, y1);
-	immEnd();
-}
-
 static void wm_gesture_draw_rect(wmGesture *gt)
 {
 	rcti *rect = (rcti *)gt->customdata;




More information about the Bf-blender-cvs mailing list