Commit: 9dd86e275865068165b73ec4fcd87c25855ab0fa
Author: Luca Rood
Date:   Tue Feb 21 22:17:47 2017 -0300
Branches: blender2.8
https://developer.blender.org/rB9dd86e275865068165b73ec4fcd87c25855ab0fa

OpenGl immediate mode: drawnode.c

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 ee93344cda..7367cc4312 100644
--- a/source/blender/editors/space_node/drawnode.c
+++ b/source/blender/editors/space_node/drawnode.c
@@ -353,6 +353,7 @@ static void node_draw_frame_label(bNodeTree *ntree, bNode 
*node, const float asp
        const int font_size = data->label_size / aspect;
        const float margin = (float)(NODE_DY / 4);
        int label_height;
+       unsigned char color[3];
 
        nodeLabel(ntree, node, label, sizeof(label));
 
@@ -361,7 +362,8 @@ static void node_draw_frame_label(bNodeTree *ntree, bNode 
*node, const float asp
        BLF_size(fontid, MIN2(24, font_size), U.dpi); /* clamp otherwise it can 
suck up a LOT of memory */
        
        /* title color */
-       UI_ThemeColorBlendShade(TH_TEXT, color_id, 0.4f, 10);
+       UI_GetThemeColorBlendShade3ubv(TH_TEXT, color_id, 0.4f, 10, color);
+       BLF_color3ubv(fontid, color);
 
        width = BLF_width(fontid, label, sizeof(label));
        ascender = BLF_ascender(fontid);
@@ -3267,13 +3269,19 @@ void draw_nodespace_back_pix(const bContext *C, ARegion 
*ar, SpaceNode *snode, b
                            viewer_border->ymin < viewer_border->ymax)
                        {
                                rcti pixel_border;
-                               UI_ThemeColor(TH_ACTIVE);
                                BLI_rcti_init(&pixel_border,
                                              x + snode->zoom * 
viewer_border->xmin * ibuf->x,
                                              x + snode->zoom * 
viewer_border->xmax * ibuf->x,
                                              y + snode->zoom * 
viewer_border->ymin * ibuf->y,
                                              y + snode->zoom * 
viewer_border->ymax * ibuf->y);
-                               glaDrawBorderCorners(&pixel_border, 1.0f, 1.0f);
+
+                               unsigned int pos = 
add_attrib(immVertexFormat(), "pos", GL_FLOAT, 2, KEEP_FLOAT);
+                               
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
+                               immUniformThemeColor(TH_ACTIVE);
+
+                               immDrawBorderCorners(pos, &pixel_border, 1.0f, 
1.0f);
+
+                               immUnbindProgram();
                        }
                }
                
@@ -3393,6 +3401,7 @@ void node_draw_link_bezier(View2D *v2d, SpaceNode *snode, 
bNodeLink *link,
                float arrow[2], arrow1[2], arrow2[2];
                const float px_fac = UI_DPI_WINDOW_FAC;
                glGetFloatv(GL_LINE_WIDTH, &linew);
+               unsigned int pos;
                
                /* we can reuse the dist variable here to increment the GL 
curve eval amount*/
                dist = 1.0f / (float)LINK_RESOL;
@@ -3416,57 +3425,84 @@ void node_draw_link_bezier(View2D *v2d, SpaceNode 
*snode, bNodeLink *link,
                        arrow[0] = coord_array[LINK_ARROW][0];
                        arrow[1] = coord_array[LINK_ARROW][1];
                }
+
+               if (do_triple || drawarrow || (!do_shaded)) {
+                       pos = add_attrib(immVertexFormat(), "pos", GL_FLOAT, 2, 
KEEP_FLOAT);
+                       immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
+               }
+
                if (do_triple) {
-                       UI_ThemeColorShadeAlpha(th_col3, -80, -120);
+                       immUniformThemeColorShadeAlpha(th_col3, -80, -120);
                        glLineWidth(4.0f * px_fac);
-                       
-                       glBegin(GL_LINE_STRIP);
+
+                       immBegin(GL_LINE_STRIP, (LINK_RESOL + 1));
+
                        for (i = 0; i <= LINK_RESOL; i++) {
-                               glVertex2fv(coord_array[i]);
+                               immVertex2fv(pos, coord_array[i]);
                        }
-                       glEnd();
+
+                       immEnd();
+
                        if (drawarrow) {
-                               glBegin(GL_LINE_STRIP);
-                               glVertex2fv(arrow1);
-                               glVertex2fv(arrow);
-                               glVertex2fv(arrow2);
-                               glEnd();
+                               immBegin(GL_LINE_STRIP, 3);
+                               immVertex2fv(pos, arrow1);
+                               immVertex2fv(pos, arrow);
+                               immVertex2fv(pos, arrow2);
+                               immEnd();
                        }
                }
-               
-               /* XXX using GL_LINES for shaded node lines is a workaround
-                * for Intel hardware, this breaks with GL_LINE_STRIP and
-                * changing color in begin/end blocks.
-                */
+
                glLineWidth(1.5f * px_fac);
-               if (do_shaded) {
-                       glBegin(GL_LINES);
-                       for (i = 0; i < LINK_RESOL; i++) {
-                               UI_ThemeColorBlend(th_col1, th_col2, 
spline_step);
-                               glVertex2fv(coord_array[i]);
-                               
-                               UI_ThemeColorBlend(th_col1, th_col2, 
spline_step + dist);
-                               glVertex2fv(coord_array[i + 1]);
-                               
-                               spline_step += dist;
-                       }
-                       glEnd();
+
+               if (drawarrow) {
+                       immUniformThemeColorBlend(th_col1, th_col2, 0.5f);
+
+                       immBegin(GL_LINE_STRIP, 3);
+                       immVertex2fv(pos, arrow1);
+                       immVertex2fv(pos, arrow);
+                       immVertex2fv(pos, arrow2);
+                       immEnd();
                }
-               else {
-                       UI_ThemeColor(th_col1);
-                       glBegin(GL_LINE_STRIP);
+
+               if (!do_shaded) {
+                       immUniformThemeColor(th_col1);
+
+                       immBegin(GL_LINE_STRIP, (LINK_RESOL + 1));
+
                        for (i = 0; i <= LINK_RESOL; i++) {
-                               glVertex2fv(coord_array[i]);
+                               immVertex2fv(pos, coord_array[i]);
                        }
-                       glEnd();
+
+                       immEnd();
                }
-               
-               if (drawarrow) {
-                       glBegin(GL_LINE_STRIP);
-                       glVertex2fv(arrow1);
-                       glVertex2fv(arrow);
-                       glVertex2fv(arrow2);
-                       glEnd();
+
+               if (do_triple || drawarrow || (!do_shaded)) {
+                       immUnbindProgram();
+               }
+
+               if (do_shaded) {
+                       unsigned char col[3];
+
+                       VertexFormat *format = immVertexFormat();
+                       pos = add_attrib(format, "pos", GL_FLOAT, 2, 
KEEP_FLOAT);
+                       unsigned int color = add_attrib(format, "color", 
GL_UNSIGNED_BYTE, 3, NORMALIZE_INT_TO_FLOAT);
+
+                       immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR);
+
+                       immBegin(GL_LINE_STRIP, (LINK_RESOL + 1));
+
+                       for (i = 0; i <= LINK_RESOL; i++) {
+                               UI_GetThemeColorBlend3ubv(th_col1, th_col2, 
spline_step, col);
+                               immAttrib3ubv(color, col);
+
+                               immVertex2fv(pos, coord_array[i]);
+
+                               spline_step += dist;
+                       }
+
+                       immEnd();
+
+                       immUnbindProgram();
                }
                
                glDisable(GL_LINE_SMOOTH);

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to