From 12bce04b2f6bdf4830412e91a864bf0d093bda2f Mon Sep 17 00:00:00 2001 From: Mike Erwin Date: Tue, 8 Nov 2016 11:06:30 -0500 Subject: [PATCH] Blender 2.8: OpenGL: new immediate mode for paint_image.c This one is for the straight line (white with width 2.0 over a black with width 4.0) drawn when you use the gradient tool. To test: Image editor, create / open an image, choose image paint mode and on the tool shelf: choose the Fill brush and enable "Use Gradient" for it. Then click and drag on the image. From what I checked, calls to glLineWidth are not being removed yet, so I kept them. Reviewers: dfelinto, Severin, merwin Reviewed By: merwin Tags: #bf_blender_2.8, #opengl_gfx Maniphest Tasks: T49043 Differential Revision: https://developer.blender.org/D2312 --- .../editors/sculpt_paint/paint_image.c | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index bf344e1f721..ffaaed8ab42 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -78,6 +78,7 @@ #include "GPU_draw.h" #include "GPU_buffers.h" +#include "GPU_immediate.h" #include "BIF_gl.h" #include "BIF_glutil.h" @@ -721,12 +722,28 @@ static void gradient_draw_line(bContext *UNUSED(C), int x, int y, void *customda glEnable(GL_LINE_SMOOTH); glEnable(GL_BLEND); + VertexFormat* format = immVertexFormat(); + unsigned pos = add_attrib(format, "pos", GL_INT, 2, CONVERT_INT_TO_FLOAT); + + immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); + glLineWidth(4.0); - glColor4ub(0, 0, 0, 255); - sdrawline(x, y, pop->startmouse[0], pop->startmouse[1]); + immUniformColor4ub(0, 0, 0, 255); + + immBegin(GL_LINES, 2); + immVertex2i(pos, x, y); + immVertex2i(pos, pop->startmouse[0], pop->startmouse[1]); + immEnd(); + glLineWidth(2.0); - glColor4ub(255, 255, 255, 255); - sdrawline(x, y, pop->startmouse[0], pop->startmouse[1]); + immUniformColor4ub(255, 255, 255, 255); + + immBegin(GL_LINES, 2); + immVertex2i(pos, x, y); + immVertex2i(pos, pop->startmouse[0], pop->startmouse[1]); + immEnd(); + + immUnbindProgram(); glDisable(GL_BLEND); glDisable(GL_LINE_SMOOTH);