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-29 17:07:26 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2017-04-29 20:31:36 +0300
commitb1b8ce0bbf461bea54791d9987f487fe0352bbf7 (patch)
treeae58a3ad3e60f663cd5f93549206e9c3b758b19b /source/blender
parent45eaad88e2a4fddf363e1bac68d5288b25a0b08c (diff)
Getting rid of setlinestyle: GPencil eraser.
Note the ugly hack on number of segments for outline dashed circle, to get an OK-ish rendering of dashes...
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/editors/gpencil/gpencil_paint.c29
1 files changed, 23 insertions, 6 deletions
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index 1778d243849..b4092a73df8 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -1850,23 +1850,40 @@ static void gpencil_draw_eraser(bContext *UNUSED(C), int x, int y, void *p_ptr)
if (p->paintmode == GP_PAINTMODE_ERASER) {
VertexFormat *format = immVertexFormat();
- unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
+ const uint shdr_pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
glEnable(GL_LINE_SMOOTH);
glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
immUniformColor4ub(255, 100, 100, 20);
- imm_draw_circle_fill(pos, x, y, p->radius, 40);
+ imm_draw_circle_fill(shdr_pos, x, y, p->radius, 40);
- setlinestyle(6); /* TODO: handle line stipple in shader */
+ immUnbindProgram();
+
+ format = immVertexFormat();
+ const uint shdr_dashed_pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
+ const uint shdr_dashed_origin = VertexFormat_add_attrib(format, "line_origin", COMP_F32, 2, KEEP_FLOAT);
+
+ 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]);
+
+ immUniform4f("color1", 1.0f, 0.39f, 0.39f, 0.78f);
+ immUniform4f("color2", 0.0f, 0.0f, 0.0f, 0.0f);
+ immUniform1f("dash_width", 12.0f);
+ immUniform1f("dash_width_on", 6.0f);
- immUniformColor4ub(255, 100, 100, 200);
- imm_draw_circle_wire(pos, x, y, p->radius, 40);
+ imm_draw_circle_wire_dashed(shdr_dashed_pos, shdr_dashed_origin, x, y, p->radius,
+ /* XXX Dashed shader gives bad results with sets of small segments currently,
+ * temp hack around the issue. :( */
+ max_ii(8, p->radius / 2)); /* was fixed 40 */
immUnbindProgram();
- setlinestyle(0);
glDisable(GL_BLEND);
glDisable(GL_LINE_SMOOTH);
}