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