diff options
Diffstat (limited to 'source/blender/draw')
-rw-r--r-- | source/blender/draw/DRW_engine.h | 5 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_manager.c | 36 |
2 files changed, 41 insertions, 0 deletions
diff --git a/source/blender/draw/DRW_engine.h b/source/blender/draw/DRW_engine.h index 6b3aee73229..8811309bcc1 100644 --- a/source/blender/draw/DRW_engine.h +++ b/source/blender/draw/DRW_engine.h @@ -41,6 +41,7 @@ struct ViewContext; struct ViewportEngineData; struct View3D; struct rcti; +struct GPUOffScreen; #include "BLI_sys_types.h" /* for bool */ @@ -67,6 +68,10 @@ void DRW_draw_view(const struct bContext *C); void DRW_draw_render_loop( struct Depsgraph *graph, struct View3D *v3d, struct ARegion *ar); +void DRW_draw_render_loop_offscreen( + struct Depsgraph *graph, + struct View3D *v3d, struct ARegion *ar, + struct GPUOffScreen *ofs); void DRW_draw_select_loop( struct Depsgraph *graph, struct View3D *v3d, struct ARegion *ar, diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index f116ecbc8b4..07182ef2774 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -2188,6 +2188,11 @@ void DRW_draw_view(const bContext *C) DRW_draw_render_loop(graph, v3d, ar); } +/** + * Used for both regular drawing and off-screen drawing. + * + * \param ofs: When not NULL, use this data to create the viewport. + */ void DRW_draw_render_loop( struct Depsgraph *graph, View3D *v3d, ARegion *ar) @@ -2273,6 +2278,37 @@ void DRW_draw_render_loop( memset(&DST, 0x0, sizeof(DST)); } +void DRW_draw_render_loop_offscreen( + struct Depsgraph *graph, + View3D *v3d, ARegion *ar, GPUOffScreen *ofs) +{ + RegionView3D *rv3d = ar->regiondata; + + /* backup */ + void *backup_viewport = rv3d->viewport; + { + /* backup (_never_ use rv3d->viewport) */ + rv3d->viewport = GPU_viewport_create_from_offscreen(ofs); + } + + DST.draw_ctx.evil_C = NULL; + + DRW_draw_render_loop(graph, v3d, ar); + + /* restore */ + { + /* don't free data owned by 'ofs' */ + GPU_viewport_clear_from_offscreen(rv3d->viewport); + GPU_viewport_free(rv3d->viewport); + MEM_freeN(rv3d->viewport); + + rv3d->viewport = backup_viewport; + } + + /* we need to re-bind (annoying!) */ + GPU_offscreen_bind(ofs, false); +} + /** * object mode select-loop, see: ED_view3d_draw_select_loop (legacy drawing). */ |