[Bf-blender-cvs] [d8fa3dd7c3f] blender2.8: GL: use imm* module for 2D cage manipulator

Campbell Barton noreply at git.blender.org
Mon Apr 10 18:33:21 CEST 2017


Commit: d8fa3dd7c3f9ab2bc69912193d77de85bf666113
Author: Campbell Barton
Date:   Tue Apr 11 02:32:53 2017 +1000
Branches: blender2.8
https://developer.blender.org/rBd8fa3dd7c3f9ab2bc69912193d77de85bf666113

GL: use imm* module for 2D cage manipulator

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

M	source/blender/windowmanager/manipulators/intern/manipulator_library/cage_manipulator.c

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

diff --git a/source/blender/windowmanager/manipulators/intern/manipulator_library/cage_manipulator.c b/source/blender/windowmanager/manipulators/intern/manipulator_library/cage_manipulator.c
index f0a6cbb3778..4ef3f84dfc7 100644
--- a/source/blender/windowmanager/manipulators/intern/manipulator_library/cage_manipulator.c
+++ b/source/blender/windowmanager/manipulators/intern/manipulator_library/cage_manipulator.c
@@ -46,6 +46,8 @@
 #include "ED_screen.h"
 
 #include "GPU_matrix.h"
+#include "GPU_shader.h"
+#include "GPU_immediate.h"
 
 #include "MEM_guardedalloc.h"
 
@@ -82,29 +84,39 @@ typedef struct RectTransformManipulator {
 
 /* -------------------------------------------------------------------- */
 
-static void rect_transform_draw_corners(rctf *r, const float offsetx, const float offsety)
+static void rect_transform_draw_corners(
+        const rctf *r, const float offsetx, const float offsety, const float color[3])
 {
-	glBegin(GL_LINES);
-	glVertex2f(r->xmin, r->ymin + offsety);
-	glVertex2f(r->xmin, r->ymin);
-	glVertex2f(r->xmin, r->ymin);
-	glVertex2f(r->xmin + offsetx, r->ymin);
-
-	glVertex2f(r->xmax, r->ymin + offsety);
-	glVertex2f(r->xmax, r->ymin);
-	glVertex2f(r->xmax, r->ymin);
-	glVertex2f(r->xmax - offsetx, r->ymin);
-
-	glVertex2f(r->xmax, r->ymax - offsety);
-	glVertex2f(r->xmax, r->ymax);
-	glVertex2f(r->xmax, r->ymax);
-	glVertex2f(r->xmax - offsetx, r->ymax);
-
-	glVertex2f(r->xmin, r->ymax - offsety);
-	glVertex2f(r->xmin, r->ymax);
-	glVertex2f(r->xmin, r->ymax);
-	glVertex2f(r->xmin + offsetx, r->ymax);
-	glEnd();
+	unsigned int pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
+
+	immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
+	immUniformColor3fv(color);
+
+	immBegin(PRIM_LINES, 16);
+
+	immVertex2f(pos, r->xmin, r->ymin + offsety);
+	immVertex2f(pos, r->xmin, r->ymin);
+	immVertex2f(pos, r->xmin, r->ymin);
+	immVertex2f(pos, r->xmin + offsetx, r->ymin);
+
+	immVertex2f(pos, r->xmax, r->ymin + offsety);
+	immVertex2f(pos, r->xmax, r->ymin);
+	immVertex2f(pos, r->xmax, r->ymin);
+	immVertex2f(pos, r->xmax - offsetx, r->ymin);
+
+	immVertex2f(pos, r->xmax, r->ymax - offsety);
+	immVertex2f(pos, r->xmax, r->ymax);
+	immVertex2f(pos, r->xmax, r->ymax);
+	immVertex2f(pos, r->xmax - offsetx, r->ymax);
+
+	immVertex2f(pos, r->xmin, r->ymax - offsety);
+	immVertex2f(pos, r->xmin, r->ymax);
+	immVertex2f(pos, r->xmin, r->ymax);
+	immVertex2f(pos, r->xmin + offsetx, r->ymax);
+
+	immEnd();
+
+	immUnbindProgram();
 }
 
 static void rect_transform_draw_interaction(
@@ -206,15 +218,13 @@ static void manipulator_rect_transform_draw(const bContext *UNUSED(C), wmManipul
 	           ((cage->style & MANIPULATOR_RECT_TRANSFORM_STYLE_SCALE_UNIFORM) ? cage->scale[0] : cage->scale[1]));
 
 	/* corner manipulators */
-	glColor3f(0.0, 0.0, 0.0);
 	glLineWidth(cage->manipulator.line_width + 3.0f);
 
-	rect_transform_draw_corners(&r, w, h);
+	rect_transform_draw_corners(&r, w, h, (const float[3]){0, 0, 0});
 
 	/* corner manipulators */
-	glColor3fv(manipulator->col);
 	glLineWidth(cage->manipulator.line_width);
-	rect_transform_draw_corners(&r, w, h);
+	rect_transform_draw_corners(&r, w, h, manipulator->col);
 
 	rect_transform_draw_interaction(manipulator->col, manipulator->highlighted_part, half_w, half_h,
 	                                w, h, cage->manipulator.line_width);




More information about the Bf-blender-cvs mailing list