Fix #29878: running bpy.ops.render.opengl() from console not starting new line
[blender.git] / source / blender / editors / render / render_opengl.c
1 /*
2  * ***** BEGIN GPL LICENSE BLOCK *****
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software Foundation,
16  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  *
18  * The Original Code is Copyright (C) 2008 Blender Foundation.
19  * All rights reserved.
20  *
21  *
22  * ***** END GPL LICENSE BLOCK *****
23  */
24
25 /** \file blender/editors/render/render_opengl.c
26  *  \ingroup edrend
27  */
28
29
30 #include <math.h>
31 #include <string.h>
32 #include <stddef.h>
33
34 #include <GL/glew.h>
35
36 #include "MEM_guardedalloc.h"
37
38 #include "BLI_math.h"
39 #include "BLI_blenlib.h"
40 #include "BLI_editVert.h"
41 #include "BLI_dlrbTree.h"
42 #include "BLI_utildefines.h"
43 #include "BLI_jitter.h"
44
45 #include "DNA_scene_types.h"
46 #include "DNA_object_types.h"
47
48 #include "BKE_context.h"
49 #include "BKE_global.h"
50 #include "BKE_image.h"
51 #include "BKE_main.h"
52 #include "BKE_report.h"
53 #include "BKE_scene.h"
54 #include "BKE_writeavi.h"
55
56 #include "WM_api.h"
57 #include "WM_types.h"
58
59 #include "ED_screen.h"
60 #include "ED_view3d.h"
61 #include "ED_image.h"
62
63 #include "RE_pipeline.h"
64 #include "IMB_imbuf_types.h"
65 #include "IMB_imbuf.h"
66
67 #include "RNA_access.h"
68 #include "RNA_define.h"
69
70
71 #include "GPU_extensions.h"
72
73 #include "wm_window.h"
74
75 #include "render_intern.h"
76
77 typedef struct OGLRender {
78         Main *bmain;
79         Render *re;
80         Scene *scene;
81
82         View3D *v3d;
83         RegionView3D *rv3d;
84         ARegion *ar;
85
86         ScrArea *prevsa;
87         ARegion *prevar;
88
89         short obcenter_dia_back; /* temp overwrite */
90
91         Image *ima;
92         ImageUser iuser;
93
94         GPUOffScreen *ofs;
95         int sizex, sizey;
96         int write_still;
97
98         ReportList *reports;
99         bMovieHandle *mh;
100         int cfrao, nfra;
101
102         wmTimer *timer; /* use to check if running modal or not (invoke'd or exec'd)*/
103 } OGLRender;
104
105 /* added because v3d is not always valid */
106 static unsigned int screen_opengl_layers(OGLRender *oglrender)
107 {
108         if(oglrender->v3d) {
109                 return oglrender->scene->lay | oglrender->v3d->lay;
110         }
111         else {
112                 return oglrender->scene->lay;
113         }
114 }
115
116 static void screen_opengl_render_apply(OGLRender *oglrender)
117 {
118         Scene *scene= oglrender->scene;
119         ARegion *ar= oglrender->ar;
120         View3D *v3d= oglrender->v3d;
121         RegionView3D *rv3d= oglrender->rv3d;
122         RenderResult *rr;
123         Object *camera= NULL;
124         ImBuf *ibuf;
125         void *lock;
126         float winmat[4][4];
127         int sizex= oglrender->sizex;
128         int sizey= oglrender->sizey;
129         const short view_context= (v3d != NULL);
130
131         rr= RE_AcquireResultRead(oglrender->re);
132         
133         if(view_context) {
134                 GPU_offscreen_bind(oglrender->ofs); /* bind */
135
136                 /* render 3d view */
137                 if(rv3d->persp==RV3D_CAMOB && v3d->camera) {
138                         /*int is_ortho= scene->r.mode & R_ORTHO;*/
139                         camera= v3d->camera;
140                         RE_GetCameraWindow(oglrender->re, camera, scene->r.cfra, winmat);
141                         
142                 }
143                 else {
144                         rctf viewplane;
145                         float clipsta, clipend;
146
147                         int is_ortho= ED_view3d_viewplane_get(v3d, rv3d, sizex, sizey, &viewplane, &clipsta, &clipend);
148                         if(is_ortho) orthographic_m4(winmat, viewplane.xmin, viewplane.xmax, viewplane.ymin, viewplane.ymax, -clipend, clipend);
149                         else  perspective_m4(winmat, viewplane.xmin, viewplane.xmax, viewplane.ymin, viewplane.ymax, clipsta, clipend);
150                 }
151
152                 if((scene->r.mode & R_OSA) == 0) { 
153                         ED_view3d_draw_offscreen(scene, v3d, ar, sizex, sizey, NULL, winmat);
154                         GPU_offscreen_read_pixels(oglrender->ofs, GL_FLOAT, rr->rectf);
155                 }
156                 else {
157                         /* simple accumulation, less hassle then FSAA FBO's */
158                         static float jit_ofs[32][2];
159                         float winmat_jitter[4][4];
160                         float *accum_buffer= MEM_mallocN(sizex * sizey * sizeof(float) * 4, "accum1");
161                         float *accum_tmp= MEM_mallocN(sizex * sizey * sizeof(float) * 4, "accum2");
162                         int j;
163
164                         BLI_initjit(jit_ofs[0], scene->r.osa);
165
166                         /* first sample buffer, also initializes 'rv3d->persmat' */
167                         ED_view3d_draw_offscreen(scene, v3d, ar, sizex, sizey, NULL, winmat);
168                         GPU_offscreen_read_pixels(oglrender->ofs, GL_FLOAT, accum_buffer);
169
170                         /* skip the first sample */
171                         for(j=1; j < scene->r.osa; j++) {
172                                 copy_m4_m4(winmat_jitter, winmat);
173                                 window_translate_m4(winmat_jitter, rv3d->persmat,
174                                                     (jit_ofs[j][0] * 2.0f) / sizex,
175                                                     (jit_ofs[j][1] * 2.0f) / sizey);
176
177                                 ED_view3d_draw_offscreen(scene, v3d, ar, sizex, sizey, NULL, winmat_jitter);
178                                 GPU_offscreen_read_pixels(oglrender->ofs, GL_FLOAT, accum_tmp);
179                                 add_vn_vn(accum_buffer, accum_tmp, sizex*sizey*sizeof(float));
180                         }
181
182                         mul_vn_vn_fl(rr->rectf, accum_buffer, sizex*sizey*sizeof(float), 1.0f / scene->r.osa);
183
184                         MEM_freeN(accum_buffer);
185                         MEM_freeN(accum_tmp);
186                 }
187
188                 GPU_offscreen_unbind(oglrender->ofs); /* unbind */
189         }
190         else {
191                 /* shouldnt suddenly give errors mid-render but possible */
192                 char err_out[256]= "unknown";
193                 ImBuf *ibuf_view= ED_view3d_draw_offscreen_imbuf_simple(scene, scene->camera, oglrender->sizex, oglrender->sizey, IB_rectfloat, OB_SOLID, err_out);
194                 camera= scene->camera;
195
196                 if(ibuf_view) {
197                         memcpy(rr->rectf, ibuf_view->rect_float, sizeof(float) * 4 * oglrender->sizex * oglrender->sizey);
198                         IMB_freeImBuf(ibuf_view);
199                 }
200                 else {
201                         fprintf(stderr, "screen_opengl_render_apply: failed to get buffer, %s\n", err_out);
202                 }
203         }
204         
205         /* rr->rectf is now filled with image data */
206
207         if((scene->r.stamp & R_STAMP_ALL) && (scene->r.stamp & R_STAMP_DRAW))
208                 BKE_stamp_buf(scene, camera, NULL, rr->rectf, rr->rectx, rr->recty, 4);
209
210         /* note on color management:
211          *
212          * OpenGL renders into sRGB colors, but render buffers are expected to be
213          * linear if color management is enabled. So we convert to linear here, so
214          * the conversion back to bytes using the color management flag can make it
215          * sRGB again, and so that e.g. openexr saving also saves the correct linear
216          * float buffer. */
217
218         if(oglrender->scene->r.color_mgt_flag & R_COLOR_MANAGEMENT) {
219                 int predivide= 0; /* no alpha */
220
221                 IMB_buffer_float_from_float(rr->rectf, rr->rectf,
222                         4, IB_PROFILE_LINEAR_RGB, IB_PROFILE_SRGB, predivide,
223                         oglrender->sizex, oglrender->sizey, oglrender->sizex, oglrender->sizex);
224         }
225
226         RE_ReleaseResult(oglrender->re);
227
228         /* update byte from float buffer */
229         ibuf= BKE_image_acquire_ibuf(oglrender->ima, &oglrender->iuser, &lock);
230
231         if(ibuf) {
232                 image_buffer_rect_update(scene, rr, ibuf, NULL);
233
234                 if(oglrender->write_still) {
235                         char name[FILE_MAX];
236                         int ok;
237
238                         if(scene->r.im_format.planes == R_IMF_CHAN_DEPTH_8) {
239                                 IMB_color_to_bw(ibuf);
240                         }
241
242                         BKE_makepicstring(name, scene->r.pic, oglrender->bmain->name, scene->r.cfra, scene->r.im_format.imtype, scene->r.scemode & R_EXTENSION, FALSE);
243                         ok= BKE_write_ibuf(ibuf, name, &scene->r.im_format); /* no need to stamp here */
244                         if(ok)  printf("OpenGL Render written to '%s'\n", name);
245                         else    printf("OpenGL Render failed to write '%s'\n", name);
246                 }
247         }
248         
249         BKE_image_release_ibuf(oglrender->ima, lock);
250 }
251
252 static int screen_opengl_render_init(bContext *C, wmOperator *op)
253 {
254         /* new render clears all callbacks */
255         Scene *scene= CTX_data_scene(C);
256         ScrArea *prevsa= CTX_wm_area(C);
257         ARegion *prevar= CTX_wm_region(C);
258         RenderResult *rr;
259         GPUOffScreen *ofs;
260         OGLRender *oglrender;
261         int sizex, sizey;
262         short is_view_context= RNA_boolean_get(op->ptr, "view_context");
263         const short is_animation= RNA_boolean_get(op->ptr, "animation");
264         const short is_write_still= RNA_boolean_get(op->ptr, "write_still");
265         char err_out[256]= "unknown";
266
267         if(G.background) {
268                 BKE_report(op->reports, RPT_ERROR, "Can't use OpenGL render in background mode (no opengl context)");
269                 return 0;
270         }
271
272         /* ensure we have a 3d view */
273
274         if(!ED_view3d_context_activate(C)) {
275                 RNA_boolean_set(op->ptr, "view_context", 0);
276                 is_view_context= 0;
277         }
278
279         /* only one render job at a time */
280         if(WM_jobs_test(CTX_wm_manager(C), scene))
281                 return 0;
282         
283         if(!is_view_context && scene->camera==NULL) {
284                 BKE_report(op->reports, RPT_ERROR, "Scene has no camera");
285                 return 0;
286         }
287
288         if(!is_animation && is_write_still && BKE_imtype_is_movie(scene->r.im_format.imtype)) {
289                 BKE_report(op->reports, RPT_ERROR, "Can't write a single file with an animation format selected");
290                 return 0;
291         }
292
293         /* stop all running jobs, currently previews frustrate Render */
294         WM_jobs_stop_all(CTX_wm_manager(C));
295
296         /* handle UI stuff */
297         WM_cursor_wait(1);
298
299         /* create offscreen buffer */
300         sizex= (scene->r.size*scene->r.xsch)/100;
301         sizey= (scene->r.size*scene->r.ysch)/100;
302
303         /* corrects render size with actual size, not every card supports non-power-of-two dimensions */
304         ofs= GPU_offscreen_create(sizex, sizey, err_out);
305
306         if(!ofs) {
307                 BKE_reportf(op->reports, RPT_ERROR, "Failed to create OpenGL offscreen buffer, %s", err_out);
308                 return 0;
309         }
310
311         /* allocate opengl render */
312         oglrender= MEM_callocN(sizeof(OGLRender), "OGLRender");
313         op->customdata= oglrender;
314
315         oglrender->ofs= ofs;
316         oglrender->sizex= sizex;
317         oglrender->sizey= sizey;
318         oglrender->bmain= CTX_data_main(C);
319         oglrender->scene= scene;
320
321         oglrender->write_still= is_write_still && !is_animation;
322
323         oglrender->obcenter_dia_back = U.obcenter_dia;
324         U.obcenter_dia = 0;
325
326         oglrender->prevsa= prevsa;
327         oglrender->prevar= prevar;
328
329         if(is_view_context) {
330                 oglrender->v3d= CTX_wm_view3d(C);
331                 oglrender->ar= CTX_wm_region(C);
332                 oglrender->rv3d= CTX_wm_region_view3d(C);
333
334                 /* MUST be cleared on exit */
335                 oglrender->scene->customdata_mask_modal = (ED_view3d_datamask(oglrender->scene, oglrender->v3d) |
336                                                            ED_view3d_object_datamask(oglrender->scene) );
337
338                 /* apply immediately incase we're rendeing from a script,
339                  * running notifiers again will overwrite */
340                 oglrender->scene->customdata_mask |= oglrender->scene->customdata_mask_modal;
341
342         }
343
344         /* create render */
345         oglrender->re= RE_NewRender(scene->id.name);
346
347         /* create image and image user */
348         oglrender->ima= BKE_image_verify_viewer(IMA_TYPE_R_RESULT, "Render Result");
349         BKE_image_signal(oglrender->ima, NULL, IMA_SIGNAL_FREE);
350         BKE_image_backup_render(oglrender->scene, oglrender->ima);
351
352         oglrender->iuser.scene= scene;
353         oglrender->iuser.ok= 1;
354
355         /* create render result */
356         RE_InitState(oglrender->re, NULL, &scene->r, NULL, sizex, sizey, NULL);
357
358         rr= RE_AcquireResultWrite(oglrender->re);
359         if(rr->rectf==NULL)
360                 rr->rectf= MEM_callocN(sizeof(float)*4*sizex*sizey, "screen_opengl_render_init rect");
361         RE_ReleaseResult(oglrender->re);
362
363         return 1;
364 }
365
366 static void screen_opengl_render_end(bContext *C, OGLRender *oglrender)
367 {
368         Main *bmain= CTX_data_main(C);
369         Scene *scene= oglrender->scene;
370
371         if(oglrender->mh) {
372                 if(BKE_imtype_is_movie(scene->r.im_format.imtype))
373                         oglrender->mh->end_movie();
374         }
375
376         if(oglrender->timer) { /* exec will not have a timer */
377                 scene->r.cfra= oglrender->cfrao;
378                 scene_update_for_newframe(bmain, scene, screen_opengl_layers(oglrender));
379
380                 WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), oglrender->timer);
381         }
382
383         WM_cursor_wait(0);
384         WM_event_add_notifier(C, NC_SCENE|ND_RENDER_RESULT, oglrender->scene);
385
386         U.obcenter_dia = oglrender->obcenter_dia_back;
387
388         GPU_offscreen_free(oglrender->ofs);
389
390         oglrender->scene->customdata_mask_modal= 0;
391
392         CTX_wm_area_set(C, oglrender->prevsa);
393         CTX_wm_region_set(C, oglrender->prevar);
394
395         MEM_freeN(oglrender);
396 }
397
398 static int screen_opengl_render_cancel(bContext *C, wmOperator *op)
399 {
400         screen_opengl_render_end(C, op->customdata);
401
402         return OPERATOR_CANCELLED;
403 }
404
405 /* share between invoke and exec */
406 static int screen_opengl_render_anim_initialize(bContext *C, wmOperator *op)
407 {
408         /* initialize animation */
409         OGLRender *oglrender;
410         Scene *scene;
411
412         oglrender= op->customdata;
413         scene= oglrender->scene;
414
415         oglrender->reports= op->reports;
416         oglrender->mh= BKE_get_movie_handle(scene->r.im_format.imtype);
417         if(BKE_imtype_is_movie(scene->r.im_format.imtype)) {
418                 if(!oglrender->mh->start_movie(scene, &scene->r, oglrender->sizex, oglrender->sizey, oglrender->reports)) {
419                         screen_opengl_render_end(C, oglrender);
420                         return 0;
421                 }
422         }
423
424         oglrender->cfrao= scene->r.cfra;
425         oglrender->nfra= PSFRA;
426         scene->r.cfra= PSFRA;
427
428         return 1;
429 }
430 static int screen_opengl_render_anim_step(bContext *C, wmOperator *op)
431 {
432         Main *bmain= CTX_data_main(C);
433         OGLRender *oglrender= op->customdata;
434         Scene *scene= oglrender->scene;
435         ImBuf *ibuf;
436         void *lock;
437         char name[FILE_MAX];
438         int ok= 0;
439         const short  view_context= (oglrender->v3d != NULL);
440         Object *camera= NULL;
441
442         /* update animated image textures for gpu, etc,
443          * call before scene_update_for_newframe so modifiers with textuers dont lag 1 frame */
444         ED_image_update_frame(bmain, scene->r.cfra);
445
446         /* go to next frame */
447         while(CFRA<oglrender->nfra) {
448                 unsigned int lay= screen_opengl_layers(oglrender);
449
450                 if(lay & 0xFF000000)
451                         lay &= 0xFF000000;
452
453                 scene_update_for_newframe(bmain, scene, lay);
454                 CFRA++;
455         }
456
457         scene_update_for_newframe(bmain, scene, screen_opengl_layers(oglrender));
458
459         if(view_context) {
460                 if(oglrender->rv3d->persp==RV3D_CAMOB && oglrender->v3d->camera && oglrender->v3d->scenelock) {
461                         /* since scene_update_for_newframe() is used rather
462                          * then ED_update_for_newframe() the camera needs to be set */
463                         if(scene_camera_switch_update(scene)) {
464                                 oglrender->v3d->camera= scene->camera;
465                         }
466
467                         camera= oglrender->v3d->camera;
468                 }
469         }
470         else {
471                 scene_camera_switch_update(scene);
472
473                 camera= scene->camera;
474         }
475
476         /* render into offscreen buffer */
477         screen_opengl_render_apply(oglrender);
478
479         /* save to disk */
480         ibuf= BKE_image_acquire_ibuf(oglrender->ima, &oglrender->iuser, &lock);
481
482         if(ibuf) {
483                 /* color -> greyscale */
484                 /* editing directly would alter the render view */
485                 if(scene->r.im_format.planes == R_IMF_PLANES_BW) {
486                         ImBuf *ibuf_bw= IMB_dupImBuf(ibuf);
487                         IMB_color_to_bw(ibuf_bw);
488                         // IMB_freeImBuf(ibuf); /* owned by the image */
489                         ibuf= ibuf_bw;
490                 }
491                 else {
492                         /* this is lightweight & doesnt re-alloc the buffers, only do this
493                          * to save the correct bit depth since the image is always RGBA */
494                         ImBuf *ibuf_cpy= IMB_allocImBuf(ibuf->x, ibuf->y, scene->r.im_format.planes, 0);
495                         ibuf_cpy->rect= ibuf->rect;
496                         ibuf_cpy->rect_float= ibuf->rect_float;
497                         ibuf_cpy->zbuf_float= ibuf->zbuf_float;
498                         ibuf= ibuf_cpy;
499                 }
500
501                 if(BKE_imtype_is_movie(scene->r.im_format.imtype)) {
502                         ok= oglrender->mh->append_movie(&scene->r, SFRA, CFRA, (int*)ibuf->rect,
503                                                         oglrender->sizex, oglrender->sizey, oglrender->reports);
504                         if(ok) {
505                                 printf("Append frame %d", scene->r.cfra);
506                                 BKE_reportf(op->reports, RPT_INFO, "Appended frame: %d", scene->r.cfra);
507                         }
508                 }
509                 else {
510                         BKE_makepicstring(name, scene->r.pic, oglrender->bmain->name, scene->r.cfra, scene->r.im_format.imtype, scene->r.scemode & R_EXTENSION, TRUE);
511                         ok= BKE_write_ibuf_stamp(scene, camera, ibuf, name, &scene->r.im_format);
512
513                         if(ok==0) {
514                                 printf("Write error: cannot save %s\n", name);
515                                 BKE_reportf(op->reports, RPT_ERROR, "Write error: cannot save %s", name);
516                         }
517                         else {
518                                 printf("Saved: %s", name);
519                                 BKE_reportf(op->reports, RPT_INFO, "Saved file: %s", name);
520                         }
521                 }
522
523                 /* imbuf knows which rects are not part of ibuf */
524                 IMB_freeImBuf(ibuf);
525         }
526
527         BKE_image_release_ibuf(oglrender->ima, lock);
528
529         /* movie stats prints have no line break */
530         printf("\n");
531
532         /* go to next frame */
533         oglrender->nfra += scene->r.frame_step;
534         scene->r.cfra++;
535
536         /* stop at the end or on error */
537         if(scene->r.cfra > PEFRA || !ok) {
538                 screen_opengl_render_end(C, op->customdata);
539                 return 0;
540         }
541
542         return 1;
543 }
544
545
546 static int screen_opengl_render_modal(bContext *C, wmOperator *op, wmEvent *event)
547 {
548         OGLRender *oglrender= op->customdata;
549         int anim= RNA_boolean_get(op->ptr, "animation");
550         int ret;
551
552         switch(event->type) {
553                 case ESCKEY:
554                         /* cancel */
555                         screen_opengl_render_end(C, op->customdata);
556                         return OPERATOR_FINISHED;
557                 case TIMER:
558                         /* render frame? */
559                         if(oglrender->timer == event->customdata)
560                                 break;
561                 default:
562                         /* nothing to do */
563                         return OPERATOR_RUNNING_MODAL;
564         }
565
566         /* run first because screen_opengl_render_anim_step can free oglrender */
567         WM_event_add_notifier(C, NC_SCENE|ND_RENDER_RESULT, oglrender->scene);
568         
569         if(anim == 0) {
570                 screen_opengl_render_apply(op->customdata);
571                 screen_opengl_render_end(C, op->customdata);
572                 return OPERATOR_FINISHED;
573         }
574         else
575                 ret= screen_opengl_render_anim_step(C, op);
576
577         /* stop at the end or on error */
578         if(ret == 0) {
579                 return OPERATOR_FINISHED;
580         }
581
582         return OPERATOR_RUNNING_MODAL;
583 }
584
585 static int screen_opengl_render_invoke(bContext *C, wmOperator *op, wmEvent *event)
586 {
587         OGLRender *oglrender;
588         int anim= RNA_boolean_get(op->ptr, "animation");
589
590         if(!screen_opengl_render_init(C, op))
591                 return OPERATOR_CANCELLED;
592
593         if(anim) {
594                 if(!screen_opengl_render_anim_initialize(C, op))
595                         return OPERATOR_CANCELLED;
596         }
597         
598         oglrender= op->customdata;
599         render_view_open(C, event->x, event->y);
600         
601         WM_event_add_modal_handler(C, op);
602         oglrender->timer= WM_event_add_timer(CTX_wm_manager(C), CTX_wm_window(C), TIMER, 0.01f);
603         
604         return OPERATOR_RUNNING_MODAL;
605 }
606
607 /* executes blocking render */
608 static int screen_opengl_render_exec(bContext *C, wmOperator *op)
609 {
610         const short is_animation= RNA_boolean_get(op->ptr, "animation");
611
612         if(!screen_opengl_render_init(C, op))
613                 return OPERATOR_CANCELLED;
614
615         if(!is_animation) { /* same as invoke */
616                 /* render image */
617                 screen_opengl_render_apply(op->customdata);
618                 screen_opengl_render_end(C, op->customdata);
619
620                 return OPERATOR_FINISHED;
621         }
622         else {
623                 int ret= 1;
624
625                 if(!screen_opengl_render_anim_initialize(C, op))
626                         return OPERATOR_CANCELLED;
627
628                 while(ret) {
629                         ret= screen_opengl_render_anim_step(C, op);
630                 }
631         }
632
633         // no redraw needed, we leave state as we entered it
634 //      ED_update_for_newframe(C, 1);
635         WM_event_add_notifier(C, NC_SCENE|ND_RENDER_RESULT, CTX_data_scene(C));
636
637         return OPERATOR_FINISHED;
638 }
639
640 void RENDER_OT_opengl(wmOperatorType *ot)
641 {
642         /* identifiers */
643         ot->name= "OpenGL Render";
644         ot->description= "OpenGL render active viewport";
645         ot->idname= "RENDER_OT_opengl";
646
647         /* api callbacks */
648         ot->invoke= screen_opengl_render_invoke;
649         ot->exec= screen_opengl_render_exec; /* blocking */
650         ot->modal= screen_opengl_render_modal;
651         ot->cancel= screen_opengl_render_cancel;
652
653         ot->poll= ED_operator_screenactive;
654
655         RNA_def_boolean(ot->srna, "animation", 0, "Animation", "Render files from the animation range of this scene");
656         RNA_def_boolean(ot->srna, "write_still", 0, "Write Image", "Save rendered the image to the output path (used only when animation is disabled)");
657         RNA_def_boolean(ot->srna, "view_context", 1, "View Context", "Use the current 3D view for rendering, else use scene settings");
658 }
659
660 /* function for getting an opengl buffer from a View3D, used by sequencer */
661 // extern void *sequencer_view3d_cb;