diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-01-28 08:40:23 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-01-28 08:40:23 +0300 |
commit | 1c905046d1da3a37993376f34f9a438244f4a1f3 (patch) | |
tree | f65dff79bcffe2ab6a470a9fb667f1c8b35e58d5 /source/blender/editors/space_view3d/view3d_utils.c | |
parent | 87215bbae4cd581229ad1890ed599cebda421b38 (diff) | |
parent | d386d4e7c4fd256b41dacfd011e9d3082b7654d5 (diff) |
Merge branch 'master' into blender2.8
Diffstat (limited to 'source/blender/editors/space_view3d/view3d_utils.c')
-rw-r--r-- | source/blender/editors/space_view3d/view3d_utils.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/source/blender/editors/space_view3d/view3d_utils.c b/source/blender/editors/space_view3d/view3d_utils.c index cb9c7f02db9..7bb3f443ac6 100644 --- a/source/blender/editors/space_view3d/view3d_utils.c +++ b/source/blender/editors/space_view3d/view3d_utils.c @@ -55,6 +55,8 @@ #include "BIF_gl.h" #include "BIF_glutil.h" +#include "GPU_matrix.h" + #include "WM_api.h" #include "WM_types.h" @@ -148,6 +150,33 @@ bool ED_view3d_viewplane_get( * \{ */ /** + * Use this call when executing an operator, + * event system doesn't set for each event the OpenGL drawing context. + */ +void view3d_operator_needs_opengl(const bContext *C) +{ + wmWindow *win = CTX_wm_window(C); + ARegion *ar = CTX_wm_region(C); + + view3d_region_operator_needs_opengl(win, ar); +} + +void view3d_region_operator_needs_opengl(wmWindow *win, ARegion *ar) +{ + /* for debugging purpose, context should always be OK */ + if ((ar == NULL) || (ar->regiontype != RGN_TYPE_WINDOW)) { + printf("view3d_region_operator_needs_opengl error, wrong region\n"); + } + else { + RegionView3D *rv3d = ar->regiondata; + + wmSubWindowSet(win, ar->swinid); + gpuLoadProjectionMatrix(rv3d->winmat); + gpuLoadMatrix(rv3d->viewmat); + } +} + +/** * Use instead of: ``bglPolygonOffset(rv3d->dist, ...)`` see bug [#37727] */ void ED_view3d_polygon_offset(const RegionView3D *rv3d, const float dist) |