Clay Engine: support draw callbacks

This commit is contained in:
Clément Foucault
2017-03-05 18:09:43 +01:00
parent ff96f527fd
commit b36f93fa37
3 changed files with 39 additions and 0 deletions

View File

@@ -715,6 +715,8 @@ static void CLAY_view_draw(RenderEngine *UNUSED(engine), const bContext *context
/* Start Drawing */
DRW_draw_background();
DRW_draw_callbacks_pre_scene();
/* Pass 1 : Depth pre-pass */
DRW_draw_pass(psl->depth_pass);
DRW_draw_pass(psl->depth_pass_cull);
@@ -730,6 +732,8 @@ static void CLAY_view_draw(RenderEngine *UNUSED(engine), const bContext *context
/* At this point all shaded geometry should have been rendered and their depth written */
DRW_draw_mode_overlays();
DRW_draw_callbacks_post_scene();
/* Always finish by this */
DRW_state_reset();
}

View File

@@ -221,6 +221,9 @@ void DRW_mode_cache_finish(void);
void DRW_draw_pass(DRWPass *pass);
void DRW_draw_mode_overlays(void);
void DRW_draw_callbacks_pre_scene(void);
void DRW_draw_callbacks_post_scene(void);
void DRW_state_reset(void);
/* Other */

View File

@@ -40,6 +40,8 @@
#include "DNA_view3d_types.h"
#include "ED_space_api.h"
#include "GPU_batch.h"
#include "GPU_draw.h"
#include "GPU_extensions.h"
@@ -1025,6 +1027,36 @@ void DRW_draw_pass(DRWPass *pass)
}
}
void DRW_draw_callbacks_pre_scene(void)
{
struct ARegion *ar = CTX_wm_region(DST.context);
RegionView3D *rv3d = CTX_wm_region_view3d(DST.context);
/* This is temporary
* waiting for the full matrix switch */
glMatrixMode(GL_PROJECTION);
glLoadMatrixf((float *)rv3d->winmat);
glMatrixMode(GL_MODELVIEW);
glLoadMatrixf((float *)rv3d->viewmat);
ED_region_draw_cb_draw(DST.context, ar, REGION_DRAW_PRE_VIEW);
}
void DRW_draw_callbacks_post_scene(void)
{
struct ARegion *ar = CTX_wm_region(DST.context);
RegionView3D *rv3d = CTX_wm_region_view3d(DST.context);
/* This is temporary
* waiting for the full matrix switch */
glMatrixMode(GL_PROJECTION);
glLoadMatrixf((float *)rv3d->winmat);
glMatrixMode(GL_MODELVIEW);
glLoadMatrixf((float *)rv3d->viewmat);
ED_region_draw_cb_draw(DST.context, ar, REGION_DRAW_POST_VIEW);
}
/* Reset state to not interfer with other UI drawcall */
void DRW_state_reset(void)
{