86 #define MAX_SCHEDULED_FRAMES 8
160 if ((rd ==
nullptr) || ((v3d !=
nullptr) && (rv3d ==
nullptr))) {
188 rv = MEM_cnew<RenderView>(
"new opengl render view");
256 rv = MEM_cnew<RenderView>(
"new opengl render view");
287 int sizex = oglrender->
sizex;
288 int sizey = oglrender->
sizey;
289 const short view_context = (v3d !=
nullptr);
291 float *rectf =
nullptr;
292 uchar *rect =
nullptr;
294 ImBuf *ibuf_result =
nullptr;
313 if (
out->rect_float !=
nullptr) {
347 gp_rect =
static_cast<uchar *
>(
351 for (i = 0; i < sizex * sizey * 4; i += 4) {
362 char err_out[256] =
"unknown";
403 ibuf_result = ibuf_view;
412 fprintf(stderr,
"%s: failed to get buffer, %s\n", __func__, err_out);
416 if (ibuf_result !=
nullptr) {
450 printf(
"OpenGL Render written to '%s'\n", name);
453 printf(
"OpenGL Render failed to write '%s'\n", name);
462 mul = 1.0f - source[3];
483 int chanshown = sseq ? sseq->
chanshown : 0;
494 for (view_id = 0; view_id < oglrender->
views_len; view_id++) {
504 rv = rv->
next, view_id++) {
533 int frame_start =
PSFRA;
534 int frame_end =
PEFRA;
537 if (fcu->driver !=
nullptr || fcu->fpt !=
nullptr) {
546 fcu->bezt, frame_start, fcu->totvert, &found);
547 for (; key_index < fcu->totvert; key_index++) {
555 if (frame_nr > frame_end) {
571 int frame_start =
PSFRA;
572 int frame_end =
PEFRA;
576 if (gp_frame->framenum < frame_start || gp_frame->framenum > frame_end) {
587 if (*id_p ==
nullptr) {
593 const int cb_flag = cb_data->
cb_flag;
678 int frame_start =
PSFRA;
679 int frame_end =
PEFRA;
683 "OGLRender::render_frames");
722 char err_out[256] =
"unknown";
726 op->
reports,
RPT_ERROR,
"Cannot use OpenGL render in background mode (no opengl context)");
736 is_view_context =
false;
742 is_view_context =
false;
745 if (!is_view_context &&
scene->
camera ==
nullptr) {
753 op->
reports,
RPT_ERROR,
"Cannot write a single file with an animation format selected");
774 oglrender = MEM_new<OGLRender>(
"OGLRender");
777 oglrender->
ofs = ofs;
778 oglrender->
sizex = sizex;
779 oglrender->
sizey = sizey;
789 oglrender->
write_still = is_write_still && !is_animation;
803 oglrender->
prevsa = prevsa;
804 oglrender->
prevar = prevar;
806 if (is_view_context) {
844 oglrender->
win = win;
847 oglrender->
mh =
nullptr;
851 if (is_render_keyed_only) {
915 for (i = 0; i < oglrender->
totvideos; i++) {
926 if (oglrender->
timer) {
953 MEM_delete(oglrender);
982 if (oglrender->
mh ==
nullptr) {
991 for (i = 0; i < oglrender->
totvideos; i++) {
1083 report = report->
next) {
1114 WriteTaskData *task_data = MEM_new<WriteTaskData>(
"write task data");
1134 const bool view_context = (oglrender->
v3d !=
nullptr);
1221 switch (event->
type) {
1293 if (!is_animation) {
1328 "Render the viewport for the animation range of this scene, but only render keyframes of "
1329 "selected objects"));
1332 return BLI_strdup(
TIP_(
"Render the viewport for the animation range of this scene"));
1340 ot->
name =
"Viewport Render";
1357 "Render files from the animation range of this scene");
1361 "render_keyed_only",
1363 "Render Keyframes Only",
1364 "Render only those frames where selected objects have a key in their "
1365 "animation data. Only used when rendering animation");
1369 ot->
srna,
"sequencer",
false,
"Sequencer",
"Render using the sequencer's OpenGL display");
1376 "Save rendered the image to the output path (used only when animation is disabled)");
1382 "Use the current 3D view for rendering, else use scene settings");
struct AnimData * BKE_animdata_from_id(const struct ID *id)
Camera data-block and utility functions.
struct Object * BKE_camera_multiview_render(const struct Scene *scene, struct Object *camera, const char *viewname)
struct WorkSpace * CTX_wm_workspace(const bContext *C)
struct ScrArea * CTX_wm_area(const bContext *C)
struct Scene * CTX_data_scene(const bContext *C)
void CTX_wm_region_set(bContext *C, struct ARegion *region)
struct wmWindowManager * CTX_wm_manager(const bContext *C)
#define CTX_DATA_BEGIN(C, Type, instance, member)
struct SpaceSeq * CTX_wm_space_seq(const bContext *C)
struct ViewLayer * CTX_data_view_layer(const bContext *C)
struct Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C)
struct bScreen * CTX_wm_screen(const bContext *C)
struct ARegion * CTX_wm_region(const bContext *C)
void CTX_wm_area_set(bContext *C, struct ScrArea *area)
struct Main * CTX_data_main(const bContext *C)
struct wmWindow * CTX_wm_window(const bContext *C)
CustomData interface, see also DNA_customdata_types.h.
void CustomData_MeshMasks_update(CustomData_MeshMasks *mask_dst, const CustomData_MeshMasks *mask_src)
int BKE_fcurve_bezt_binarysearch_index(const struct BezTriple array[], float frame, int arraylen, bool *r_replace)
void BKE_image_release_ibuf(struct Image *ima, struct ImBuf *ibuf, void *lock)
struct ImBuf * BKE_image_acquire_ibuf(struct Image *ima, struct ImageUser *iuser, void **r_lock)
void BKE_image_backup_render(struct Scene *scene, struct Image *ima, bool free_current_slot)
void BKE_image_partial_update_mark_full_update(struct Image *image)
Mark the whole image to be updated.
struct Image * BKE_image_ensure_viewer(struct Main *bmain, int type, const char *name)
void BKE_image_signal(struct Main *bmain, struct Image *ima, struct ImageUser *iuser, int signal)
void BKE_render_result_stamp_info(struct Scene *scene, struct Object *camera, struct RenderResult *rr, bool allocate_only)
void BKE_image_stamp_buf(struct Scene *scene, struct Object *camera, const struct StampData *stamp_data_template, unsigned char *rect, float *rectf, int width, int height, int channels)
bool BKE_image_render_write(struct ReportList *reports, struct RenderResult *rr, const struct Scene *scene, const bool stamp, const char *filepath_basis)
void BKE_library_foreach_ID_link(struct Main *bmain, struct ID *id, LibraryIDLinkCallback callback, void *user_data, int flag)
@ IDWALK_RET_STOP_RECURSION
const char * BKE_main_blendfile_path(const struct Main *bmain) ATTR_NONNULL()
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
void BKE_report(ReportList *reports, eReportType type, const char *message)
void BKE_reports_init(ReportList *reports, int flag)
bool BKE_scene_multiview_is_stereo3d(const struct RenderData *rd)
int BKE_scene_multiview_num_videos_get(const struct RenderData *rd)
bool BKE_scene_multiview_is_render_view_active(const struct RenderData *rd, const struct SceneRenderView *srv)
void BKE_render_resolution(const struct RenderData *r, const bool use_crop, int *r_width, int *r_height)
bool BKE_scene_camera_switch_update(struct Scene *scene)
void BKE_scene_graph_update_for_newframe(struct Depsgraph *depsgraph)
int BKE_scene_multiview_num_views_get(const struct RenderData *rd)
const char * BKE_scene_multiview_view_id_suffix_get(const struct RenderData *rd, int view_id)
void BKE_scene_multiview_videos_dimensions_get(const struct RenderData *rd, size_t width, size_t height, size_t *r_width, size_t *r_height)
bMovieHandle * BKE_movie_handle_get(char imtype)
#define BLI_BITMAP_NEW(_num, _alloc_string)
#define BLI_BITMAP_ENABLE(_bitmap, _index)
#define BLI_BITMAP_TEST_BOOL(_bitmap, _index)
int BLI_exists(const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
#define LISTBASE_FOREACH(type, var, list)
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void BLI_remlink(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void * BLI_findstring(const struct ListBase *listbase, const char *id, int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
MINLINE int round_fl_to_int(float a)
MINLINE void blend_color_mix_byte(unsigned char dst[4], const unsigned char src1[4], const unsigned char src2[4])
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL() ATTR_MALLOC
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t maxncpy) ATTR_NONNULL()
void * BLI_task_pool_user_data(TaskPool *pool)
void BLI_task_pool_work_and_wait(TaskPool *pool)
TaskPool * BLI_task_pool_create_background_serial(void *userdata, eTaskPriority priority)
TaskPool * BLI_task_pool_create(void *userdata, eTaskPriority priority)
void BLI_task_pool_free(TaskPool *pool)
void BLI_task_pool_push(TaskPool *pool, TaskRunFunction run, void *taskdata, bool free_taskdata, TaskFreeFunction freedata)
void BLI_condition_notify_all(ThreadCondition *cond)
pthread_spinlock_t SpinLock
void BLI_mutex_end(ThreadMutex *mutex)
void BLI_condition_wait(ThreadCondition *cond, ThreadMutex *mutex)
void BLI_mutex_init(ThreadMutex *mutex)
pthread_cond_t ThreadCondition
void BLI_condition_end(ThreadCondition *cond)
void BLI_condition_init(ThreadCondition *cond)
void BLI_mutex_lock(ThreadMutex *mutex)
void BLI_mutex_unlock(ThreadMutex *mutex)
void BLI_spin_init(SpinLock *spin)
void BLI_spin_unlock(SpinLock *spin)
void BLI_spin_lock(SpinLock *spin)
pthread_mutex_t ThreadMutex
void BLI_spin_end(SpinLock *spin)
#define UNUSED_FUNCTION(x)
struct Depsgraph Depsgraph
struct Scene * DEG_get_evaluated_scene(const struct Depsgraph *graph)
Object is a sort of wrapper for general info.
#define V3D_CAMERA_SCENE(scene, v3d)
@ SEQ_PREVIEW_SHOW_GPENCIL
@ V3D_OFSDRAW_SHOW_ANNOTATION
void DRW_opengl_context_enable(void)
void DRW_opengl_context_disable(void)
bool ED_operator_screenactive(struct bContext *C)
bool ED_view3d_context_activate(struct bContext *C)
bool ED_view3d_context_user_region(struct bContext *C, struct View3D **r_v3d, struct ARegion **r_region)
void ED_view3d_datamask(const struct bContext *C, const struct Scene *scene, const struct View3D *v3d, struct CustomData_MeshMasks *r_cddata_masks)
struct ImBuf * ED_view3d_draw_offscreen_imbuf(struct Depsgraph *depsgraph, struct Scene *scene, eDrawType drawtype, struct View3D *v3d, struct ARegion *region, int sizex, int sizey, eImBufFlags imbuf_flag, int alpha_mode, const char *viewname, bool restore_rv3d_mats, struct GPUOffScreen *ofs, char err_out[256])
struct ImBuf * ED_view3d_draw_offscreen_imbuf_simple(struct Depsgraph *depsgraph, struct Scene *scene, struct View3DShading *shading_override, eDrawType drawtype, struct Object *camera, int width, int height, eImBufFlags imbuf_flags, eV3DOffscreenDrawFlag draw_flags, int alpha_mode, const char *viewname, struct GPUOffScreen *ofs, char err_out[256])
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei height
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei width
void GPU_matrix_reset(void)
void GPU_matrix_translate_2f(float x, float y)
void imb_freerectfloatImBuf(struct ImBuf *ibuf)
struct ImBuf * IMB_allocImBuf(unsigned int x, unsigned int y, unsigned char planes, unsigned int flags)
struct ImBuf * IMB_dupImBuf(const struct ImBuf *ibuf1)
void IMB_rect_from_float(struct ImBuf *ibuf)
Contains defines and structs used throughout the imbuf module.
@ IB_DISPLAY_BUFFER_INVALID
Read Guarded memory(de)allocation.
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Sample an image file as a texture Sky Generate a procedural sky texture Noise Generate fractal Perlin noise Wave Generate procedural bands or rings with noise Voronoi Generate Worley noise based on the distance to random points Typically used to generate textures such as or biological cells Brick Generate a procedural texture producing bricks Texture Retrieve multiple types of texture coordinates nTypically used as inputs for texture nodes Vector Convert a or normal between camera
Platform independent time functions.
void ED_annotation_draw_ex(Scene *scene, bGPdata *gpd, int winx, int winy, const int cfra, const char spacetype)
static void mul(btAlignedObjectArray< T > &items, const Q &value)
const Depsgraph * depsgraph
depth_tx normal_tx diffuse_light_tx specular_light_tx volume_light_tx environment_tx ambient_occlusion_tx aov_value_tx in_weight_img GPU_RGBA16F
void GPU_offscreen_free(GPUOffScreen *ofs)
void GPU_offscreen_unbind(GPUOffScreen *UNUSED(ofs), bool restore)
GPUOffScreen * GPU_offscreen_create(int width, int height, bool depth, eGPUTextureFormat format, char err_out[256])
void GPU_offscreen_read_pixels(GPUOffScreen *ofs, eGPUDataFormat format, void *pixels)
void GPU_clear_color(float red, float green, float blue, float alpha)
void GPU_clear_depth(float depth)
void GPU_offscreen_bind(GPUOffScreen *ofs, bool save)
void IMB_freeImBuf(ImBuf *UNUSED(ibuf))
void RE_SetOverrideCamera(Render *re, Object *cam_ob)
void(* MEM_freeN)(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
void *(* MEM_mallocN)(size_t len, const char *str)
void isolate_task(const Function &function)
static const pxr::TfToken out("out", pxr::TfToken::Immortal)
RenderResult * RE_AcquireResultRead(Render *re)
void RE_ReleaseResultImage(Render *re)
bool RE_WriteRenderViewsMovie(ReportList *reports, RenderResult *rr, Scene *scene, RenderData *rd, bMovieHandle *mh, void **movie_ctx_arr, const int totvideos, bool preview)
void RE_FreeRenderResult(RenderResult *rr)
Render * RE_NewSceneRender(const Scene *scene)
void RE_InitState(Render *re, Render *source, RenderData *rd, ListBase *render_layers, ViewLayer *single_layer, int winx, int winy, rcti *disprect)
void RE_ReleaseResult(Render *re)
const char * RE_GetActiveRenderView(Render *re)
RenderResult * RE_AcquireResultWrite(Render *re)
void RE_SetActiveRenderView(Render *re, const char *viewname)
ImBuf * SEQ_render_give_ibuf(const SeqRenderData *context, float timeline_frame, int chanshown)
void SEQ_render_new_render_data(Main *bmain, struct Depsgraph *depsgraph, Scene *scene, int rectx, int recty, int preview_render_size, int for_render, SeqRenderData *r_context)
struct ScrArea * render_view_open(struct bContext *C, int mx, int my, struct ReportList *reports)
static void screen_opengl_render_doit(const bContext *C, OGLRender *oglrender, RenderResult *rr)
static bool schedule_write_result(OGLRender *oglrender, RenderResult *rr)
static bool screen_opengl_render_anim_init(bContext *C, wmOperator *op)
static void screen_opengl_render_end(bContext *C, OGLRender *oglrender)
static void UNUSED_FUNCTION() addAlphaOverFloat(float dest[4], const float source[4])
static int screen_opengl_render_exec(bContext *C, wmOperator *op)
static int screen_opengl_render_modal(bContext *C, wmOperator *op, const wmEvent *event)
static int screen_opengl_render_invoke(bContext *C, wmOperator *op, const wmEvent *event)
#define MAX_SCHEDULED_FRAMES
static char * screen_opengl_render_description(struct bContext *UNUSED(C), struct wmOperatorType *UNUSED(ot), struct PointerRNA *ptr)
static void screen_opengl_views_setup(OGLRender *oglrender)
static void gather_frames_to_render(bContext *C, OGLRender *oglrender)
static int gather_frames_to_render_for_id(LibraryIDLinkCallbackData *cb_data)
static void gather_frames_to_render_for_adt(const OGLRender *oglrender, const AnimData *adt)
static void write_result_func(TaskPool *__restrict pool, void *task_data_v)
static void screen_opengl_render_apply(const bContext *C, OGLRender *oglrender)
static void screen_opengl_render_write(OGLRender *oglrender)
static void write_result(TaskPool *__restrict pool, WriteTaskData *task_data)
static bool screen_opengl_render_anim_step(bContext *C, wmOperator *op)
void RENDER_OT_opengl(wmOperatorType *ot)
static bool screen_opengl_is_multiview(OGLRender *oglrender)
static bool screen_opengl_render_init(bContext *C, wmOperator *op)
static void gather_frames_to_render_for_grease_pencil(const OGLRender *oglrender, const bGPdata *gp)
static void screen_opengl_render_cancel(bContext *C, wmOperator *op)
RenderView * RE_RenderViewGetById(RenderResult *rr, const int view_id)
void RE_render_result_rect_from_ibuf(RenderResult *rr, const ImBuf *ibuf, const int view_id)
RenderResult * RE_DuplicateRenderResult(RenderResult *rr)
void RNA_boolean_set(PointerRNA *ptr, const char *name, bool value)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, bool default_value, const char *ui_name, const char *ui_description)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
static bool is_movie(wmDrag *drag)
BLI_bitmap * render_frames
uint num_scheduled_frames
ThreadCondition task_condition
eImageFormatDepth color_depth
struct OGLRender::@505 seq_data
struct ImageFormatData im_format
struct SceneRenderView * next
struct CustomData_MeshMasks customdata_mask
struct CustomData_MeshMasks customdata_mask_modal
void(* end_movie)(void *context_v)
int(* start_movie)(void *context_v, const struct Scene *scene, struct RenderData *rd, int rectx, int recty, struct ReportList *reports, bool preview, const char *suffix)
void(* context_free)(void *context_v)
void *(* context_create)(void)
int(* invoke)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT
int(* modal)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT
char *(* get_description)(struct bContext *C, struct wmOperatorType *, struct PointerRNA *)
bool(* poll)(struct bContext *) ATTR_WARN_UNUSED_RESULT
void(* cancel)(struct bContext *, struct wmOperator *)
int(* exec)(struct bContext *, struct wmOperator *) ATTR_WARN_UNUSED_RESULT
struct ReportList * reports
double PIL_check_seconds_timer(void)
void WM_cursor_modal_restore(wmWindow *win)
void WM_cursor_time(wmWindow *win, int nr)
wmEventHandler_Op * WM_event_add_modal_handler(bContext *C, wmOperator *op)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
void WM_jobs_kill_all_except(wmWindowManager *wm, const void *owner)
bool WM_jobs_test(const wmWindowManager *wm, const void *owner, int job_type)
void wmOrtho2(float x1, float x2, float y1, float y2)
void WM_event_remove_timer(wmWindowManager *wm, wmWindow *UNUSED(win), wmTimer *timer)
wmTimer * WM_event_add_timer(wmWindowManager *wm, wmWindow *win, int event_type, double timestep)