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_view3d/view3d_draw.c | |
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_view3d/view3d_draw.c')
-rw-r--r-- | source/blender/editors/space_view3d/view3d_draw.c | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 74554e8d62b..e9c2ddbab76 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -80,6 +80,8 @@ #include "GPU_immediate_util.h" #include "GPU_material.h" #include "GPU_viewport.h" +#include "GPU_state.h" +#include "GPU_framebuffer.h" #include "MEM_guardedalloc.h" @@ -450,7 +452,7 @@ static void drawviewborder(Scene *scene, Depsgraph *depsgraph, ARegion *ar, View x2 = viewborder.xmax; y2 = viewborder.ymax; - glLineWidth(1.0f); + GPU_line_width(1.0f); /* apply offsets so the real 3D camera shows through */ @@ -478,8 +480,8 @@ static void drawviewborder(Scene *scene, Depsgraph *depsgraph, ARegion *ar, View float alpha = 1.0f; if (ca->passepartalpha != 1.0f) { - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_BLEND); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend(true); alpha = ca->passepartalpha; } @@ -494,7 +496,7 @@ static void drawviewborder(Scene *scene, Depsgraph *depsgraph, ARegion *ar, View if (y2i > 0.0f) immRectf(shdr_pos, x1i, y1i, x2i, 0.0f); - glDisable(GL_BLEND); + GPU_blend(false); } immUniformThemeColor(TH_BACK); @@ -516,7 +518,7 @@ static void drawviewborder(Scene *scene, Depsgraph *depsgraph, ARegion *ar, View { float viewport_size[4]; - glGetFloatv(GL_VIEWPORT, viewport_size); + GPU_viewport_size_getf(viewport_size); immUniform2f("viewport_size", viewport_size[2], viewport_size[3]); immUniform1i("num_colors", 0); /* "simple" mode */ @@ -673,12 +675,12 @@ static void drawrenderborder(ARegion *ar, View3D *v3d) /* use the same program for everything */ uint shdr_pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - glLineWidth(1.0f); + GPU_line_width(1.0f); immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); float viewport_size[4]; - glGetFloatv(GL_VIEWPORT, viewport_size); + GPU_viewport_size_getf(viewport_size); immUniform2f("viewport_size", viewport_size[2], viewport_size[3]); immUniform1i("num_colors", 0); /* "simple" mode */ @@ -717,7 +719,7 @@ void ED_view3d_draw_depth( ED_view3d_draw_setup_view(NULL, depsgraph, scene, ar, v3d, NULL, NULL, NULL); - glClear(GL_DEPTH_BUFFER_BIT); + GPU_clear(GPU_DEPTH_BIT); if (rv3d->rflag & RV3D_CLIPPING) { ED_view3d_clipping_set(rv3d); @@ -726,7 +728,7 @@ void ED_view3d_draw_depth( rv3d->rflag |= RV3D_ZOFFSET_DISABLED; v3d->zbuf = true; - glEnable(GL_DEPTH_TEST); + GPU_depth_test(true); DRW_draw_depth_loop(depsgraph, ar, v3d); @@ -736,7 +738,7 @@ void ED_view3d_draw_depth( rv3d->rflag &= ~RV3D_ZOFFSET_DISABLED; v3d->zbuf = zbuf; - if (!v3d->zbuf) glDisable(GL_DEPTH_TEST); + if (!v3d->zbuf) GPU_depth_test(false); U.glalphaclip = glalphaclip; v3d->flag = flag; @@ -808,10 +810,10 @@ static void draw_view_axis(RegionView3D *rv3d, const rcti *rect) } /* draw axis lines */ - glLineWidth(2.0f); - glEnable(GL_LINE_SMOOTH); - glEnable(GL_BLEND); - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + GPU_line_width(2.0f); + GPU_line_smooth(true); + GPU_blend(true); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); Gwn_VertFormat *format = immVertexFormat(); unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); @@ -831,7 +833,7 @@ static void draw_view_axis(RegionView3D *rv3d, const rcti *rect) immEnd(); immUnbindProgram(); - glDisable(GL_LINE_SMOOTH); + GPU_line_smooth(false); /* draw axis names */ for (int axis_i = 0; axis_i < 3; axis_i++) { @@ -854,8 +856,8 @@ static void UNUSED_FUNCTION(draw_rotation_guide)(RegionView3D *rv3d) negate_v3_v3(o, rv3d->ofs); - glEnable(GL_BLEND); - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + GPU_blend(true); + GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); glDepthMask(GL_FALSE); /* don't overwrite zbuf */ Gwn_VertFormat *format = immVertexFormat(); @@ -938,7 +940,7 @@ static void UNUSED_FUNCTION(draw_rotation_guide)(RegionView3D *rv3d) /* -- draw rotation center -- */ immBindBuiltinProgram(GPU_SHADER_3D_POINT_FIXED_SIZE_VARYING_COLOR); - glPointSize(5.0f); + GPU_point_size(5.0f); immBegin(GWN_PRIM_POINTS, 1); immAttrib4ubv(col, color); immVertex3fv(pos, o); @@ -952,7 +954,7 @@ static void UNUSED_FUNCTION(draw_rotation_guide)(RegionView3D *rv3d) /* ^^ just playing around, does not work */ #endif - glDisable(GL_BLEND); + GPU_blend(false); glDepthMask(GL_TRUE); } #endif /* WITH_INPUT_NDOF */ @@ -1283,7 +1285,7 @@ void view3d_main_region_draw(const bContext *C, ARegion *ar) gpu_batch_presets_reset(); /* No depth test for drawing action zones afterwards. */ - glDisable(GL_DEPTH_TEST); + GPU_depth_test(false); v3d->flag |= V3D_INVALID_BACKBUF; } |