96 #define MAX_SCHEDULED_FRAMES 8
168 if ((rd ==
NULL) || ((v3d !=
NULL) && (rv3d ==
NULL))) {
293 int sizex = oglrender->
sizex;
294 int sizey = oglrender->
sizey;
295 const short view_context = (v3d !=
NULL);
356 for (i = 0; i < sizex * sizey * 4; i += 4) {
367 char err_out[256] =
"unknown";
408 ibuf_result = ibuf_view;
417 fprintf(stderr,
"%s: failed to get buffer, %s\n", __func__, err_out);
421 if (ibuf_result !=
NULL) {
455 printf(
"OpenGL Render written to '%s'\n", name);
458 printf(
"OpenGL Render failed to write '%s'\n", name);
467 mul = 1.0f - source[3];
469 dest[0] = (
mul * dest[0]) + source[0];
470 dest[1] = (
mul * dest[1]) + source[1];
471 dest[2] = (
mul * dest[2]) + source[2];
472 dest[3] = (
mul * dest[3]) + source[3];
488 int chanshown = sseq ? sseq->
chanshown : 0;
499 for (view_id = 0; view_id < oglrender->
views_len; view_id++) {
507 for (rv = rr->
views.
first, view_id = 0; rv; rv = rv->
next, view_id++) {
536 int frame_start =
PSFRA;
537 int frame_end =
PEFRA;
540 if (fcu->driver !=
NULL || fcu->fpt !=
NULL) {
549 fcu->bezt, frame_start, fcu->totvert, &found);
550 for (; key_index < fcu->totvert; key_index++) {
558 if (frame_nr > frame_end) {
574 int frame_start =
PSFRA;
575 int frame_end =
PEFRA;
579 if (gp_frame->framenum < frame_start || gp_frame->framenum > frame_end) {
596 const int cb_flag = cb_data->
cb_flag;
681 int frame_start =
PSFRA;
682 int frame_end =
PEFRA;
686 "OGLRender::render_frames");
725 char err_out[256] =
"unknown";
729 op->
reports,
RPT_ERROR,
"Cannot use OpenGL render in background mode (no opengl context)");
739 is_view_context =
false;
745 is_view_context =
false;
756 op->
reports,
RPT_ERROR,
"Cannot write a single file with an animation format selected");
781 oglrender->
ofs = ofs;
782 oglrender->
sizex = sizex;
783 oglrender->
sizey = sizey;
793 oglrender->
write_still = is_write_still && !is_animation;
806 oglrender->
prevsa = prevsa;
807 oglrender->
prevar = prevar;
809 if (is_view_context) {
847 oglrender->
win = win;
854 if (is_render_keyed_only) {
918 for (i = 0; i < oglrender->
totvideos; i++) {
929 if (oglrender->
timer) {
985 if (oglrender->
mh ==
NULL) {
993 for (i = 0; i < oglrender->
totvideos; i++) {
1127 const bool view_context = (oglrender->
v3d !=
NULL);
1132 if (CFRA < oglrender->nfra) {
1135 while (CFRA < oglrender->nfra) {
1212 switch (event->
type) {
1284 if (!is_animation) {
1319 "Render the viewport for the animation range of this scene, but only render keyframes of "
1320 "selected objects");
1323 return BLI_strdup(
"Render the viewport for the animation range of this scene");
1331 ot->
name =
"Viewport Render";
1348 "Render files from the animation range of this scene");
1352 "render_keyed_only",
1354 "Render Keyframes Only",
1355 "Render only those frames where selected objects have a key in their "
1356 "animation data. Only used when rendering animation");
1360 ot->
srna,
"sequencer", 0,
"Sequencer",
"Render using the sequencer's OpenGL display");
1367 "Save rendered the image to the output path (used only when animation is disabled)");
1373 "Use the current 3D view for rendering, else use scene settings");
struct AnimData * BKE_animdata_from_id(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(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_path_from_imformat(char *string, const char *base, const char *relbase, int frame, const struct ImageFormatData *im_format, const bool use_ext, const bool use_frames, const char *suffix)
struct Image * BKE_image_ensure_viewer(struct Main *bmain, int type, const char *name)
bool BKE_imtype_is_movie(const char imtype)
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)
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_report(ReportList *reports, ReportType type, const char *message)
void BKE_reportf(ReportList *reports, ReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
void BKE_reports_init(ReportList *reports, int flag)
bool BKE_scene_multiview_is_stereo3d(const struct RenderData *rd)
const char * BKE_scene_multiview_view_id_suffix_get(const struct RenderData *rd, const int view_id)
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)
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)
void BKE_scene_multiview_videos_dimensions_get(const struct RenderData *rd, const size_t width, const size_t height, size_t *r_width, size_t *r_height)
bMovieHandle * BKE_movie_handle_get(const char imtype)
#define BLI_BITMAP_ENABLE(_bitmap, _index)
#define BLI_BITMAP_TEST_BOOL(_bitmap, _index)
#define BLI_BITMAP_NEW(_tot, _alloc_string)
int BLI_exists(const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
#define LISTBASE_FOREACH(type, var, list)
void * BLI_findstring(const struct ListBase *listbase, const char *id, const int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void BLI_remlink(struct ListBase *listbase, void *vlink) 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, const 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, TaskPriority priority)
TaskPool * BLI_task_pool_create(void *userdata, TaskPriority 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)
@ 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, const 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 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
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei height
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)
void IMB_freeImBuf(struct ImBuf *ibuf)
Contains defines and structs used throughout the imbuf module.
@ IB_DISPLAY_BUFFER_INVALID
Read Guarded memory(de)allocation.
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
void GPU_offscreen_free(GPUOffScreen *ofs)
void GPU_offscreen_unbind(GPUOffScreen *UNUSED(ofs), bool restore)
void GPU_offscreen_read_pixels(GPUOffScreen *ofs, eGPUDataFormat format, void *pixels)
void GPU_clear_color(float red, float green, float blue, float alpha)
GPUOffScreen * GPU_offscreen_create(int width, int height, bool depth, bool high_bitdepth, char err_out[256])
void GPU_clear_depth(float depth)
void GPU_offscreen_bind(GPUOffScreen *ofs, bool save)
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)
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)
bool RE_WriteRenderViewsImage(ReportList *reports, RenderResult *rr, Scene *scene, const bool stamp, char *name)
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)
struct WriteTaskData WriteTaskData
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)
struct OGLRender OGLRender
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, RenderData *UNUSED(rd), 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)
struct SELECTID_Context context
BLI_bitmap * render_frames
uint num_scheduled_frames
ThreadCondition task_condition
eImageFormatDepth color_depth
struct OGLRender::@480 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, void *owner)
bool WM_jobs_test(wmWindowManager *wm, 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)