Merge branch 'master' into blender2.8
[blender.git] / source / blender / editors / space_info / textview.c
index 334106f..85de70c 100644 (file)
@@ -39,6 +39,8 @@
 #include "BLI_utildefines.h"
 #include "BLI_string_utf8.h"
 
+#include "GPU_immediate.h"
+
 #include "BIF_gl.h"
 
 #include "BKE_text.h"
@@ -80,10 +82,16 @@ static void console_draw_sel(const char *str, const int sel[2], const int xy[2],
                const int end = txt_utf8_offset_to_column(str, min_ii(sel[1], str_len_draw));
 
                glEnable(GL_BLEND);
-               glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-               glColor4ubv(bg_sel);
+               glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+
+               Gwn_VertFormat *format = immVertexFormat();
+               unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
+               immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
+
+               immUniformColor4ubv(bg_sel);
+               immRecti(pos, xy[0] + (cwidth * sta), xy[1] - 2 + lheight, xy[0] + (cwidth * end), xy[1] - 2);
 
-               glRecti(xy[0] + (cwidth * sta), xy[1] - 2 + lheight, xy[0] + (cwidth * end), xy[1] - 2);
+               immUnbindProgram();
 
                glDisable(GL_BLEND);
        }
@@ -182,21 +190,25 @@ static int console_draw_string(ConsoleDrawContext *cdc, const char *str, int str
                cdc->sel[1] = str_len - sel_orig[0];
 
                if (bg) {
-                       glColor3ubv(bg);
-                       glRecti(0, cdc->xy[1], cdc->winx, (cdc->xy[1] + (cdc->lheight * tot_lines)));
-               }
+                       Gwn_VertFormat *format = immVertexFormat();
+                       unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
+                       immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
 
-               glColor3ubv(fg);
+                       immUniformColor3ubv(bg);
+                       immRecti(pos, 0, cdc->xy[1], cdc->winx, (cdc->xy[1] + (cdc->lheight * tot_lines)));
+
+                       immUnbindProgram();
+               }
 
                /* last part needs no clipping */
                BLF_position(cdc->font_id, cdc->xy[0], cdc->lofs + cdc->xy[1], 0);
+               BLF_color3ubv(cdc->font_id, fg);
                BLF_draw_mono(cdc->font_id, s, len, cdc->cwidth);
 
                if (cdc->sel[0] != cdc->sel[1]) {
                        console_step_sel(cdc, -initial_offset);
-                       // glColor4ub(255, 0, 0, 96); // debug
+                       /* BLF_color3ub(cdc->font_id, 255, 0, 0); // debug */
                        console_draw_sel(s, cdc->sel, cdc->xy, len, cdc->cwidth, cdc->lheight, bg_sel);
-                       glColor3ubv(fg);
                }
 
                cdc->xy[1] += cdc->lheight;
@@ -210,9 +222,8 @@ static int console_draw_string(ConsoleDrawContext *cdc, const char *str, int str
 
                        if (cdc->sel[0] != cdc->sel[1]) {
                                console_step_sel(cdc, len);
-                               // glColor4ub(0, 255, 0, 96); // debug
+                               /* BLF_color3ub(cdc->font_id, 0, 255, 0); // debug */
                                console_draw_sel(s, cdc->sel, cdc->xy, len, cdc->cwidth, cdc->lheight, bg_sel);
-                               glColor3ubv(fg);
                        }
 
                        cdc->xy[1] += cdc->lheight;
@@ -230,12 +241,17 @@ static int console_draw_string(ConsoleDrawContext *cdc, const char *str, int str
        else { /* simple, no wrap */
 
                if (bg) {
-                       glColor3ubv(bg);
-                       glRecti(0, cdc->xy[1], cdc->winx, cdc->xy[1] + cdc->lheight);
-               }
+                       Gwn_VertFormat *format = immVertexFormat();
+                       unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT);
+                       immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
 
-               glColor3ubv(fg);
+                       immUniformColor3ubv(bg);
+                       immRecti(pos, 0, cdc->xy[1], cdc->winx, cdc->xy[1] + cdc->lheight);
+
+                       immUnbindProgram();
+               }
 
+               BLF_color3ubv(cdc->font_id, fg);
                BLF_position(cdc->font_id, cdc->xy[0], cdc->lofs + cdc->xy[1], 0);
                BLF_draw_mono(cdc->font_id, str, str_len, cdc->cwidth);
 
@@ -245,7 +261,7 @@ static int console_draw_string(ConsoleDrawContext *cdc, const char *str, int str
                        isel[0] = str_len - cdc->sel[1];
                        isel[1] = str_len - cdc->sel[0];
 
-                       // glColor4ub(255, 255, 0, 96); // debug
+                       /* BLF_color3ub(cdc->font_id, 255, 255, 0); // debug */
                        console_draw_sel(str, isel, cdc->xy, str_len, cdc->cwidth, cdc->lheight, bg_sel);
                        console_step_sel(cdc, -(str_len + 1));
                }