From d2589b0a31bfbbc3dc9b5992de49ce571454341a Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Sat, 29 Apr 2017 12:43:37 +0200 Subject: Getting rid of setlinestyle: Text space margin line. --- source/blender/editors/space_text/text_draw.c | 32 ++++++++++++++++++++------- 1 file changed, 24 insertions(+), 8 deletions(-) (limited to 'source/blender') diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c index 148f605f68c..c4e6dde2a64 100644 --- a/source/blender/editors/space_text/text_draw.c +++ b/source/blender/editors/space_text/text_draw.c @@ -1501,18 +1501,34 @@ void draw_text_main(SpaceText *st, ARegion *ar) margin_column_x = x + st->cwidth * (st->margin_column - st->left); if (margin_column_x >= x) { - setlinestyle(1); - unsigned int pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_I32, 2, CONVERT_INT_TO_FLOAT); - immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); + VertexFormat *format = immVertexFormat(); + uint shdr_dashed_pos = VertexFormat_add_attrib(format, "pos", COMP_I32, 2, CONVERT_INT_TO_FLOAT); + uint shdr_dashed_origin = VertexFormat_add_attrib(format, "line_origin", COMP_I32, 2, CONVERT_INT_TO_FLOAT); + + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + 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); + + float color1[4]; + UI_GetThemeColor4fv(TH_GRID, color1); /* same color as line number background */ + immUniform4fv("color1", color1); + immUniform4f("color2", 0.0f, 0.0f, 0.0f, 0.0f); + immUniform1f("dash_width", 2.0f); + immUniform1f("dash_width_on", 1.0f); - /* same color as line number background */ - immUniformThemeColor(TH_GRID); immBegin(PRIM_LINES, 2); - immVertex2i(pos, margin_column_x, 0); - immVertex2i(pos, margin_column_x, ar->winy - 2); + immAttrib2i(shdr_dashed_origin, margin_column_x, 0); + immVertex2i(shdr_dashed_pos, margin_column_x, 0); + immVertex2i(shdr_dashed_pos, margin_column_x, ar->winy - 2); immEnd(); immUnbindProgram(); - setlinestyle(0); + + glDisable(GL_BLEND); } } -- cgit v1.2.3