diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2020-07-16 05:16:10 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2020-07-16 19:01:44 +0300 |
commit | 5099cbeec9c481600e359e95a806a3393ba4ab0d (patch) | |
tree | aa20597f4760b5f1b77356e30e90ce6a5c914874 /source/blender/editors | |
parent | 436d38bb548d904200337d58720552b6f78555cb (diff) |
Cleanup: GPU: Move depth/color masks functions to GPU_state
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/gpencil/annotate_draw.c | 10 | ||||
-rw-r--r-- | source/blender/editors/gpencil/drawgpencil.c | 9 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_cursor.c | 8 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_draw.c | 4 |
4 files changed, 17 insertions, 14 deletions
diff --git a/source/blender/editors/gpencil/annotate_draw.c b/source/blender/editors/gpencil/annotate_draw.c index 20307e7f809..8c8e6da75c0 100644 --- a/source/blender/editors/gpencil/annotate_draw.c +++ b/source/blender/editors/gpencil/annotate_draw.c @@ -555,11 +555,8 @@ static void annotation_draw_strokes(const bGPDframe *gpf, /* check which stroke-drawer to use */ if (dflag & GP_DRAWDATA_ONLY3D) { const int no_xray = (dflag & GP_DRAWDATA_NO_XRAY); - int mask_orig = 0; if (no_xray) { - glGetIntegerv(GL_DEPTH_WRITEMASK, &mask_orig); - glDepthMask(0); GPU_depth_test(true); /* first arg is normally rv3d->dist, but this isn't @@ -578,7 +575,6 @@ static void annotation_draw_strokes(const bGPDframe *gpf, } if (no_xray) { - glDepthMask(mask_orig); GPU_depth_test(false); bglPolygonOffset(0.0, 0.0); @@ -743,12 +739,18 @@ static void annotation_draw_data( GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); GPU_blend(true); + /* Do not write to depth (avoid self-occlusion). */ + bool prev_depth_mask = GPU_depth_mask_get(); + GPU_depth_mask(false); + /* draw! */ annotation_draw_data_layers(gpd, offsx, offsy, winx, winy, cfra, dflag); /* turn off alpha blending, then smooth lines */ GPU_blend(false); // alpha blending GPU_line_smooth(false); // smooth lines + + GPU_depth_mask(prev_depth_mask); } /* if we have strokes for scenes (3d view)/clips (movie clip editor) diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c index 60fd52db707..4df071c84f8 100644 --- a/source/blender/editors/gpencil/drawgpencil.c +++ b/source/blender/editors/gpencil/drawgpencil.c @@ -306,6 +306,10 @@ static void gpencil_draw_strokes(tGPDdraw *tgpw) GPU_program_point_size(true); + /* Do not write to depth (avoid self-occlusion). */ + bool prev_depth_mask = GPU_depth_mask_get(); + GPU_depth_mask(false); + bGPDstroke *gps_init = (tgpw->gps) ? tgpw->gps : tgpw->t_gpf->strokes.first; for (bGPDstroke *gps = gps_init; gps; gps = gps->next) { @@ -343,11 +347,8 @@ static void gpencil_draw_strokes(tGPDdraw *tgpw) /* check which stroke-drawer to use */ if (tgpw->dflag & GP_DRAWDATA_ONLY3D) { const int no_xray = (tgpw->dflag & GP_DRAWDATA_NO_XRAY); - int mask_orig = 0; if (no_xray) { - glGetIntegerv(GL_DEPTH_WRITEMASK, &mask_orig); - glDepthMask(0); GPU_depth_test(true); /* first arg is normally rv3d->dist, but this isn't @@ -393,7 +394,6 @@ static void gpencil_draw_strokes(tGPDdraw *tgpw) } } if (no_xray) { - glDepthMask(mask_orig); GPU_depth_test(false); bglPolygonOffset(0.0, 0.0); @@ -405,6 +405,7 @@ static void gpencil_draw_strokes(tGPDdraw *tgpw) } } + GPU_depth_mask(prev_depth_mask); GPU_program_point_size(false); } diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c index be7b824fc3e..527d73ca725 100644 --- a/source/blender/editors/sculpt_paint/paint_cursor.c +++ b/source/blender/editors/sculpt_paint/paint_cursor.c @@ -638,8 +638,8 @@ static bool paint_draw_tex_overlay(UnifiedPaintSettings *ups, if (load_tex(brush, vc, zoom, col, primary)) { GPU_blend(true); - glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); - glDepthMask(GL_FALSE); + GPU_color_mask(true, true, true, true); + GPU_depth_mask(false); glDepthFunc(GL_ALWAYS); if (mtex->brush_map_mode == MTEX_MAP_MODE_VIEW) { @@ -758,8 +758,8 @@ static bool paint_draw_cursor_overlay( float center[2]; GPU_blend(true); - glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); - glDepthMask(GL_FALSE); + GPU_color_mask(true, true, true, true); + GPU_depth_mask(false); glDepthFunc(GL_ALWAYS); if (ups->draw_anchored) { diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index aa8fe1d63e5..82840f67699 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -1085,7 +1085,7 @@ static void draw_rotation_guide(const RegionView3D *rv3d) 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 */ + GPU_depth_mask(false); /* don't overwrite zbuf */ GPUVertFormat *format = immVertexFormat(); uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); @@ -1175,7 +1175,7 @@ static void draw_rotation_guide(const RegionView3D *rv3d) immUnbindProgram(); GPU_blend(false); - glDepthMask(GL_TRUE); + GPU_depth_mask(true); } #endif /* WITH_INPUT_NDOF */ |