Commit: 47b21dd4c6768e0410e4a73350be75bfb1123188
Author: Luca Rood
Date:   Thu Feb 2 03:14:52 2017 -0200
Branches: blender2.8
https://developer.blender.org/rB47b21dd4c6768e0410e4a73350be75bfb1123188

OpenGL immediate mode: transform_snap.c and part of drawnode.c

Also converted ED_node_draw_snap from drawnode.c
Committing these together, as they are inter-dependent.

Part of T49043

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

M       source/blender/editors/include/ED_node.h
M       source/blender/editors/space_node/drawnode.c
M       source/blender/editors/transform/transform_snap.c

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

diff --git a/source/blender/editors/include/ED_node.h 
b/source/blender/editors/include/ED_node.h
index f7b9d6b4f9..b4cf96f27b 100644
--- a/source/blender/editors/include/ED_node.h
+++ b/source/blender/editors/include/ED_node.h
@@ -75,7 +75,7 @@ void ED_init_custom_node_socket_type(struct bNodeSocketType 
*stype);
 void ED_init_standard_node_socket_type(struct bNodeSocketType *stype);
 void ED_init_node_socket_type_virtual(struct bNodeSocketType *stype);
 void ED_node_sample_set(const float col[4]);
-void ED_node_draw_snap(struct View2D *v2d, const float cent[2], float size, 
NodeBorder border);
+void ED_node_draw_snap(struct View2D *v2d, const float cent[2], float size, 
NodeBorder border, unsigned pos);
 
 /* node_draw.c */
 void ED_node_tree_update(const struct bContext *C);
diff --git a/source/blender/editors/space_node/drawnode.c 
b/source/blender/editors/space_node/drawnode.c
index e02c69ea85..5940ed5f0c 100644
--- a/source/blender/editors/space_node/drawnode.c
+++ b/source/blender/editors/space_node/drawnode.c
@@ -3619,27 +3619,27 @@ void node_draw_link(View2D *v2d, SpaceNode *snode, 
bNodeLink *link)
 //     node_draw_link_straight(v2d, snode, link, th_col1, do_shaded, th_col2, 
do_triple, th_col3);
 }
 
-void ED_node_draw_snap(View2D *v2d, const float cent[2], float size, 
NodeBorder border)
+void ED_node_draw_snap(View2D *v2d, const float cent[2], float size, 
NodeBorder border, unsigned pos)
 {
-       glBegin(GL_LINES);
+       immBegin(GL_LINES, 4);
        
        if (border & (NODE_LEFT | NODE_RIGHT)) {
-               glVertex2f(cent[0], v2d->cur.ymin);
-               glVertex2f(cent[0], v2d->cur.ymax);
+               immVertex2f(pos, cent[0], v2d->cur.ymin);
+               immVertex2f(pos, cent[0], v2d->cur.ymax);
        }
        else {
-               glVertex2f(cent[0], cent[1] - size);
-               glVertex2f(cent[0], cent[1] + size);
+               immVertex2f(pos, cent[0], cent[1] - size);
+               immVertex2f(pos, cent[0], cent[1] + size);
        }
        
        if (border & (NODE_TOP | NODE_BOTTOM)) {
-               glVertex2f(v2d->cur.xmin, cent[1]);
-               glVertex2f(v2d->cur.xmax, cent[1]);
+               immVertex2f(pos, v2d->cur.xmin, cent[1]);
+               immVertex2f(pos, v2d->cur.xmax, cent[1]);
        }
        else {
-               glVertex2f(cent[0] - size, cent[1]);
-               glVertex2f(cent[0] + size, cent[1]);
+               immVertex2f(pos, cent[0] - size, cent[1]);
+               immVertex2f(pos, cent[0] + size, cent[1]);
        }
        
-       glEnd();
+       immEnd();
 }
diff --git a/source/blender/editors/transform/transform_snap.c 
b/source/blender/editors/transform/transform_snap.c
index 87ac54b2bd..6ca963bc0e 100644
--- a/source/blender/editors/transform/transform_snap.c
+++ b/source/blender/editors/transform/transform_snap.c
@@ -49,7 +49,7 @@
 #include "BLI_blenlib.h"
 #include "BLI_utildefines.h"
 
-#include "BIF_gl.h"
+#include "GPU_immediate.h"
 
 #include "BKE_DerivedMesh.h"
 #include "BKE_global.h"
@@ -163,36 +163,42 @@ void drawSnapping(const struct bContext *C, TransInfo *t)
                        size = 2.5f * UI_GetThemeValuef(TH_VERTEX_SIZE);
                        
                        invert_m4_m4(imat, rv3d->viewmat);
-                       
+
+                       unsigned pos = add_attrib(immVertexFormat(), "pos", 
GL_FLOAT, 3, KEEP_FLOAT);
+
+                       immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
+
                        for (p = t->tsnap.points.first; p; p = p->next) {
                                if (p == t->tsnap.selectedPoint) {
-                                       glColor4ubv(selectedCol);
+                                       immUniformColor4ubv(selectedCol);
                                }
                                else {
-                                       glColor4ubv(col);
+                                       immUniformColor4ubv(col);
                                }
                                
-                               drawcircball(GL_LINE_LOOP, p->co, 
ED_view3d_pixel_size(rv3d, p->co) * size * 0.75f, imat);
+                               imm_drawcircball(p->co, 
ED_view3d_pixel_size(rv3d, p->co) * size * 0.75f, imat, pos);
                        }
                        
                        if (t->tsnap.status & POINT_INIT) {
-                               glColor4ubv(activeCol);
+                               immUniformColor4ubv(activeCol);
                                
-                               drawcircball(GL_LINE_LOOP, t->tsnap.snapPoint, 
ED_view3d_pixel_size(rv3d, t->tsnap.snapPoint) * size, imat);
+                               imm_drawcircball(t->tsnap.snapPoint, 
ED_view3d_pixel_size(rv3d, t->tsnap.snapPoint) * size, imat, pos);
                        }
                        
                        /* draw normal if needed */
                        if (usingSnappingNormal(t) && validSnappingNormal(t)) {
-                               glColor4ubv(activeCol);
+                               immUniformColor4ubv(activeCol);
                                
-                               glBegin(GL_LINES);
-                               glVertex3f(t->tsnap.snapPoint[0], 
t->tsnap.snapPoint[1], t->tsnap.snapPoint[2]);
-                               glVertex3f(t->tsnap.snapPoint[0] + 
t->tsnap.snapNormal[0],
-                                          t->tsnap.snapPoint[1] + 
t->tsnap.snapNormal[1],
-                                          t->tsnap.snapPoint[2] + 
t->tsnap.snapNormal[2]);
-                               glEnd();
+                               immBegin(GL_LINES, 2);
+                               immVertex3f(pos, t->tsnap.snapPoint[0], 
t->tsnap.snapPoint[1], t->tsnap.snapPoint[2]);
+                               immVertex3f(pos, t->tsnap.snapPoint[0] + 
t->tsnap.snapNormal[0],
+                                           t->tsnap.snapPoint[1] + 
t->tsnap.snapNormal[1],
+                                           t->tsnap.snapPoint[2] + 
t->tsnap.snapNormal[2]);
+                               immEnd();
                        }
-                       
+
+                       immUnbindProgram();
+
                        if (v3d->zbuf)
                                glEnable(GL_DEPTH_TEST);
                }
@@ -241,23 +247,29 @@ void drawSnapping(const struct bContext *C, TransInfo *t)
                        
                        glEnable(GL_BLEND);
                        
+                       unsigned pos = add_attrib(immVertexFormat(), "pos", 
GL_FLOAT, 2, KEEP_FLOAT);
+
+                       immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
+
                        for (p = t->tsnap.points.first; p; p = p->next) {
                                if (p == t->tsnap.selectedPoint) {
-                                       glColor4ubv(selectedCol);
+                                       immUniformColor4ubv(selectedCol);
                                }
                                else {
-                                       glColor4ubv(col);
+                                       immUniformColor4ubv(col);
                                }
                                
-                               ED_node_draw_snap(&ar->v2d, p->co, size, 0);
+                               ED_node_draw_snap(&ar->v2d, p->co, size, 0, 
pos);
                        }
                        
                        if (t->tsnap.status & POINT_INIT) {
-                               glColor4ubv(activeCol);
+                               immUniformColor4ubv(activeCol);
                                
-                               ED_node_draw_snap(&ar->v2d, t->tsnap.snapPoint, 
size, t->tsnap.snapNodeBorder);
+                               ED_node_draw_snap(&ar->v2d, t->tsnap.snapPoint, 
size, t->tsnap.snapNodeBorder, pos);
                        }
-                       
+
+                       immUnbindProgram();
+
                        glDisable(GL_BLEND);
                }
        }

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

Reply via email to