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/manipulator_library/manipulator_types | |
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/manipulator_library/manipulator_types')
8 files changed, 73 insertions, 65 deletions
diff --git a/source/blender/editors/manipulator_library/manipulator_types/arrow2d_manipulator.c b/source/blender/editors/manipulator_library/manipulator_types/arrow2d_manipulator.c index 749e92e25fb..5acf1ab2d64 100644 --- a/source/blender/editors/manipulator_library/manipulator_types/arrow2d_manipulator.c +++ b/source/blender/editors/manipulator_library/manipulator_types/arrow2d_manipulator.c @@ -44,6 +44,7 @@ #include "GPU_draw.h" #include "GPU_immediate.h" #include "GPU_matrix.h" +#include "GPU_state.h" #include "MEM_guardedalloc.h" @@ -103,20 +104,20 @@ static void manipulator_arrow2d_draw(const bContext *UNUSED(C), wmManipulator *m manipulator_color_get(mpr, mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT, color); - glLineWidth(mpr->line_width); + GPU_line_width(mpr->line_width); WM_manipulator_calc_matrix_final(mpr, matrix_final); - glEnable(GL_BLEND); + GPU_blend(true); arrow2d_draw_geom(mpr, matrix_final, color); - glDisable(GL_BLEND); + GPU_blend(false); if (mpr->interaction_data) { ManipulatorInteraction *inter = mpr->interaction_data; - glEnable(GL_BLEND); + GPU_blend(true); arrow2d_draw_geom(mpr, inter->init_matrix_final, (const float[4]){0.5f, 0.5f, 0.5f, 0.5f}); - glDisable(GL_BLEND); + GPU_blend(false); } } diff --git a/source/blender/editors/manipulator_library/manipulator_types/arrow3d_manipulator.c b/source/blender/editors/manipulator_library/manipulator_types/arrow3d_manipulator.c index 8516b9d8244..a5bcef7ed5e 100644 --- a/source/blender/editors/manipulator_library/manipulator_types/arrow3d_manipulator.c +++ b/source/blender/editors/manipulator_library/manipulator_types/arrow3d_manipulator.c @@ -51,6 +51,7 @@ #include "GPU_immediate_util.h" #include "GPU_matrix.h" #include "GPU_select.h" +#include "GPU_state.h" #include "MEM_guardedalloc.h" @@ -118,7 +119,7 @@ static void arrow_draw_geom(const ArrowManipulator3D *arrow, const bool select, {-unitx, unity, 0}, }; - glLineWidth(arrow->manipulator.line_width); + GPU_line_width(arrow->manipulator.line_width); wm_manipulator_vec_draw(color, vec, ARRAY_SIZE(vec), pos, GWN_PRIM_LINE_LOOP); } else { @@ -133,7 +134,7 @@ static void arrow_draw_geom(const ArrowManipulator3D *arrow, const bool select, }; if (draw_options & ED_MANIPULATOR_ARROW_DRAW_FLAG_STEM) { - glLineWidth(arrow->manipulator.line_width); + GPU_line_width(arrow->manipulator.line_width); wm_manipulator_vec_draw(color, vec, ARRAY_SIZE(vec), pos, GWN_PRIM_LINE_STRIP); } else { @@ -197,9 +198,9 @@ static void arrow_draw_intern(ArrowManipulator3D *arrow, const bool select, cons gpuPushMatrix(); gpuMultMatrix(matrix_final); - glEnable(GL_BLEND); + GPU_blend(true); arrow_draw_geom(arrow, select, color); - glDisable(GL_BLEND); + GPU_blend(false); gpuPopMatrix(); @@ -210,9 +211,9 @@ static void arrow_draw_intern(ArrowManipulator3D *arrow, const bool select, cons gpuMultMatrix(inter->init_matrix_final); - glEnable(GL_BLEND); + GPU_blend(true); arrow_draw_geom(arrow, select, (const float[4]){0.5f, 0.5f, 0.5f, 0.5f}); - glDisable(GL_BLEND); + GPU_blend(false); gpuPopMatrix(); } diff --git a/source/blender/editors/manipulator_library/manipulator_types/button2d_manipulator.c b/source/blender/editors/manipulator_library/manipulator_types/button2d_manipulator.c index 86c3b4a09de..db33f457056 100644 --- a/source/blender/editors/manipulator_library/manipulator_types/button2d_manipulator.c +++ b/source/blender/editors/manipulator_library/manipulator_types/button2d_manipulator.c @@ -45,6 +45,7 @@ #include "GPU_matrix.h" #include "GPU_select.h" #include "GPU_batch.h" +#include "GPU_state.h" #include "RNA_access.h" #include "RNA_define.h" @@ -80,7 +81,7 @@ typedef struct ButtonManipulator2D { static void button2d_geom_draw_backdrop( const wmManipulator *mpr, const float color[4], const bool select) { - glLineWidth(mpr->line_width); + GPU_line_width(mpr->line_width); Gwn_VertFormat *format = immVertexFormat(); uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); @@ -138,7 +139,7 @@ static void button2d_draw_intern( uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); immUniformColor4fv(color); - glLineWidth(mpr->line_width); + GPU_line_width(mpr->line_width); immUniformColor4fv(color); immBegin(GWN_PRIM_LINE_STRIP, 2); immVertex3fv(pos, matrix_final[3]); @@ -168,11 +169,11 @@ static void button2d_draw_intern( } else { - glEnable(GL_BLEND); + GPU_blend(true); if (button->shape_batch[0] != NULL) { - glEnable(GL_LINE_SMOOTH); - glDisable(GL_POLYGON_SMOOTH); - glLineWidth(1.0f); + GPU_line_smooth(true); + GPU_polygon_smooth(false); + GPU_line_width(1.0f); for (uint i = 0; i < ARRAY_SIZE(button->shape_batch) && button->shape_batch[i]; i++) { /* Invert line color for wire. */ GWN_batch_program_set_builtin(button->shape_batch[i], GPU_SHADER_2D_UNIFORM_COLOR); @@ -185,8 +186,8 @@ static void button2d_draw_intern( color[2] = 1.0f - color[2]; } } - glDisable(GL_LINE_SMOOTH); - glEnable(GL_POLYGON_SMOOTH); + GPU_line_smooth(false); + GPU_polygon_smooth(true); } else if (button->icon != ICON_NONE) { button2d_geom_draw_backdrop(mpr, color, select); @@ -206,7 +207,7 @@ static void button2d_draw_intern( } UI_icon_draw(size[0], size[1], button->icon); } - glDisable(GL_BLEND); + GPU_blend(false); } if (need_to_pop) { @@ -224,9 +225,9 @@ static void manipulator_button2d_draw(const bContext *C, wmManipulator *mpr) { const bool is_highlight = (mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT) != 0; - glEnable(GL_BLEND); + GPU_blend(true); button2d_draw_intern(C, mpr, false, is_highlight); - glDisable(GL_BLEND); + GPU_blend(false); } static int manipulator_button2d_test_select( diff --git a/source/blender/editors/manipulator_library/manipulator_types/cage2d_manipulator.c b/source/blender/editors/manipulator_library/manipulator_types/cage2d_manipulator.c index fe748f33d35..b7b19ccd634 100644 --- a/source/blender/editors/manipulator_library/manipulator_types/cage2d_manipulator.c +++ b/source/blender/editors/manipulator_library/manipulator_types/cage2d_manipulator.c @@ -49,6 +49,7 @@ #include "GPU_immediate.h" #include "GPU_immediate_util.h" #include "GPU_select.h" +#include "GPU_state.h" #include "RNA_access.h" #include "RNA_define.h" @@ -420,7 +421,7 @@ static void cage2d_draw_box_interaction( } else { BLI_assert(ELEM(prim_type, GWN_PRIM_LINE_STRIP, GWN_PRIM_LINES)); - glLineWidth(line_width + 3.0f); + GPU_line_width(line_width + 3.0f); immBegin(prim_type, verts_len); immAttrib3f(attr_id.col, 0.0f, 0.0f, 0.0f); @@ -429,7 +430,7 @@ static void cage2d_draw_box_interaction( } immEnd(); - glLineWidth(line_width); + GPU_line_width(line_width); immBegin(prim_type, verts_len); immAttrib3fv(attr_id.col, color); @@ -558,14 +559,14 @@ static void manipulator_cage2d_draw_intern( /* Handy for quick testing draw (if it's outside bounds). */ if (false) { - glEnable(GL_BLEND); + GPU_blend(true); uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4fv((const float[4]){1, 1, 1, 0.5f}); float s = 0.5f; immRectf(pos, -s, -s, s, s); immUnbindProgram(); - glDisable(GL_BLEND); + GPU_blend(false); } if (select) { @@ -610,13 +611,13 @@ static void manipulator_cage2d_draw_intern( }; if (draw_style == ED_MANIPULATOR_CAGE2D_STYLE_BOX) { /* corner manipulators */ - glLineWidth(mpr->line_width + 3.0f); + GPU_line_width(mpr->line_width + 3.0f); cage2d_draw_box_corners(&r, margin, (const float[3]){0, 0, 0}); /* corner manipulators */ float color[4]; manipulator_color_get(mpr, highlight, color); - glLineWidth(mpr->line_width); + GPU_line_width(mpr->line_width); cage2d_draw_box_corners(&r, margin, color); bool show = false; @@ -645,12 +646,12 @@ static void manipulator_cage2d_draw_intern( float color[4]; manipulator_color_get(mpr, highlight, color); - glEnable(GL_LINE_SMOOTH); - glEnable(GL_BLEND); + GPU_line_smooth(true); + GPU_blend(true); - glLineWidth(mpr->line_width + 3.0f); + GPU_line_width(mpr->line_width + 3.0f); cage2d_draw_circle_wire(&r, margin, (const float[3]){0, 0, 0}, transform_flag, draw_options); - glLineWidth(mpr->line_width); + GPU_line_width(mpr->line_width); cage2d_draw_circle_wire(&r, margin, color, transform_flag, draw_options); @@ -658,15 +659,15 @@ static void manipulator_cage2d_draw_intern( cage2d_draw_circle_handles(&r, margin, color, transform_flag, true); cage2d_draw_circle_handles(&r, margin, (const float[3]){0, 0, 0}, transform_flag, false); - glDisable(GL_BLEND); - glDisable(GL_LINE_SMOOTH); + GPU_blend(false); + GPU_line_smooth(false); } else { BLI_assert(0); } } - glLineWidth(1.0); + GPU_line_width(1.0); gpuPopMatrix(); } diff --git a/source/blender/editors/manipulator_library/manipulator_types/cage3d_manipulator.c b/source/blender/editors/manipulator_library/manipulator_types/cage3d_manipulator.c index 6c2e2bd564d..a907816b08f 100644 --- a/source/blender/editors/manipulator_library/manipulator_types/cage3d_manipulator.c +++ b/source/blender/editors/manipulator_library/manipulator_types/cage3d_manipulator.c @@ -48,6 +48,7 @@ #include "GPU_immediate.h" #include "GPU_immediate_util.h" #include "GPU_select.h" +#include "GPU_state.h" #include "RNA_access.h" #include "RNA_define.h" @@ -303,14 +304,14 @@ static void manipulator_cage3d_draw_intern( /* Handy for quick testing draw (if it's outside bounds). */ if (false) { - glEnable(GL_BLEND); + GPU_blend(true); uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); immUniformColor4fv((const float[4]){1, 1, 1, 0.5f}); float s = 0.5f; immRectf(pos, -s, -s, s, s); immUnbindProgram(); - glDisable(GL_BLEND); + GPU_blend(false); } if (select) { @@ -358,13 +359,13 @@ static void manipulator_cage3d_draw_intern( #endif if (draw_style == ED_MANIPULATOR_CAGE2D_STYLE_BOX) { /* corner manipulators */ - glLineWidth(mpr->line_width + 3.0f); + GPU_line_width(mpr->line_width + 3.0f); cage3d_draw_box_corners(size_real, margin, (const float[3]){0, 0, 0}); /* corner manipulators */ float color[4]; manipulator_color_get(mpr, highlight, color); - glLineWidth(mpr->line_width); + GPU_line_width(mpr->line_width); cage3d_draw_box_corners(size_real, margin, color); bool show = false; @@ -388,29 +389,29 @@ static void manipulator_cage3d_draw_intern( float color[4]; manipulator_color_get(mpr, highlight, color); - glEnable(GL_LINE_SMOOTH); - glEnable(GL_POLYGON_SMOOTH); - glEnable(GL_BLEND); + GPU_line_smooth(true); + GPU_polygon_smooth(true); + GPU_blend(true); - glLineWidth(mpr->line_width + 3.0f); + GPU_line_width(mpr->line_width + 3.0f); cage3d_draw_circle_wire(size_real, margin, (const float[3]){0, 0, 0}, transform_flag, draw_options); - glLineWidth(mpr->line_width); + GPU_line_width(mpr->line_width); cage3d_draw_circle_wire(size_real, margin, color, transform_flag, draw_options); /* corner manipulators */ cage3d_draw_circle_handles(rv3d, matrix_final, size_real, margin, (const float[3]){0, 0, 0}, true, 60); cage3d_draw_circle_handles(rv3d, matrix_final, size_real, margin, color, true, 40); - glDisable(GL_BLEND); - glDisable(GL_POLYGON_SMOOTH); - glDisable(GL_LINE_SMOOTH); + GPU_blend(false); + GPU_polygon_smooth(false); + GPU_line_smooth(false); } else { BLI_assert(0); } } - glLineWidth(1.0); + GPU_line_width(1.0); gpuPopMatrix(); } diff --git a/source/blender/editors/manipulator_library/manipulator_types/dial3d_manipulator.c b/source/blender/editors/manipulator_library/manipulator_types/dial3d_manipulator.c index 643a379cbb0..74ba8bd77a9 100644 --- a/source/blender/editors/manipulator_library/manipulator_types/dial3d_manipulator.c +++ b/source/blender/editors/manipulator_library/manipulator_types/dial3d_manipulator.c @@ -51,6 +51,7 @@ #include "GPU_immediate_util.h" #include "GPU_matrix.h" #include "GPU_select.h" +#include "GPU_state.h" #include "RNA_access.h" #include "RNA_define.h" @@ -123,7 +124,7 @@ static void dial_geom_draw( const int draw_options = RNA_enum_get(mpr->ptr, "draw_options"); const bool filled = (draw_options & ED_MANIPULATOR_DIAL_DRAW_FLAG_FILL) != 0; - glLineWidth(mpr->line_width); + GPU_line_width(mpr->line_width); Gwn_VertFormat *format = immVertexFormat(); uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); @@ -158,7 +159,7 @@ static void dial_geom_draw( */ static void dial_ghostarc_draw_helpline(const float angle, const float co_outer[3], const float color[4]) { - glLineWidth(1.0f); + GPU_line_width(1.0f); gpuPushMatrix(); gpuRotate3f(RAD2DEGF(angle), 0.0f, 0.0f, -1.0f); @@ -313,9 +314,9 @@ static void dial_draw_intern( /* draw! */ for (int i = 0; i < 2; i++) { - glDisable(GL_POLYGON_SMOOTH); + GPU_polygon_smooth(false); dial_ghostarc_draw(mpr, angle_ofs, angle_delta, (const float[4]){0.8f, 0.8f, 0.8f, 0.4f}); - glEnable(GL_POLYGON_SMOOTH); + GPU_polygon_smooth(true); dial_ghostarc_draw_helpline(angle_ofs, co_outer, color); /* starting position */ dial_ghostarc_draw_helpline(angle_ofs + angle_delta, co_outer, color); /* starting position + current value */ @@ -382,9 +383,9 @@ static void manipulator_dial_draw(const bContext *C, wmManipulator *mpr) glEnable(GL_CLIP_DISTANCE0); } - glEnable(GL_BLEND); + GPU_blend(true); dial_draw_intern(C, mpr, false, is_highlight, clip_plane); - glDisable(GL_BLEND); + GPU_blend(false); if (clip_plane) { glDisable(GL_CLIP_DISTANCE0); diff --git a/source/blender/editors/manipulator_library/manipulator_types/grab3d_manipulator.c b/source/blender/editors/manipulator_library/manipulator_types/grab3d_manipulator.c index e2d1979b7a6..458dc2fd1c8 100644 --- a/source/blender/editors/manipulator_library/manipulator_types/grab3d_manipulator.c +++ b/source/blender/editors/manipulator_library/manipulator_types/grab3d_manipulator.c @@ -46,6 +46,7 @@ #include "GPU_immediate_util.h" #include "GPU_matrix.h" #include "GPU_select.h" +#include "GPU_state.h" #include "RNA_access.h" #include "RNA_define.h" @@ -102,7 +103,7 @@ static void grab_geom_draw( const int draw_style = RNA_enum_get(mpr->ptr, "draw_style"); const bool filled = (draw_options & ED_MANIPULATOR_GRAB_DRAW_FLAG_FILL) != 0; - glLineWidth(mpr->line_width); + GPU_line_width(mpr->line_width); Gwn_VertFormat *format = immVertexFormat(); uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); @@ -188,9 +189,9 @@ static void grab3d_draw_intern( gpuMultMatrix(matrix_align); } - glEnable(GL_BLEND); + GPU_blend(true); grab_geom_draw(mpr, color, select, draw_options); - glDisable(GL_BLEND); + GPU_blend(false); gpuPopMatrix(); if (mpr->interaction_data) { @@ -201,9 +202,9 @@ static void grab3d_draw_intern( gpuMultMatrix(matrix_align); } - glEnable(GL_BLEND); + GPU_blend(true); grab_geom_draw(mpr, (const float[4]){0.5f, 0.5f, 0.5f, 0.5f}, select, draw_options); - glDisable(GL_BLEND); + GPU_blend(false); gpuPopMatrix(); } } @@ -221,9 +222,9 @@ static void manipulator_grab_draw(const bContext *C, wmManipulator *mpr) (void)is_modal; - glEnable(GL_BLEND); + GPU_blend(true); grab3d_draw_intern(C, mpr, false, is_highlight); - glDisable(GL_BLEND); + GPU_blend(false); } static int manipulator_grab_modal( diff --git a/source/blender/editors/manipulator_library/manipulator_types/primitive3d_manipulator.c b/source/blender/editors/manipulator_library/manipulator_types/primitive3d_manipulator.c index 531cf742e6f..419873ccfff 100644 --- a/source/blender/editors/manipulator_library/manipulator_types/primitive3d_manipulator.c +++ b/source/blender/editors/manipulator_library/manipulator_types/primitive3d_manipulator.c @@ -42,6 +42,7 @@ #include "GPU_immediate.h" #include "GPU_matrix.h" #include "GPU_select.h" +#include "GPU_state.h" #include "RNA_access.h" #include "RNA_define.h" @@ -101,9 +102,9 @@ static void manipulator_primitive_draw_intern( gpuPushMatrix(); gpuMultMatrix(matrix_final); - glEnable(GL_BLEND); + GPU_blend(true); manipulator_primitive_draw_geom(color_inner, color_outer, draw_style); - glDisable(GL_BLEND); + GPU_blend(false); gpuPopMatrix(); @@ -117,9 +118,9 @@ static void manipulator_primitive_draw_intern( gpuPushMatrix(); gpuMultMatrix(inter->init_matrix_final); - glEnable(GL_BLEND); + GPU_blend(true); manipulator_primitive_draw_geom(color_inner, color_outer, draw_style); - glDisable(GL_BLEND); + GPU_blend(false); gpuPopMatrix(); } |