[Bf-blender-cvs] [33d99bd] blender2.8: immediate mode: ed_util.c

Dalai Felinto noreply at git.blender.org
Thu Oct 20 01:59:45 CEST 2016


Commit: 33d99bdfe6c4f883671c4ab757a85bea781f820e
Author: Dalai Felinto
Date:   Wed Oct 19 23:59:22 2016 +0000
Branches: blender2.8
https://developer.blender.org/rB33d99bdfe6c4f883671c4ab757a85bea781f820e

immediate mode: ed_util.c

note: I switched one of the glVertex2iv into glVertex2fv to use the same attrib_id

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

M	source/blender/editors/util/ed_util.c

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

diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c
index 1f1a778..482523e 100644
--- a/source/blender/editors/util/ed_util.c
+++ b/source/blender/editors/util/ed_util.c
@@ -70,6 +70,8 @@
 #include "ED_space_api.h"
 #include "ED_util.h"
 
+#include "GPU_immediate.h"
+
 #include "UI_interface.h"
 #include "UI_resources.h"
 
@@ -312,15 +314,23 @@ void ED_region_draw_mouse_line_cb(const bContext *C, ARegion *ar, void *arg_info
 {
 	wmWindow *win = CTX_wm_window(C);
 	const float *mval_src = (float *)arg_info;
-	const int mval_dst[2] = {win->eventstate->x - ar->winrct.xmin,
-	                         win->eventstate->y - ar->winrct.ymin};
+	const float mval_dst[2] = {win->eventstate->x - ar->winrct.xmin,
+	                           win->eventstate->y - ar->winrct.ymin};
 
-	UI_ThemeColor(TH_VIEW_OVERLAY);
 	setlinestyle(3);
-	glBegin(GL_LINES);
-	glVertex2iv(mval_dst);
-	glVertex2fv(mval_src);
-	glEnd();
+
+	VertexFormat *format = immVertexFormat();
+	unsigned pos = add_attrib(format, "pos", GL_FLOAT, 2, KEEP_FLOAT);
+
+	immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
+	immUniformThemeColor(TH_VIEW_OVERLAY);
+
+	immBegin(GL_LINES, 2);
+	immVertex2fv(pos, mval_dst);
+	immVertex2fv(pos, mval_src);
+	immEnd();
+	immUnbindProgram();
+
 	setlinestyle(0);
 }




More information about the Bf-blender-cvs mailing list