diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2020-07-16 21:24:05 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2020-07-18 04:43:51 +0300 |
commit | 02c09773ea07c8c0a3d7be63abdfd963a9452402 (patch) | |
tree | 5cd052db8fc0dd71072f90dd22175e314a134f5c /source/blender/editors | |
parent | acad0d75b1448550c863ac8002bba4284d30d10d (diff) |
Cleanup: GPU: rename bglPolygonOffset to GPU_polygon_offset
And move it to GPU module.
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/gpencil/annotate_draw.c | 7 | ||||
-rw-r--r-- | source/blender/editors/gpencil/drawgpencil.c | 7 | ||||
-rw-r--r-- | source/blender/editors/include/BIF_glutil.h | 7 | ||||
-rw-r--r-- | source/blender/editors/screen/glutil.c | 62 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_utils.c | 4 |
5 files changed, 8 insertions, 79 deletions
diff --git a/source/blender/editors/gpencil/annotate_draw.c b/source/blender/editors/gpencil/annotate_draw.c index 8c8e6da75c0..df479325027 100644 --- a/source/blender/editors/gpencil/annotate_draw.c +++ b/source/blender/editors/gpencil/annotate_draw.c @@ -53,9 +53,8 @@ #include "WM_api.h" -#include "BIF_glutil.h" - #include "GPU_immediate.h" +#include "GPU_matrix.h" #include "GPU_state.h" #include "ED_gpencil.h" @@ -561,7 +560,7 @@ static void annotation_draw_strokes(const bGPDframe *gpf, /* first arg is normally rv3d->dist, but this isn't * available here and seems to work quite well without */ - bglPolygonOffset(1.0f, 1.0f); + GPU_polygon_offset(1.0f, 1.0f); } /* 3D Lines - OpenGL primitives-based */ @@ -577,7 +576,7 @@ static void annotation_draw_strokes(const bGPDframe *gpf, if (no_xray) { GPU_depth_test(false); - bglPolygonOffset(0.0, 0.0); + GPU_polygon_offset(0.0f, 0.0f); } } else { diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c index 4df071c84f8..9d11c1c2a25 100644 --- a/source/blender/editors/gpencil/drawgpencil.c +++ b/source/blender/editors/gpencil/drawgpencil.c @@ -60,9 +60,8 @@ #include "WM_api.h" -#include "BIF_glutil.h" - #include "GPU_immediate.h" +#include "GPU_matrix.h" #include "GPU_state.h" #include "ED_gpencil.h" @@ -353,7 +352,7 @@ static void gpencil_draw_strokes(tGPDdraw *tgpw) /* first arg is normally rv3d->dist, but this isn't * available here and seems to work quite well without */ - bglPolygonOffset(1.0f, 1.0f); + GPU_polygon_offset(1.0f, 1.0f); } /* 3D Stroke */ @@ -396,7 +395,7 @@ static void gpencil_draw_strokes(tGPDdraw *tgpw) if (no_xray) { GPU_depth_test(false); - bglPolygonOffset(0.0, 0.0); + GPU_polygon_offset(0.0f, 0.0f); } } /* if only one stroke, exit from loop */ diff --git a/source/blender/editors/include/BIF_glutil.h b/source/blender/editors/include/BIF_glutil.h index 04f9edeaf3a..1eb22fb34e2 100644 --- a/source/blender/editors/include/BIF_glutil.h +++ b/source/blender/editors/include/BIF_glutil.h @@ -172,13 +172,6 @@ void ED_draw_imbuf_ctx_clipping(const struct bContext *C, int ED_draw_imbuf_method(struct ImBuf *ibuf); -/* OpenGL drawing utility functions. Do not use these in new code, these - * are intended to be moved or removed in the future. */ - -/* own working polygon offset */ -float bglPolygonOffsetCalc(const float winmat[16], float viewdist, float dist); -void bglPolygonOffset(float viewdist, float dist); - void immDrawBorderCorners(unsigned int pos, const struct rcti *border, float zoomx, float zoomy); #ifdef __cplusplus diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c index 27e5a53a526..79ec8dde009 100644 --- a/source/blender/editors/screen/glutil.c +++ b/source/blender/editors/screen/glutil.c @@ -473,68 +473,6 @@ void immDrawPixelsTex_clipping(IMMDrawPixelsTexState *state, color); } -/* *************** glPolygonOffset hack ************* */ - -float bglPolygonOffsetCalc(const float winmat[16], float viewdist, float dist) -{ - /* Seems like we have a factor of 2 more offset than 2.79 for some reason. Correct for this. */ - dist *= 0.5f; - - if (winmat[15] > 0.5f) { -#if 1 - return 0.00001f * dist * viewdist; // ortho tweaking -#else - static float depth_fac = 0.0f; - if (depth_fac == 0.0f) { - int depthbits; - glGetIntegerv(GL_DEPTH_BITS, &depthbits); - depth_fac = 1.0f / (float)((1 << depthbits) - 1); - } - offs = (-1.0 / winmat[10]) * dist * depth_fac; - - UNUSED_VARS(viewdist); -#endif - } - - /* This adjustment effectively results in reducing the Z value by 0.25%. - * - * winmat[14] actually evaluates to `-2 * far * near / (far - near)`, - * is very close to -0.2 with default clip range, - * and is used as the coefficient multiplied by `w / z`, - * thus controlling the z dependent part of the depth value. - */ - return winmat[14] * -0.0025f * dist; -} - -/** - * \note \a viewdist is only for ortho at the moment. - */ -void bglPolygonOffset(float viewdist, float dist) -{ - static float winmat[16], offset = 0.0f; - - if (dist != 0.0f) { - // glEnable(GL_POLYGON_OFFSET_FILL); - // glPolygonOffset(-1.0, -1.0); - - /* hack below is to mimic polygon offset */ - GPU_matrix_projection_get(winmat); - - /* dist is from camera to center point */ - - float offs = bglPolygonOffsetCalc(winmat, viewdist, dist); - - winmat[14] -= offs; - offset += offs; - } - else { - winmat[14] += offset; - offset = 0.0; - } - - GPU_matrix_projection_set(winmat); -} - /* **** Color management helper functions for GLSL display/transform ***** */ /* Draw given image buffer on a screen using GLSL for display transform */ diff --git a/source/blender/editors/space_view3d/view3d_utils.c b/source/blender/editors/space_view3d/view3d_utils.c index 0d121b23c71..bd2323f47f4 100644 --- a/source/blender/editors/space_view3d/view3d_utils.c +++ b/source/blender/editors/space_view3d/view3d_utils.c @@ -220,7 +220,7 @@ void view3d_region_operator_needs_opengl(wmWindow *UNUSED(win), ARegion *region) } /** - * Use instead of: ``bglPolygonOffset(rv3d->dist, ...)`` see bug [#37727] + * Use instead of: ``GPU_polygon_offset(rv3d->dist, ...)`` see bug [#37727] */ void ED_view3d_polygon_offset(const RegionView3D *rv3d, const float dist) { @@ -241,7 +241,7 @@ void ED_view3d_polygon_offset(const RegionView3D *rv3d, const float dist) } } - bglPolygonOffset(viewdist, dist); + GPU_polygon_offset(viewdist, dist); } bool ED_view3d_context_activate(bContext *C) |