Merge remote-tracking branch 'origin/master' into blender2.8
[blender.git] / source / blender / editors / gpencil / gpencil_paint.c
index c23bfb1ff607443a50362cbd2443ce7541ec26c2..b483402d6c83799fe14a12c853cc43252c35e08c 100644 (file)
 #include "ED_view3d.h"
 #include "ED_clip.h"
 
-#include "BIF_gl.h"
 #include "BIF_glutil.h"
 
+#include "GPU_immediate.h"
+
 #include "RNA_access.h"
 #include "RNA_define.h"
 
@@ -1546,6 +1547,7 @@ static bool gp_session_initdata(bContext *C, tGPsdata *p)
        bGPDpalettecolor *palcolor = p->palettecolor;
        bGPdata *pdata = p->gpd;
        copy_v4_v4(pdata->scolor, palcolor->color);
+       copy_v4_v4(pdata->sfill, palcolor->fill);
        pdata->sflag = palcolor->flag;
        /* lock axis */
        p->lock_axis = ts->gp_sculpt.lock_axis;
@@ -1832,28 +1834,28 @@ static void gp_paint_cleanup(tGPsdata *p)
 static void gpencil_draw_eraser(bContext *UNUSED(C), int x, int y, void *p_ptr)
 {
        tGPsdata *p = (tGPsdata *)p_ptr;
-       
+
        if (p->paintmode == GP_PAINTMODE_ERASER) {
-               glPushMatrix();
-               
-               glTranslatef((float)x, (float)y, 0.0f);
-               
+               VertexFormat *format = immVertexFormat();
+               unsigned pos = add_attrib(format, "pos", GL_FLOAT, 2, KEEP_FLOAT);
+               immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
+
                glEnable(GL_LINE_SMOOTH);
                glEnable(GL_BLEND);
-               
-               glColor4ub(255, 100, 100, 20);
-               glutil_draw_filled_arc(0.0, M_PI * 2.0, p->radius, 40);
-               
-               setlinestyle(6);
-               
-               glColor4ub(255, 100, 100, 200);
-               glutil_draw_lined_arc(0.0, M_PI * 2.0, p->radius, 40);
-               
+
+               immUniformColor4ub(255, 100, 100, 20);
+               imm_draw_filled_circle(pos, x, y, p->radius, 40);
+
+               setlinestyle(6); /* TODO: handle line stipple in shader */
+
+               immUniformColor4ub(255, 100, 100, 200);
+               imm_draw_lined_circle(pos, x, y, p->radius, 40);
+
+               immUnbindProgram();
+
                setlinestyle(0);
                glDisable(GL_BLEND);
                glDisable(GL_LINE_SMOOTH);
-               
-               glPopMatrix();
        }
 }