diff options
Diffstat (limited to 'source/blender/editors/sculpt_paint/paint_stroke.c')
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_stroke.c | 59 |
1 files changed, 34 insertions, 25 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c index 05270dbfa09..bc561c345b4 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.c +++ b/source/blender/editors/sculpt_paint/paint_stroke.c @@ -51,6 +51,7 @@ #include "BKE_curve.h" #include "BKE_colortools.h" #include "BKE_image.h" +#include "BKE_mesh.h" #include "WM_api.h" #include "WM_types.h" @@ -58,7 +59,7 @@ #include "BIF_gl.h" #include "BIF_glutil.h" -#include "GPU_basic_shader.h" +#include "GPU_immediate.h" #include "ED_screen.h" #include "ED_view3d.h" @@ -145,9 +146,18 @@ static void paint_draw_smooth_cursor(bContext *C, int x, int y, void *customdata if (stroke && brush) { glEnable(GL_LINE_SMOOTH); glEnable(GL_BLEND); - glColor4ubv(paint->paint_cursor_col); - sdrawline(x, y, (int)stroke->last_mouse_position[0], - (int)stroke->last_mouse_position[1]); + + unsigned int pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT); + immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); + immUniformColor4ubv(paint->paint_cursor_col); + + immBegin(PRIM_LINES, 2); + immVertex2f(pos, x, y); + immVertex2f(pos, stroke->last_mouse_position[0], stroke->last_mouse_position[1]); + immEnd(); + + immUnbindProgram(); + glDisable(GL_BLEND); glDisable(GL_LINE_SMOOTH); } @@ -159,36 +169,35 @@ static void paint_draw_line_cursor(bContext *C, int x, int y, void *customdata) PaintStroke *stroke = customdata; glEnable(GL_LINE_SMOOTH); - glEnable(GL_BLEND); - 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); + uint shdr_pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT); - glColor4ub(0, 0, 0, paint->paint_cursor_col[3]); - 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]); - } - else { - sdrawline((int)stroke->last_mouse_position[0], (int)stroke->last_mouse_position[1], - x, y); - } + immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR); + + float viewport_size[4]; + glGetFloatv(GL_VIEWPORT, viewport_size); + immUniform2f("viewport_size", viewport_size[2], viewport_size[3]); + + immUniform1i("num_colors", 2); /* "advanced" mode */ + const float alpha = (float)paint->paint_cursor_col[3] / 255.0f; + immUniformArray4fv("colors", (float *)(float[][4]){{0.0f, 0.0f, 0.0f, alpha}, {1.0f, 1.0f, 1.0f, alpha}}, 2); + immUniform1f("dash_width", 6.0f); + + immBegin(PRIM_LINES, 2); - glColor4ub(255, 255, 255, paint->paint_cursor_col[3]); - 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]); + immVertex2f(shdr_pos, stroke->last_mouse_position[0], stroke->last_mouse_position[1]); + immVertex2f(shdr_pos, stroke->constrained_pos[0], stroke->constrained_pos[1]); } else { - sdrawline((int)stroke->last_mouse_position[0], (int)stroke->last_mouse_position[1], - x, y); + immVertex2f(shdr_pos, stroke->last_mouse_position[0], stroke->last_mouse_position[1]); + immVertex2f(shdr_pos, x, y); } - GPU_basic_shader_bind_disable(GPU_SHADER_LINE | GPU_SHADER_STIPPLE); + immEnd(); + + immUnbindProgram(); - glDisable(GL_BLEND); glDisable(GL_LINE_SMOOTH); } |