Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2017-04-26 22:22:05 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2017-04-26 22:22:05 +0300
commit4b682fa3e7a1df187fda355ecff3aa8cad8d4029 (patch)
tree9db3fac168e27ba7774819e116356e3137ef32c0 /source/blender/editors/sculpt_paint/paint_stroke.c
parentcf959dc03afe8ee847cfc3f6a50fe39ab10aa0e6 (diff)
Getting rid of setlinestyle: Paint 'line' strokes.
Diffstat (limited to 'source/blender/editors/sculpt_paint/paint_stroke.c')
-rw-r--r--source/blender/editors/sculpt_paint/paint_stroke.c38
1 files changed, 14 insertions, 24 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c
index d882baf6251..b6c4febe607 100644
--- a/source/blender/editors/sculpt_paint/paint_stroke.c
+++ b/source/blender/editors/sculpt_paint/paint_stroke.c
@@ -168,39 +168,32 @@ static void paint_draw_line_cursor(bContext *C, int x, int y, void *customdata)
PaintStroke *stroke = customdata;
glEnable(GL_LINE_SMOOTH);
- glEnable(GL_BLEND);
- setlinestyle(3);
- glLineWidth(3.0f);
+ VertexFormat *format = immVertexFormat();
+ unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
+ unsigned int line_origin = VertexFormat_add_attrib(format, "line_origin", COMP_F32, 2, KEEP_FLOAT);
- unsigned int pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
-
- immUniformColor4ub(0, 0, 0, paint->paint_cursor_col[3]);
-
- immBegin(PRIM_LINES, 2);
-
- if (stroke->constrain_line) {
- immVertex2f(pos, stroke->last_mouse_position[0], stroke->last_mouse_position[1]);
- immVertex2f(pos, stroke->constrained_pos[0], stroke->constrained_pos[1]);
- }
- else {
- immVertex2f(pos, stroke->last_mouse_position[0], stroke->last_mouse_position[1]);
- immVertex2f(pos, x, y);
- }
+ immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
- immEnd();
+ float viewport_size[4];
+ glGetFloatv(GL_VIEWPORT, viewport_size);
+ immUniform2f("viewport_size", viewport_size[2], viewport_size[3]);
- glLineWidth(1.0f);
- immUniformColor4ub(255, 255, 255, paint->paint_cursor_col[3]);
+ const float alpha = (float)paint->paint_cursor_col[3] / 255.0f;
+ immUniform4f("color1", 0.0f, 0.0f, 0.0f, alpha);
+ immUniform4f("color2", 1.0f, 1.0f, 1.0f, alpha);
+ immUniform1f("dash_width", 6.0f);
+ immUniform1f("dash_width_on", 3.0f);
immBegin(PRIM_LINES, 2);
if (stroke->constrain_line) {
+ immAttrib2f(line_origin, stroke->last_mouse_position[0], stroke->last_mouse_position[1]);
immVertex2f(pos, stroke->last_mouse_position[0], stroke->last_mouse_position[1]);
immVertex2f(pos, stroke->constrained_pos[0], stroke->constrained_pos[1]);
}
else {
+ immAttrib2f(line_origin, stroke->last_mouse_position[0], stroke->last_mouse_position[1]);
immVertex2f(pos, stroke->last_mouse_position[0], stroke->last_mouse_position[1]);
immVertex2f(pos, x, y);
}
@@ -209,9 +202,6 @@ static void paint_draw_line_cursor(bContext *C, int x, int y, void *customdata)
immUnbindProgram();
- setlinestyle(0);
-
- glDisable(GL_BLEND);
glDisable(GL_LINE_SMOOTH);
}