Merge branch 'master' into blender2.8
[blender.git] / source / blender / editors / space_view3d / view3d_fly.c
index eda780d01a7a3a509840a6b6faaa4e4ffb045ffc..5e7eddb1c221642d72c952b1ac3037111a05da26 100644 (file)
@@ -56,6 +56,8 @@
 #include "UI_interface.h"
 #include "UI_resources.h"
 
+#include "GPU_immediate.h"
+
 #include "view3d_intern.h"  /* own include */
 
 /* NOTE: these defines are saved in keymap files, do not change values but just add new ones */
@@ -257,36 +259,45 @@ static void drawFlyPixel(const struct bContext *UNUSED(C), ARegion *UNUSED(ar),
        x2 = xoff + 0.55f * fly->width;
        y2 = yoff + 0.55f * fly->height;
 
-       UI_ThemeColor(TH_VIEW_OVERLAY);
-       glBegin(GL_LINES);
+       Gwn_VertFormat *format = immVertexFormat();
+       unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
+
+       immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
+
+       immUniformThemeColor(TH_VIEW_OVERLAY);
+
+       immBegin(GWN_PRIM_LINES, 16);
+
        /* bottom left */
-       glVertex2f(x1, y1);
-       glVertex2f(x1, y1 + 5);
+       immVertex2f(pos, x1, y1);
+       immVertex2f(pos, x1, y1 + 5);
 
-       glVertex2f(x1, y1);
-       glVertex2f(x1 + 5, y1);
+       immVertex2f(pos, x1, y1);
+       immVertex2f(pos, x1 + 5, y1);
 
        /* top right */
-       glVertex2f(x2, y2);
-       glVertex2f(x2, y2 - 5);
+       immVertex2f(pos, x2, y2);
+       immVertex2f(pos, x2, y2 - 5);
 
-       glVertex2f(x2, y2);
-       glVertex2f(x2 - 5, y2);
+       immVertex2f(pos, x2, y2);
+       immVertex2f(pos, x2 - 5, y2);
 
        /* top left */
-       glVertex2f(x1, y2);
-       glVertex2f(x1, y2 - 5);
+       immVertex2f(pos, x1, y2);
+       immVertex2f(pos, x1, y2 - 5);
 
-       glVertex2f(x1, y2);
-       glVertex2f(x1 + 5, y2);
+       immVertex2f(pos, x1, y2);
+       immVertex2f(pos, x1 + 5, y2);
 
        /* bottom right */
-       glVertex2f(x2, y1);
-       glVertex2f(x2, y1 + 5);
+       immVertex2f(pos, x2, y1);
+       immVertex2f(pos, x2, y1 + 5);
+
+       immVertex2f(pos, x2, y1);
+       immVertex2f(pos, x2 - 5, y1);
 
-       glVertex2f(x2, y1);
-       glVertex2f(x2 - 5, y1);
-       glEnd();
+       immEnd();
+       immUnbindProgram();
 }
 
 static void fly_update_header(bContext *C, wmOperator *op, FlyInfo *fly)
@@ -406,7 +417,7 @@ static bool initFlyInfo(bContext *C, FlyInfo *fly, wmOperator *op, const wmEvent
        }
 
        fly->v3d_camera_control = ED_view3d_cameracontrol_acquire(
-               fly->scene, fly->v3d, fly->rv3d,
+               C, fly->scene, fly->v3d, fly->rv3d,
                (U.uiflag & USER_CAM_LOCK_NO_PARENT) == 0);
 
        /* calculate center */