diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2020-06-28 17:29:27 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2020-06-29 15:19:52 +0300 |
commit | bd6cc282d28f58766d84d78d4400d3020fe4cb10 (patch) | |
tree | 42471a90d3b6a584c7eb71b785b1bbfafb04db9c /source | |
parent | 0d2e628964763a5ad872d51aec07bd551cbb2272 (diff) |
Fix T61573 GPencil: Annotation thickness doesn't work with on OSX
This fixes the issue by using the polyline shader but this does not gives
the best results.
A better way would be to have a dedicated shader for the lines to avoid
the line break at every angle change.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/gpencil/annotate_draw.c | 39 |
1 files changed, 26 insertions, 13 deletions
diff --git a/source/blender/editors/gpencil/annotate_draw.c b/source/blender/editors/gpencil/annotate_draw.c index 22df7bbbf31..089f41b4a66 100644 --- a/source/blender/editors/gpencil/annotate_draw.c +++ b/source/blender/editors/gpencil/annotate_draw.c @@ -172,9 +172,14 @@ static void annotation_draw_stroke_buffer(bGPdata *gps, float oldpressure = points[0].pressure; /* draw stroke curve */ - GPU_line_width(max_ff(oldpressure * thickness, 1.0)); + immBindBuiltinProgram(GPU_SHADER_3D_POLYLINE_UNIFORM_COLOR); + + float viewport[4]; + GPU_viewport_size_get_f(viewport); + immUniform2fv("viewportSize", &viewport[2]); + + immUniform1f("lineWidth", max_ff(oldpressure * thickness, 1.0) * U.pixelsize); - immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor3fvAlpha(ink, ink[3]); immBeginAtMost(GPU_PRIM_LINE_STRIP, totpoints); @@ -193,7 +198,7 @@ static void annotation_draw_stroke_buffer(bGPdata *gps, immEnd(); draw_points = 0; - GPU_line_width(max_ff(pt->pressure * thickness, 1.0f)); + immUniform1f("lineWidth", max_ff(pt->pressure * thickness, 1.0) * U.pixelsize); immBeginAtMost(GPU_PRIM_LINE_STRIP, totpoints - i + 1); /* need to roll-back one point to ensure that there are no gaps in the stroke */ @@ -327,11 +332,17 @@ static void annotation_draw_stroke_3d( GPUVertFormat *format = immVertexFormat(); uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); - immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); + immBindBuiltinProgram(GPU_SHADER_3D_POLYLINE_UNIFORM_COLOR); + + float viewport[4]; + GPU_viewport_size_get_f(viewport); + immUniform2fv("viewportSize", &viewport[2]); + + immUniform1f("lineWidth", max_ff(curpressure * thickness, 1.0) * U.pixelsize); + immUniformColor3fvAlpha(ink, ink[3]); /* draw stroke curve */ - GPU_line_width(max_ff(curpressure * thickness, 1.0f)); immBeginAtMost(GPU_PRIM_LINE_STRIP, totpoints + cyclic_add); const bGPDspoint *pt = points; for (int i = 0; i < totpoints; i++, pt++) { @@ -351,7 +362,7 @@ static void annotation_draw_stroke_3d( draw_points = 0; curpressure = pt->pressure; - GPU_line_width(max_ff(curpressure * thickness, 1.0f)); + immUniform1f("lineWidth", max_ff(curpressure * thickness, 1.0) * U.pixelsize); immBeginAtMost(GPU_PRIM_LINE_STRIP, totpoints - i + 1 + cyclic_add); /* need to roll-back one point to ensure that there are no gaps in the stroke */ @@ -424,11 +435,15 @@ static void annotation_draw_stroke_2d(const bGPDspoint *points, } else { /* draw stroke curve */ - GPU_line_width(max_ff(oldpressure * thickness, 1.0)); - - immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); + immBindBuiltinProgram(GPU_SHADER_3D_POLYLINE_UNIFORM_COLOR); immUniformColor3fvAlpha(ink, ink[3]); + float viewport[4]; + GPU_viewport_size_get_f(viewport); + immUniform2fv("viewportSize", &viewport[2]); + + immUniform1f("lineWidth", max_ff(oldpressure * thickness, 1.0) * U.pixelsize); + immBeginAtMost(GPU_PRIM_LINE_STRIP, totpoints); for (int i = 0; i < totpoints; i++) { @@ -448,7 +463,8 @@ static void annotation_draw_stroke_2d(const bGPDspoint *points, immEnd(); draw_points = 0; - GPU_line_width(max_ff(pt->pressure * thickness, 1.0f)); + immUniform1f("lineWidth", max_ff(pt->pressure * thickness, 1.0) * U.pixelsize); + immBeginAtMost(GPU_PRIM_LINE_STRIP, totpoints - i + 1); /* need to roll-back one point to ensure that there are no gaps in the stroke */ @@ -683,9 +699,6 @@ static void annotation_draw_data_layers( continue; } - /* set basic stroke thickness */ - GPU_line_width(lthick); - /* Add layer drawing settings to the set of "draw flags" * NOTE: If the setting doesn't apply, it *must* be cleared, * as dflag's carry over from the previous layer |