Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_view3d/view3d_draw.c
| Show First 20 Lines • Show All 1,670 Lines • ▼ Show 20 Lines | void ED_view3d_draw_offscreen(Depsgraph *depsgraph, | ||||
| int winx, | int winx, | ||||
| int winy, | int winy, | ||||
| const float viewmat[4][4], | const float viewmat[4][4], | ||||
| const float winmat[4][4], | const float winmat[4][4], | ||||
| bool is_image_render, | bool is_image_render, | ||||
| bool draw_background, | bool draw_background, | ||||
| const char *viewname, | const char *viewname, | ||||
| const bool do_color_management, | const bool do_color_management, | ||||
| const bool restore_rv3d_mats, | |||||
| GPUOffScreen *ofs, | GPUOffScreen *ofs, | ||||
| GPUViewport *viewport) | GPUViewport *viewport) | ||||
| { | { | ||||
| RegionView3D *rv3d = region->regiondata; | RegionView3D *rv3d = region->regiondata; | ||||
| RenderEngineType *engine_type = ED_view3d_engine_type(scene, drawtype); | RenderEngineType *engine_type = ED_view3d_engine_type(scene, drawtype); | ||||
| /* Store `orig` variables. */ | /* Store `orig` variables. */ | ||||
| struct { | struct { | ||||
| ▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | void ED_view3d_draw_offscreen(Depsgraph *depsgraph, | ||||
| GPU_matrix_pop_projection(); | GPU_matrix_pop_projection(); | ||||
| GPU_matrix_pop(); | GPU_matrix_pop(); | ||||
| /* Restore all `orig` members. */ | /* Restore all `orig` members. */ | ||||
| region->winx = orig.region_winx; | region->winx = orig.region_winx; | ||||
| region->winy = orig.region_winy; | region->winy = orig.region_winy; | ||||
| region->winrct = orig.region_winrct; | region->winrct = orig.region_winrct; | ||||
| /* Optionally do _not_ restore rv3d matrices (e.g. they are used/stored in the ImBuff for | |||||
| * reprojection, see texture_paint_image_from_view_exec(). */ | |||||
| if (restore_rv3d_mats) { | |||||
| ED_view3d_mats_rv3d_restore(region->regiondata, orig.rv3d_mats); | ED_view3d_mats_rv3d_restore(region->regiondata, orig.rv3d_mats); | ||||
| } | |||||
| MEM_freeN(orig.rv3d_mats); | MEM_freeN(orig.rv3d_mats); | ||||
| UI_Theme_Restore(&orig.theme_state); | UI_Theme_Restore(&orig.theme_state); | ||||
| v3d->shading.type = orig.v3d_shading_type; | v3d->shading.type = orig.v3d_shading_type; | ||||
| G.f &= ~G_FLAG_RENDER_VIEWPORT; | G.f &= ~G_FLAG_RENDER_VIEWPORT; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 75 Lines • ▼ Show 20 Lines | ED_view3d_draw_offscreen(depsgraph, | ||||
| winx, | winx, | ||||
| winy, | winy, | ||||
| viewmat, | viewmat, | ||||
| winmat, | winmat, | ||||
| is_image_render, | is_image_render, | ||||
| draw_background, | draw_background, | ||||
| viewname, | viewname, | ||||
| do_color_management, | do_color_management, | ||||
| true, | |||||
| ofs, | ofs, | ||||
| viewport); | viewport); | ||||
| } | } | ||||
| /** | /** | ||||
| * Utility func for ED_view3d_draw_offscreen | * Utility func for ED_view3d_draw_offscreen | ||||
| * | * | ||||
| * \param ofs: Optional off-screen buffer, can be NULL. | * \param ofs: Optional off-screen buffer, can be NULL. | ||||
| * (avoids re-creating when doing multiple GL renders). | * (avoids re-creating when doing multiple GL renders). | ||||
| */ | */ | ||||
| ImBuf *ED_view3d_draw_offscreen_imbuf(Depsgraph *depsgraph, | ImBuf *ED_view3d_draw_offscreen_imbuf(Depsgraph *depsgraph, | ||||
| Scene *scene, | Scene *scene, | ||||
| eDrawType drawtype, | eDrawType drawtype, | ||||
| View3D *v3d, | View3D *v3d, | ||||
| ARegion *region, | ARegion *region, | ||||
| int sizex, | int sizex, | ||||
| int sizey, | int sizey, | ||||
| eImBufFlags imbuf_flag, | eImBufFlags imbuf_flag, | ||||
| int alpha_mode, | int alpha_mode, | ||||
| const char *viewname, | const char *viewname, | ||||
| const bool restore_rv3d_mats, | |||||
| /* output vars */ | /* output vars */ | ||||
| GPUOffScreen *ofs, | GPUOffScreen *ofs, | ||||
| char err_out[256]) | char err_out[256]) | ||||
| { | { | ||||
| RegionView3D *rv3d = region->regiondata; | RegionView3D *rv3d = region->regiondata; | ||||
| const bool draw_sky = (alpha_mode == R_ADDSKY); | const bool draw_sky = (alpha_mode == R_ADDSKY); | ||||
| /* view state */ | /* view state */ | ||||
| ▲ Show 20 Lines • Show All 91 Lines • ▼ Show 20 Lines | ED_view3d_draw_offscreen(depsgraph, | ||||
| sizex, | sizex, | ||||
| sizey, | sizey, | ||||
| NULL, | NULL, | ||||
| winmat, | winmat, | ||||
| true, | true, | ||||
| draw_sky, | draw_sky, | ||||
| viewname, | viewname, | ||||
| do_color_management, | do_color_management, | ||||
| restore_rv3d_mats, | |||||
| ofs, | ofs, | ||||
| NULL); | NULL); | ||||
| if (ibuf->rect_float) { | if (ibuf->rect_float) { | ||||
| GPU_offscreen_read_pixels(ofs, GPU_DATA_FLOAT, ibuf->rect_float); | GPU_offscreen_read_pixels(ofs, GPU_DATA_FLOAT, ibuf->rect_float); | ||||
| } | } | ||||
| else if (ibuf->rect) { | else if (ibuf->rect) { | ||||
| GPU_offscreen_read_pixels(ofs, GPU_DATA_UNSIGNED_BYTE, ibuf->rect); | GPU_offscreen_read_pixels(ofs, GPU_DATA_UNSIGNED_BYTE, ibuf->rect); | ||||
| ▲ Show 20 Lines • Show All 109 Lines • ▼ Show 20 Lines | return ED_view3d_draw_offscreen_imbuf(depsgraph, | ||||
| drawtype, | drawtype, | ||||
| &v3d, | &v3d, | ||||
| ®ion, | ®ion, | ||||
| width, | width, | ||||
| height, | height, | ||||
| imbuf_flag, | imbuf_flag, | ||||
| alpha_mode, | alpha_mode, | ||||
| viewname, | viewname, | ||||
| true, | |||||
| ofs, | ofs, | ||||
| err_out); | err_out); | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Viewport Clipping | /** \name Viewport Clipping | ||||
| ▲ Show 20 Lines • Show All 304 Lines • ▼ Show 20 Lines | |||||
| /** | /** | ||||
| * Store values from #RegionView3D, set when drawing. | * Store values from #RegionView3D, set when drawing. | ||||
| * This is needed when we draw with to a viewport using a different matrix | * This is needed when we draw with to a viewport using a different matrix | ||||
| * (offscreen drawing for example). | * (offscreen drawing for example). | ||||
| * | * | ||||
| * Values set by #ED_view3d_update_viewmat should be handled here. | * Values set by #ED_view3d_update_viewmat should be handled here. | ||||
| */ | */ | ||||
| struct RV3DMatrixStore { | struct RV3DMatrixStore { | ||||
| float winmat[4][4]; | float winmat[4][4]; | ||||
| float viewmat[4][4]; | float viewmat[4][4]; | ||||
| float viewinv[4][4]; | float viewinv[4][4]; | ||||
| float persmat[4][4]; | float persmat[4][4]; | ||||
| float persinv[4][4]; | float persinv[4][4]; | ||||
| float viewcamtexcofac[4]; | float viewcamtexcofac[4]; | ||||
| float pixsize; | float pixsize; | ||||
| ▲ Show 20 Lines • Show All 139 Lines • Show Last 20 Lines | |||||