Immediate mode: edit_curve_paint 1/2
authorDalai Felinto <dfelinto@gmail.com>
Mon, 6 Feb 2017 11:40:02 +0000 (12:40 +0100)
committerDalai Felinto <dfelinto@gmail.com>
Mon, 6 Feb 2017 11:43:24 +0000 (12:43 +0100)
Part of T49043

source/blender/editors/curve/editcurve_paint.c

index 34e026a3ef4e1e58d4a4362f760a10a6e710a84a..f0cec1a84bf89778b20d9fdb406dbd3d6d26aa24 100644 (file)
@@ -48,6 +48,8 @@
 #include "BIF_gl.h"
 #include "BIF_glutil.h"
 
+#include "GPU_immediate.h"
+
 #include "curve_intern.h"
 
 #include "UI_resources.h"
@@ -514,30 +516,45 @@ static void curve_draw_stroke_3d(const struct bContext *UNUSED(C), ARegion *UNUS
                }
 
                {
+                       VertexFormat *format = immVertexFormat();
+                       unsigned pos = add_attrib(format, "pos", GL_FLOAT, 3, KEEP_FLOAT);
+                       immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
+
                        glEnable(GL_BLEND);
                        glEnable(GL_LINE_SMOOTH);
 
-                       glEnableClientState(GL_VERTEX_ARRAY);
-                       glVertexPointer(3, GL_FLOAT, 0, coord_array);
-
-                       cpack(0x0);
+                       imm_cpack(0x0);
+                       immBegin(GL_LINE_STRIP, stroke_len);
                        glLineWidth(3.0f);
-                       glDrawArrays(GL_LINE_STRIP, 0, stroke_len);
 
-                       if (v3d->zbuf)
+                       if (v3d->zbuf) {
                                glDisable(GL_DEPTH_TEST);
+                       }
+
+                       for (int i = 0; i < stroke_len; i++) {
+                               immVertex3fv(pos, coord_array[i]);
+                       }
+
+                       immEnd();
 
-                       cpack(0xffffffff);
+                       imm_cpack(0xffffffff);
+                       immBegin(GL_LINE_STRIP, stroke_len);
                        glLineWidth(1.0f);
-                       glDrawArrays(GL_LINE_STRIP, 0, stroke_len);
 
-                       if (v3d->zbuf)
-                               glEnable(GL_DEPTH_TEST);
+                       for (int i = 0; i < stroke_len; i++) {
+                               immVertex3fv(pos, coord_array[i]);
+                       }
+
+                       immEnd();
 
-                       glDisableClientState(GL_VERTEX_ARRAY);
+                       if (v3d->zbuf) {
+                               glEnable(GL_DEPTH_TEST);
+                       }
 
                        glDisable(GL_BLEND);
                        glDisable(GL_LINE_SMOOTH);
+
+                       immUnbindProgram();
                }
 
                MEM_freeN(coord_array);