diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2016-10-20 02:59:22 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2016-10-20 02:59:22 +0300 |
commit | 33d99bdfe6c4f883671c4ab757a85bea781f820e (patch) | |
tree | 7f180cb57d74d02dea012665060bd93638eb2967 /source/blender/editors/util/ed_util.c | |
parent | 9941bc3041c6712d6e2ccca3ac5559c55d82bfc1 (diff) |
immediate mode: ed_util.c
note: I switched one of the glVertex2iv into glVertex2fv to use the same attrib_id
Diffstat (limited to 'source/blender/editors/util/ed_util.c')
-rw-r--r-- | source/blender/editors/util/ed_util.c | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c index 1f1a778cac7..482523e56be 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); } |