GPUOffScreen *ofs;
int sizex, sizey;
+ int write_still;
ReportList *reports;
bMovieHandle *mh;
float winmat[4][4];
int sizex= oglrender->sizex;
int sizey= oglrender->sizey;
- int view_context = (v3d != NULL);
+ const short view_context= (v3d != NULL);
rr= RE_AcquireResultRead(oglrender->re);
/* update byte from float buffer */
ibuf= BKE_image_acquire_ibuf(oglrender->ima, &oglrender->iuser, &lock);
- if(ibuf) image_buffer_rect_update(NULL, rr, ibuf, NULL);
+
+ if(ibuf) {
+ image_buffer_rect_update(NULL, rr, ibuf, NULL);
+
+ if(oglrender->write_still) {
+ char name[FILE_MAX];
+ int ok;
+ BKE_makepicstring(name, scene->r.pic, scene->r.cfra, scene->r.imtype, scene->r.scemode & R_EXTENSION, FALSE);
+ ok= BKE_write_ibuf(scene, ibuf, name, scene->r.imtype, scene->r.subimtype, scene->r.quality);
+ if(ok) printf("OpenGL Render written to '%s'\n", name);
+ else printf("OpenGL Render failed to write '%s'\n", name);
+ }
+ }
+
BKE_image_release_ibuf(oglrender->ima, lock);
}
GPUOffScreen *ofs;
OGLRender *oglrender;
int sizex, sizey;
- int view_context= RNA_boolean_get(op->ptr, "view_context");
+ short is_view_context= RNA_boolean_get(op->ptr, "view_context");
+ const short is_animation= RNA_boolean_get(op->ptr, "animation");
+ const short is_write_still= RNA_boolean_get(op->ptr, "view_context");
/* ensure we have a 3d view */
-
+
if(!ED_view3d_context_activate(C)) {
RNA_boolean_set(op->ptr, "view_context", 0);
- view_context = 0;
+ is_view_context= 0;
}
/* only one render job at a time */
if(WM_jobs_test(CTX_wm_manager(C), scene))
return 0;
- if(!view_context && scene->camera==NULL) {
+ if(!is_view_context && scene->camera==NULL) {
BKE_report(op->reports, RPT_ERROR, "Scene has no camera.");
return 0;
}
+ if(!is_animation && is_write_still && BKE_imtype_is_movie(scene->r.imtype)) {
+ BKE_report(op->reports, RPT_ERROR, "Can't write a single file with an animation format selected.");
+ return 0;
+ }
+
/* stop all running jobs, currently previews frustrate Render */
WM_jobs_stop_all(CTX_wm_manager(C));
oglrender->sizey= sizey;
oglrender->scene= scene;
- if(view_context) {
+ oglrender->write_still= is_write_still && !is_animation;
+
+ if(is_view_context) {
oglrender->v3d= CTX_wm_view3d(C);
oglrender->ar= CTX_wm_region(C);
oglrender->rv3d= CTX_wm_region_view3d(C);
void *lock;
char name[FILE_MAXDIR+FILE_MAXFILE];
int ok= 0;
- int view_context = (oglrender->v3d != NULL);
+ const short view_context= (oglrender->v3d != NULL);
/* update animated image textures for gpu, etc,
* call before scene_update_for_newframe so modifiers with textuers dont lag 1 frame */
/* executes blocking render */
static int screen_opengl_render_exec(bContext *C, wmOperator *op)
{
- int anim= RNA_boolean_get(op->ptr, "animation");
+ const short is_animation= RNA_boolean_get(op->ptr, "animation");
if(!screen_opengl_render_init(C, op))
return OPERATOR_CANCELLED;
- if(!anim) { /* same as invoke */
+ if(!is_animation) { /* same as invoke */
/* render image */
screen_opengl_render_apply(op->customdata);
screen_opengl_render_end(C, op->customdata);
ot->poll= ED_operator_screenactive;
- RNA_def_boolean(ot->srna, "animation", 0, "Animation", "");
+ RNA_def_boolean(ot->srna, "animation", 0, "Animation", "Render files from the animation range of this scene");
+ RNA_def_boolean(ot->srna, "write_still", 0, "Write Image", "Save rendered the image to the output path (used only when animation is disabled)");
RNA_def_boolean(ot->srna, "view_context", 1, "View Context", "Use the current 3D view for rendering, else use scene settings.");
}