diff options
author | Ray Molenkamp <github@lazydodo.com> | 2018-06-28 04:07:23 +0300 |
---|---|---|
committer | Ray Molenkamp <github@lazydodo.com> | 2018-06-28 04:07:23 +0300 |
commit | 8e02106d0ddc7b31844d26037a824d56d3c65663 (patch) | |
tree | bfa1898220d74ac9610b8a1363a4087a44f7b41d /source/blender/editors/space_outliner | |
parent | fe258fd4451a7fb1ccdd85d1607b6dbd30442f28 (diff) |
GLRefactor: partially remove gl calls from source/blender/editors.
This translates the gl calls to the new GPU_ wrappers from D3501.
Given it's tedious and repetitive work, this patch does as much as it can with search + replace, the remainder of the gl calls will need to be manually dealt with on a case by case basis.
This fixes 13 of the 28 failing editors when building without opengl.
For the list of substitutions see D3502
Reviewers: brecht
Differential Revision: https://developer.blender.org/D3502
Diffstat (limited to 'source/blender/editors/space_outliner')
-rw-r--r-- | source/blender/editors/space_outliner/outliner_draw.c | 47 | ||||
-rw-r--r-- | source/blender/editors/space_outliner/outliner_ops.c | 5 | ||||
-rw-r--r-- | source/blender/editors/space_outliner/space_outliner.c | 3 |
3 files changed, 29 insertions, 26 deletions
diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c index e617bb40837..19e5217cdd2 100644 --- a/source/blender/editors/space_outliner/outliner_draw.c +++ b/source/blender/editors/space_outliner/outliner_draw.c @@ -72,6 +72,7 @@ #include "WM_types.h" #include "GPU_immediate.h" +#include "GPU_state.h" #include "UI_interface.h" #include "UI_interface_icons.h" @@ -739,7 +740,7 @@ static void outliner_draw_rnacols(ARegion *ar, int sizex) float miny = v2d->cur.ymin; if (miny < v2d->tot.ymin) miny = v2d->tot.ymin; - glLineWidth(1.0f); + GPU_line_width(1.0f); unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -855,9 +856,9 @@ static void tselem_draw_icon_uibut(struct DrawIconArg *arg, int icon) { /* restrict column clip... it has been coded by simply overdrawing, doesnt work for buttons */ if (arg->x >= arg->xmax) { - glEnable(GL_BLEND); + GPU_blend(true); UI_icon_draw_alpha(arg->x, arg->y, icon, arg->alpha); - glDisable(GL_BLEND); + GPU_blend(false); } else { uiBut *but = uiDefIconBut( @@ -1383,7 +1384,7 @@ static void outliner_draw_iconrow_number( (float)ys - UI_UNIT_Y * 0.095f + ufac, number_text, text_col); UI_fontstyle_set(fstyle); - glEnable(GL_BLEND); /* Roundbox and text drawing disables. */ + GPU_blend(true); /* Roundbox and text drawing disables. */ } static void outliner_draw_iconrow_doit( @@ -1409,7 +1410,7 @@ static void outliner_draw_iconrow_doit( (float)ys + UI_UNIT_Y - ufac, (float)UI_UNIT_Y / 2.0f - ufac, color); - glEnable(GL_BLEND); /* Roundbox disables. */ + GPU_blend(true); /* Roundbox disables. */ } /* No inlined icon should be clickable. */ @@ -1579,7 +1580,7 @@ static void outliner_draw_tree_element( if ((soops->flag & SO_HIDE_RESTRICTCOLS) == 0) xmax -= OL_TOGW + UI_UNIT_X; - glEnable(GL_BLEND); + GPU_blend(true); /* colors for active/selected data */ if (tselem->type == 0) { @@ -1642,7 +1643,7 @@ static void outliner_draw_tree_element( (float)startx + 2.0f * UI_UNIT_X - 1.0f * ufac, (float)*starty + UI_UNIT_Y - 1.0f * ufac, UI_UNIT_Y / 2.0f - 1.0f * ufac, color); - glEnable(GL_BLEND); /* roundbox disables it */ + GPU_blend(true); /* roundbox disables it */ te->flag |= TE_ACTIVE; // for lookup in display hierarchies } @@ -1701,7 +1702,7 @@ static void outliner_draw_tree_element( alpha_fac); offsx += UI_UNIT_X + 2 * ufac; } - glDisable(GL_BLEND); + GPU_blend(false); /* name */ if ((tselem->flag & TSE_TEXTBUT) == 0) { @@ -1734,7 +1735,7 @@ static void outliner_draw_tree_element( else if (tselem->type != TSE_R_LAYER) { int tempx = startx + offsx; - glEnable(GL_BLEND); + GPU_blend(true); /* divider */ { @@ -1758,7 +1759,7 @@ static void outliner_draw_tree_element( C, block, fstyle, scene, view_layer, soops, &te->subtree, 0, xmax, &tempx, *starty, alpha_fac); - glDisable(GL_BLEND); + GPU_blend(false); } } } @@ -1808,14 +1809,14 @@ static void outliner_draw_tree_element_floating( UI_GetThemeColorShade4fv(TH_BACK, -40, col); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); - glEnable(GL_BLEND); + GPU_blend(true); if (ELEM(te_floating->drag_data->insert_type, TE_INSERT_BEFORE, TE_INSERT_AFTER)) { if (te_floating->drag_data->insert_type == TE_INSERT_BEFORE) { coord_y += UI_UNIT_Y; } immUniformColor4fv(col); - glLineWidth(line_width); + GPU_line_width(line_width); immBegin(GWN_PRIM_LINE_STRIP, 2); immVertex2f(pos, coord_x, coord_y); @@ -1834,7 +1835,7 @@ static void outliner_draw_tree_element_floating( immEnd(); } - glDisable(GL_BLEND); + GPU_blend(false); immUnbindProgram(); } @@ -1908,9 +1909,9 @@ static void outliner_draw_hierarchy_lines(SpaceOops *soops, ListBase *lb, int st UI_GetThemeColorBlend3ubv(TH_BACK, TH_TEXT, 0.4f, col); col[3] = 255; - glEnable(GL_BLEND); + GPU_blend(true); outliner_draw_hierarchy_lines_recursive(pos, soops, lb, startx, col, false, starty); - glDisable(GL_BLEND); + GPU_blend(false); immUnbindProgram(); } @@ -2005,7 +2006,7 @@ static void outliner_draw_highlights(ARegion *ar, SpaceOops *soops, int startx, UI_GetThemeColor4fv(TH_MATCH, col_searchmatch); col_searchmatch[3] = 0.5f; - glEnable(GL_BLEND); + GPU_blend(true); 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); @@ -2013,7 +2014,7 @@ static void outliner_draw_highlights(ARegion *ar, SpaceOops *soops, int startx, pos, ar, soops, &soops->tree, col_selection, col_highlight, col_searchmatch, startx, starty); immUnbindProgram(); - glDisable(GL_BLEND); + GPU_blend(false); } static void outliner_draw_tree( @@ -2025,7 +2026,7 @@ static void outliner_draw_tree( TreeElement *te_floating = NULL; int starty, startx; - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); // only once + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); // only once if (soops->outlinevis == SO_DATA_API) { /* struct marks */ @@ -2039,13 +2040,13 @@ static void outliner_draw_tree( outliner_draw_highlights(ar, soops, startx, &starty); /* set scissor so tree elements or lines can't overlap restriction icons */ - GLfloat scissor[4] = {0}; + float scissor[4] = {0}; if (has_restrict_icons) { int mask_x = BLI_rcti_size_x(&ar->v2d.mask) - (int)OL_TOGW + 1; CLAMP_MIN(mask_x, 0); - glGetFloatv(GL_SCISSOR_BOX, scissor); - glScissor(0, 0, mask_x, ar->winy); + GPU_scissor_getf(scissor); + GPU_scissor(0, 0, mask_x, ar->winy); } // gray hierarchy lines @@ -2069,7 +2070,7 @@ static void outliner_draw_tree( if (has_restrict_icons) { /* reset scissor */ - glScissor(UNPACK4(scissor)); + GPU_scissor(UNPACK4(scissor)); } } @@ -2111,7 +2112,7 @@ static void outliner_back(ARegion *ar) static void outliner_draw_restrictcols(ARegion *ar) { - glLineWidth(1.0f); + GPU_line_width(1.0f); unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); diff --git a/source/blender/editors/space_outliner/outliner_ops.c b/source/blender/editors/space_outliner/outliner_ops.c index 316caf0e239..786172ca18e 100644 --- a/source/blender/editors/space_outliner/outliner_ops.c +++ b/source/blender/editors/space_outliner/outliner_ops.c @@ -41,6 +41,7 @@ #include "BKE_main.h" #include "GPU_immediate.h" +#include "GPU_state.h" #include "RNA_access.h" @@ -346,9 +347,9 @@ static void outliner_drag_drop_tooltip_cb(const wmWindow *win, void *vdata) const float col_fg[4] = {1.0f, 1.0f, 1.0f, 1.0f}; const float col_bg[4] = {0.0f, 0.0f, 0.0f, 0.2f}; - glEnable(GL_BLEND); + GPU_blend(true); UI_fontstyle_draw_simple_backdrop(fstyle, x, y, tooltip, col_fg, col_bg); - glDisable(GL_BLEND); + GPU_blend(false); } static int outliner_item_drag_drop_invoke(bContext *C, wmOperator *op, const wmEvent *event) diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c index 71ae7eeeb3d..f1431647754 100644 --- a/source/blender/editors/space_outliner/space_outliner.c +++ b/source/blender/editors/space_outliner/space_outliner.c @@ -63,6 +63,7 @@ #include "outliner_intern.h" +#include "GPU_framebuffer.h" static void outliner_main_region_init(wmWindowManager *wm, ARegion *ar) { @@ -289,7 +290,7 @@ static void outliner_main_region_draw(const bContext *C, ARegion *ar) /* clear */ UI_ThemeClearColor(TH_BACK); - glClear(GL_COLOR_BUFFER_BIT); + GPU_clear(GPU_COLOR_BIT); draw_outliner(C); |