Commit: 4ff4dbc0abc04020ff2608d1c7abc8eafd160c88
Author: Lukas Tönne
Date:   Thu Dec 1 17:07:39 2016 +0100
Branches: blender2.8
https://developer.blender.org/rB4ff4dbc0abc04020ff2608d1c7abc8eafd160c88

Immediate mode replacement for compositor node backdrop elements.

Part of T49043.

===================================================================

M       source/blender/editors/space_node/drawnode.c

===================================================================

diff --git a/source/blender/editors/space_node/drawnode.c 
b/source/blender/editors/space_node/drawnode.c
index 25e6e3d..c3f2d05 100644
--- a/source/blender/editors/space_node/drawnode.c
+++ b/source/blender/editors/space_node/drawnode.c
@@ -2187,14 +2187,21 @@ static void node_composit_backdrop_viewer(SpaceNode 
*snode, ImBuf *backdrop, bNo
                const float cx  = x + snode->zoom * backdropWidth * 
node->custom3;
                const float cy = y + snode->zoom * backdropHeight * 
node->custom4;
 
-               glColor3f(1.0, 1.0, 1.0);
+               VertexFormat* format = immVertexFormat();
+               unsigned pos = add_attrib(format, "pos", GL_FLOAT, 2, 
KEEP_FLOAT);
 
-               glBegin(GL_LINES);
-               glVertex2f(cx - 25, cy - 25);
-               glVertex2f(cx + 25, cy + 25);
-               glVertex2f(cx + 25, cy - 25);
-               glVertex2f(cx - 25, cy + 25);
-               glEnd();
+               immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
+
+               immUniformColor3f(1.0f, 1.0f, 1.0f);
+
+               immBegin(GL_LINES, 4);
+               immVertex2f(pos, cx - 25, cy - 25);
+               immVertex2f(pos, cx + 25, cy + 25);
+               immVertex2f(pos, cx + 25, cy - 25);
+               immVertex2f(pos, cx - 25, cy + 25);
+               immEnd();
+
+               immUnbindProgram();
        }
 }
 
@@ -2213,9 +2220,6 @@ static void node_composit_backdrop_boxmask(SpaceNode 
*snode, ImBuf *backdrop, bN
        float cx, cy, x1, x2, x3, x4;
        float y1, y2, y3, y4;
 
-
-       glColor3f(1.0, 1.0, 1.0);
-
        cx  = x + snode->zoom * backdropWidth * boxmask->x;
        cy = y + snode->zoom * backdropHeight * boxmask->y;
 
@@ -2228,12 +2232,21 @@ static void node_composit_backdrop_boxmask(SpaceNode 
*snode, ImBuf *backdrop, bN
        y3 = cy - (-sine * -halveBoxWidth + cosine * -halveBoxHeight) * 
snode->zoom;
        y4 = cy - (-sine * halveBoxWidth + cosine * -halveBoxHeight) * 
snode->zoom;
 
-       glBegin(GL_LINE_LOOP);
-       glVertex2f(x1, y1);
-       glVertex2f(x2, y2);
-       glVertex2f(x3, y3);
-       glVertex2f(x4, y4);
-       glEnd();
+       VertexFormat* format = immVertexFormat();
+       unsigned pos = add_attrib(format, "pos", GL_FLOAT, 2, KEEP_FLOAT);
+
+       immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
+
+       immUniformColor3f(1.0f, 1.0f, 1.0f);
+
+       immBegin(GL_LINE_LOOP, 4);
+       immVertex2f(pos, x1, y1);
+       immVertex2f(pos, x2, y2);
+       immVertex2f(pos, x3, y3);
+       immVertex2f(pos, x4, y4);
+       immEnd();
+
+       immUnbindProgram();
 }
 
 static void node_composit_backdrop_ellipsemask(SpaceNode *snode, ImBuf 
*backdrop, bNode *node, int x, int y)
@@ -2251,9 +2264,6 @@ static void node_composit_backdrop_ellipsemask(SpaceNode 
*snode, ImBuf *backdrop
        float cx, cy, x1, x2, x3, x4;
        float y1, y2, y3, y4;
 
-
-       glColor3f(1.0, 1.0, 1.0);
-
        cx  = x + snode->zoom * backdropWidth * ellipsemask->x;
        cy = y + snode->zoom * backdropHeight * ellipsemask->y;
 
@@ -2266,13 +2276,21 @@ static void 
node_composit_backdrop_ellipsemask(SpaceNode *snode, ImBuf *backdrop
        y3 = cy - (-sine * -halveBoxWidth + cosine * -halveBoxHeight) * 
snode->zoom;
        y4 = cy - (-sine * halveBoxWidth + cosine * -halveBoxHeight) * 
snode->zoom;
 
-       glBegin(GL_LINE_LOOP);
+       VertexFormat* format = immVertexFormat();
+       unsigned pos = add_attrib(format, "pos", GL_FLOAT, 2, KEEP_FLOAT);
 
-       glVertex2f(x1, y1);
-       glVertex2f(x2, y2);
-       glVertex2f(x3, y3);
-       glVertex2f(x4, y4);
-       glEnd();
+       immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
+
+       immUniformColor3f(1.0f, 1.0f, 1.0f);
+
+       immBegin(GL_LINE_LOOP, 4);
+       immVertex2f(pos, x1, y1);
+       immVertex2f(pos, x2, y2);
+       immVertex2f(pos, x3, y3);
+       immVertex2f(pos, x4, y4);
+       immEnd();
+
+       immUnbindProgram();
 }
 
 static void node_composit_buts_ellipsemask(uiLayout *layout, bContext 
*UNUSED(C), PointerRNA *ptr)

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to