From c4491d76ed35c1cdc02f2a74539bd14d7fde43dd Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Sat, 29 Apr 2017 20:41:57 +0200 Subject: Getting rid of setlinestyle: sample line in Image space. --- source/blender/editors/space_image/image_draw.c | 28 ++++++++++++++----------- 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'source/blender') diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index cdd9906271c..7c888860375 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -686,22 +686,26 @@ void draw_image_sample_line(SpaceImage *sima) if (sima->sample_line_hist.flag & HISTO_FLAG_SAMPLELINE) { Histogram *hist = &sima->sample_line_hist; - unsigned int pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT); - immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); + VertexFormat *format = immVertexFormat(); + unsigned int shdr_dashed_pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT); + unsigned int shdr_dashed_origin = VertexFormat_add_attrib(format, "line_origin", COMP_F32, 2, KEEP_FLOAT); - immBegin(PRIM_LINES, 2); - immUniformColor3ub(0, 0, 0); - immVertex2fv(pos, hist->co[0]); - immVertex2fv(pos, hist->co[1]); - immEnd(); + immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR); + + float viewport_size[4]; + glGetFloatv(GL_VIEWPORT, viewport_size); + immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC); + + immUniform4f("color1", 1.0f, 1.0f, 1.0f, 1.0f); + immUniform4f("color2", 0.0f, 0.0f, 0.0f, 1.0f); + immUniform1f("dash_width", 2.0f); + immUniform1f("dash_width_on", 1.0f); - setlinestyle(1); immBegin(PRIM_LINES, 2); - immUniformColor3ub(255, 255, 255); - immVertex2fv(pos, hist->co[0]); - immVertex2fv(pos, hist->co[1]); + immAttrib2fv(shdr_dashed_origin, hist->co[0]); + immVertex2fv(shdr_dashed_pos, hist->co[0]); + immVertex2fv(shdr_dashed_pos, hist->co[1]); immEnd(); - setlinestyle(0); immUnbindProgram(); } -- cgit v1.2.3