The zblur plugin (aka as DoF) integrated in render. Compared to patch
[blender.git] / source / blender / src / buttons_scene.c
1 /**
2  * $Id: 
3  *
4  * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version. The Blender
10  * Foundation also sells licenses for use in proprietary software under
11  * the Blender License.  See http://www.blender.org/BL/ for information
12  * about this.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software Foundation,
21  * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22  *
23  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
24  * All rights reserved.
25  *
26  * The Original Code is: all of this file.
27  *
28  * Contributor(s): none yet.
29  *
30  * ***** END GPL/BL DUAL LICENSE BLOCK *****
31  */
32
33 #include <time.h>
34 #include <math.h>
35 #include <stdlib.h>
36 #include <string.h>
37
38 #include "MEM_guardedalloc.h"
39 #include "DNA_screen_types.h"
40 #include "DNA_space_types.h"
41 #include "DNA_scene_types.h"
42 #include "DNA_sound_types.h"
43 #include "DNA_userdef_types.h"
44 #include "DNA_packedFile_types.h"
45
46 #include "BKE_global.h"
47 #include "BKE_main.h"
48 #include "BKE_library.h"
49 #include "BKE_sound.h"
50 #include "BKE_packedFile.h"
51 #include "BKE_utildefines.h"
52
53 #include "BLI_blenlib.h"
54
55 #include "BSE_filesel.h"
56
57 #include "BIF_gl.h"
58 #include "BIF_graphics.h"
59 #include "BIF_glutil.h"
60 #include "BIF_interface.h"
61 #include "BIF_keyval.h"
62 #include "BIF_mainqueue.h"
63 #include "BIF_mywindow.h"
64 #include "BIF_resources.h"
65 #include "BIF_renderwin.h"
66 #include "BIF_screen.h"
67 #include "BIF_space.h"
68 #include "BIF_toolbox.h"
69
70 #include "BIF_butspace.h"
71
72 #include "mydevice.h"
73 #include "blendef.h"
74
75 /* -----includes for this file specific----- */
76
77 #include "render.h"
78 #include "DNA_image_types.h"
79 #include "BKE_writeavi.h"
80 #include "BKE_image.h"
81 #include "BIF_writeimage.h"
82 #include "BIF_writeavicodec.h"
83 #include "BIF_editsound.h"
84 #include "BSE_seqaudio.h"
85 #include "BSE_headerbuttons.h"
86 #include "butspace.h" // own module
87
88 #ifdef WITH_QUICKTIME
89 #include "quicktime_export.h"
90 #endif
91
92
93 /* here the calls for scene buttons
94    - render
95    - world
96    - anim settings, audio
97 */
98
99
100 /* ************************ SOUND *************************** */
101 static void load_new_sample(char *str)  /* called from fileselect */
102 {
103         char name[FILE_MAXDIR+FILE_MAXFILE];
104         bSound *sound;
105         bSample *sample, *newsample;
106
107         sound = G.buts->lockpoin;
108
109         if (sound) {
110                 // save values
111                 sample = sound->sample;
112                 strcpy(name, sound->sample->name);
113
114                 strcpy(sound->name, str);
115                 sound_set_sample(sound, NULL);
116                 sound_initialize_sample(sound);
117
118                 if (sound->sample->type == SAMPLE_INVALID) {
119                         error("Not a valid sample: %s", str);
120
121                         newsample = sound->sample;
122
123                         // restore values
124                         strcpy(sound->name, name);
125                         sound_set_sample(sound, sample);
126
127                         // remove invalid sample
128
129                         sound_free_sample(newsample);
130                         BLI_remlink(samples, newsample);
131                         MEM_freeN(newsample);
132                 }
133         }
134
135         BIF_undo_push("Load new audio file");
136         allqueue(REDRAWBUTSSCENE, 0);
137
138 }
139
140
141 void do_soundbuts(unsigned short event)
142 {
143         char name[FILE_MAXDIR+FILE_MAXFILE];
144         bSound *sound;
145         bSample *sample;
146         bSound* tempsound;
147         ID *id;
148         
149         sound = G.buts->lockpoin;
150         
151         switch(event) {
152         case B_SOUND_REDRAW:
153                 allqueue(REDRAWBUTSSCENE, 0);
154                 break;
155
156         case B_SOUND_LOAD_SAMPLE:
157                 if (sound) strcpy(name, sound->name);
158                 else strcpy(name, U.sounddir);
159                         
160                 activate_fileselect(FILE_SPECIAL, "SELECT WAV FILE", name, load_new_sample);
161                 break;
162
163         case B_SOUND_PLAY_SAMPLE:
164                 if (sound) {
165                         if (sound->sample->type != SAMPLE_INVALID) {
166                                 sound_play_sound(sound);
167                                 allqueue(REDRAWBUTSSCENE, 0);
168                         }
169                 }
170                 break;
171
172         case B_SOUND_MENU_SAMPLE:
173                 if (G.buts->menunr == -2) {
174                         if (sound) {
175                                 activate_databrowse((ID *)sound->sample, ID_SAMPLE, 0, B_SOUND_MENU_SAMPLE, &G.buts->menunr, do_soundbuts);
176                         }
177                 } else if (G.buts->menunr > 0) {
178                         sample = BLI_findlink(samples, G.buts->menunr - 1);
179                         if (sample && sound) {
180                                 BLI_strncpy(sound->name, sample->name, sizeof(sound->name));
181                                 sound_set_sample(sound, sample);
182                                 do_soundbuts(B_SOUND_REDRAW);
183                         }
184                 }
185                         
186                 break;
187         case B_SOUND_NAME_SAMPLE:
188                 load_new_sample(sound->name);
189                 break;
190         
191         case B_SOUND_UNPACK_SAMPLE:
192                 if(sound && sound->sample) {
193                         sample = sound->sample;
194                         
195                         if (sample->packedfile) {
196                                 if (G.fileflags & G_AUTOPACK) {
197                                         if (okee("Disable AutoPack ?")) {
198                                                 G.fileflags &= ~G_AUTOPACK;
199                                         }
200                                 }
201                                 
202                                 if ((G.fileflags & G_AUTOPACK) == 0) {
203                                         unpackSample(sample, PF_ASK);
204                                 }
205                         } else {
206                                 sound_set_packedfile(sample, newPackedFile(sample->name));
207                         }
208                         allqueue(REDRAWHEADERS, 0);
209                         do_soundbuts(B_SOUND_REDRAW);
210                 }
211                 break;
212
213         case B_SOUND_COPY_SOUND:
214                 if (sound) {
215                         tempsound = sound_make_copy(sound);
216                         sound = tempsound;
217                         id = &sound->id;
218                         G.buts->lockpoin = (bSound*)id;
219                         BIF_undo_push("Copy sound");
220                         do_soundbuts(B_SOUND_REDRAW);
221                 }
222                 break;
223
224         case B_SOUND_RECALC:
225                 waitcursor(1);
226                 sound = G.main->sound.first;
227                 while (sound) {
228                         MEM_freeN(sound->stream);
229                         sound->stream = 0;
230                         audio_makestream(sound);
231                         sound = (bSound *) sound->id.next;
232                 }
233                 waitcursor(0);
234                 allqueue(REDRAWSEQ, 0);
235                 break;
236
237         case B_SOUND_RATECHANGED:
238
239                 allqueue(REDRAWBUTSSCENE, 0);
240                 allqueue(REDRAWSEQ, 0);
241                 break;
242
243         case B_SOUND_MIXDOWN:
244                 audio_mixdown();
245                 break;
246
247         default: 
248                 if (G.f & G_DEBUG) {
249                         printf("do_soundbuts: unhandled event %d\n", event);
250                 }
251         }
252 }
253
254
255 static void sound_panel_listener(void)
256 {
257         uiBlock *block;
258         int xco= 100, yco=100, mixrate;
259         char mixrateinfo[256];
260         
261         block= uiNewBlock(&curarea->uiblocks, "sound_panel_listener", UI_EMBOSS, UI_HELV, curarea->win);
262         if(uiNewPanel(curarea, block, "Listener", "Sound", 320, 0, 318, 204)==0) return;
263
264         mixrate = sound_get_mixrate();
265         sprintf(mixrateinfo, "Game Mixrate: %d Hz", mixrate);
266         uiDefBut(block, LABEL, 0, mixrateinfo, xco,yco,295,20, 0, 0, 0, 0, 0, "");
267
268         yco -= 30;
269         uiDefBut(block, LABEL, 0, "Game listener settings:",xco,yco,195,20, 0, 0, 0, 0, 0, "");
270
271         yco -= 30;
272         uiDefButF(block, NUMSLI, B_SOUND_CHANGED, "Volume: ",
273                 xco,yco,195,24,&G.listener->gain, 0.0, 1.0, 1.0, 0, "Sets the maximum volume for the overall sound");
274         
275         yco -= 30;
276         uiDefBut(block, LABEL, 0, "Game Doppler effect settings:",xco,yco,195,20, 0, 0, 0, 0, 0, "");
277
278         yco -= 30;
279         uiDefButF(block, NUMSLI, B_SOUND_CHANGED, "Doppler: ",
280         xco,yco,195,24,&G.listener->dopplerfactor, 0.0, 10.0, 1.0, 0, "Use this for scaling the doppler effect");
281         
282         yco -=30;
283         uiDefButF(block, NUMSLI, B_SOUND_CHANGED, "Velocity: ",
284         xco,yco,195,24,&G.listener->dopplervelocity,0.0,10000.0, 1.0,0, "Sets the propagation speed of sound");
285
286         
287 }
288
289 static void sound_panel_sequencer(void)
290 {
291         uiBlock *block;
292         short xco, yco;
293         char mixrateinfo[256];
294         
295         block= uiNewBlock(&curarea->uiblocks, "sound_panel_sequencer", UI_EMBOSS, UI_HELV, curarea->win);
296         if(uiNewPanel(curarea, block, "Sequencer", "Sound", 640, 0, 318, 204)==0) return;
297
298         /* audio sequence engine settings ------------------------------------------------------------------ */
299
300         xco = 1010;
301         yco = 195;
302
303         uiDefBut(block, LABEL, 0, "Audio sequencer settings", xco,yco,295,20, 0, 0, 0, 0, 0, "");
304
305         yco -= 25;
306         sprintf(mixrateinfo, "Mixing/Sync (latency: %d ms)", (int)( (((float)U.mixbufsize)/(float)G.scene->audio.mixrate)*1000.0 ) );
307         uiDefBut(block, LABEL, 0, mixrateinfo, xco,yco,295,20, 0, 0, 0, 0, 0, "");
308
309         yco -= 25;              
310         uiDefButI(block, ROW, B_SOUND_RATECHANGED, "44.1 kHz",  xco,yco,75,20, &G.scene->audio.mixrate, 2.0, 44100.0, 0, 0, "Mix at 44.1 kHz");
311         uiDefButI(block, ROW, B_SOUND_RATECHANGED, "48.0 kHz",          xco+80,yco,75,20, &G.scene->audio.mixrate, 2.0, 48000.0, 0, 0, "Mix at 48 kHz");
312         uiDefBut(block, BUT, B_SOUND_RECALC, "Recalc",          xco+160,yco,75,20, 0, 0, 0, 0, 0, "Recalculate samples");
313
314         yco -= 25;
315         uiDefButS(block, TOG|BIT|1, B_SOUND_CHANGED, "Sync",    xco,yco,115,20, &G.scene->audio.flag, 0, 0, 0, 0, "Use sample clock for syncing animation to audio");
316         uiDefButS(block, TOG|BIT|2, B_SOUND_CHANGED, "Scrub",           xco+120,yco,115,20, &G.scene->audio.flag, 0, 0, 0, 0, "Scrub when changing frames");
317
318         yco -= 25;
319         uiDefBut(block, LABEL, 0, "Main mix", xco,yco,295,20, 0, 0, 0, 0, 0, "");
320
321         yco -= 25;              
322         uiDefButF(block, NUMSLI, B_SOUND_CHANGED, "Main (dB): ",
323                 xco,yco,235,24,&G.scene->audio.main, -24.0, 6.0, 0, 0, "Set the audio master gain/attenuation in dB");
324
325         yco -= 25;
326         uiDefButS(block, TOG|BIT|0, 0, "Mute",  xco,yco,235,24, &G.scene->audio.flag, 0, 0, 0, 0, "Mute audio from sequencer");         
327         
328         yco -= 35;
329         uiDefBut(block, BUT, B_SOUND_MIXDOWN, "MIXDOWN",        xco,yco,235,24, 0, 0, 0, 0, 0, "Create WAV file from sequenced audio");
330         
331 }
332
333 static void sound_panel_sound(bSound *sound)
334 {
335         static int packdummy=0;
336         ID *id, *idfrom;
337         uiBlock *block;
338         bSample *sample;
339         char *strp, str[32], ch[256];
340
341         block= uiNewBlock(&curarea->uiblocks, "sound_panel_sound", UI_EMBOSS, UI_HELV, curarea->win);
342         if(uiNewPanel(curarea, block, "Sound", "Sound", 0, 0, 318, 204)==0) return;
343         
344         uiDefBut(block, LABEL, 0, "Blender Sound block",10,180,195,20, 0, 0, 0, 0, 0, "");
345         
346         // warning: abuse of texnr here! (ton didnt code!)
347         buttons_active_id(&id, &idfrom);
348         std_libbuttons(block, 10, 160, 0, NULL, B_SOUNDBROWSE2, id, idfrom, &(G.buts->texnr), 1, 0, 0, 0, 0);
349
350         if (sound) {
351         
352                 uiDefBut(block, BUT, B_SOUND_COPY_SOUND, "Copy sound", 220,160,90,20, 0, 0, 0, 0, 0, "Make another copy (duplicate) of the current sound");
353
354                 uiSetButLock(sound->id.lib!=0, "Can't edit library data");
355                 sound_initialize_sample(sound);
356                 sample = sound->sample;
357
358                 /* info string */
359                 if (sound->sample && sound->sample->len) {
360                         char *tmp;
361                         if (sound->sample->channels == 1) tmp= "Mono";
362                         else if (sound->sample->channels == 2) tmp= "Stereo";
363                         else tmp= "Unknown";
364                         
365                         sprintf(ch, "Sample: %s, %d bit, %d Hz, %d samples", tmp, sound->sample->bits, sound->sample->rate, (sound->sample->len/(sound->sample->bits/8)/sound->sample->channels));
366                         uiDefBut(block, LABEL, 0, ch,                   35,140,225,20, 0, 0, 0, 0, 0, "");
367                 }
368                 else {
369                         uiDefBut(block, LABEL, 0, "Sample: No sample info available.",35,140,225,20, 0, 0, 0, 0, 0, "");
370                 }
371
372                 /* sample browse buttons */
373
374                 id= (ID *)sound->sample;
375                 IDnames_to_pupstring(&strp, NULL, NULL, samples, id, &(G.buts->menunr));
376                 if (strp[0]) uiDefButS(block, MENU, B_SOUND_MENU_SAMPLE, strp, 10,120,23,20, &(G.buts->menunr), 0, 0, 0, 0, "Select another loaded sample");
377                 MEM_freeN(strp);
378                 
379                 uiDefBut(block, TEX, B_SOUND_NAME_SAMPLE, "",           35,120,225,20, sound->name, 0.0, 79.0, 0, 0, "The sample file used by this Sound");
380                 
381                 sprintf(str, "%d", sample->id.us);
382                 uiDefBut(block, BUT, B_SOUND_UNLINK_SAMPLE, str,        260,120,25,20, 0, 0, 0, 0, 0, "The number of users");
383                 
384                 if (sound->sample->packedfile) packdummy = 1;
385                 else packdummy = 0;
386                 
387                 uiDefIconButI(block, TOG|BIT|0, B_SOUND_UNPACK_SAMPLE, ICON_PACKAGE,
388                         285, 120,25,24, &packdummy, 0, 0, 0, 0,"Pack/Unpack this sample");
389                 
390                 uiDefBut(block, BUT, B_SOUND_LOAD_SAMPLE, "Load sample", 10, 95,150,24, 0, 0, 0, 0, 0, "Load a different sample file");
391
392                 uiDefBut(block, BUT, B_SOUND_PLAY_SAMPLE, "Play",       160, 95, 150, 24, 0, 0.0, 0, 0, 0, "Playback sample using settings below");
393                 
394                 uiDefButF(block, NUMSLI, B_SOUND_CHANGED, "Volume: ",
395                         10,70,150,20, &sound->volume, 0.0, 1.0, 0, 0, "Game engine only: Set the volume of this sound");
396
397                 uiDefButF(block, NUMSLI, B_SOUND_CHANGED, "Pitch: ",
398                         160,70,150,20, &sound->pitch, -12.0, 12.0, 0, 0, "Game engine only: Set the pitch of this sound");
399
400                 /* looping */
401                 uiDefButI(block, TOG|BIT|SOUND_FLAGS_LOOP_BIT, B_SOUND_REDRAW, "Loop",
402                         10, 50, 95, 20, &sound->flags, 0.0, 0.0, 0, 0, "Game engine only: Toggle between looping on/off");
403
404                 if (sound->flags & SOUND_FLAGS_LOOP) {
405                         uiDefButI(block, TOG|BIT|SOUND_FLAGS_BIDIRECTIONAL_LOOP_BIT, B_SOUND_REDRAW, "Ping Pong",
406                                 105, 50, 95, 20, &sound->flags, 0.0, 0.0, 0, 0, "Game engine only: Toggle between A->B and A->B->A looping");
407                         
408                 }
409         
410
411                 /* 3D settings ------------------------------------------------------------------ */
412
413                 if (sound->sample->channels == 1) {
414                         uiDefButI(block, TOG|BIT|SOUND_FLAGS_3D_BIT, B_SOUND_REDRAW, "3D Sound",
415                                 10, 10, 90, 20, &sound->flags, 0, 0, 0, 0, "Game engine only: Turns 3D sound on");
416                         
417                         if (sound->flags & SOUND_FLAGS_3D) {
418                                 uiDefButF(block, NUMSLI, B_SOUND_CHANGED, "Scale: ",
419                                         100,10,210,20, &sound->attenuation, 0.0, 5.0, 1.0, 0, "Game engine only: Sets the surround scaling factor for this sound");
420                                 
421                         }
422                 }
423         }
424 }
425
426
427 /* ************************* SCENE *********************** */
428
429
430 static void output_pic(char *name)
431 {
432         strcpy(G.scene->r.pic, name);
433         allqueue(REDRAWBUTSSCENE, 0);
434         BIF_undo_push("Change output picture directory");
435 }
436
437 static void backbuf_pic(char *name)
438 {
439         Image *ima;
440         
441         strcpy(G.scene->r.backbuf, name);
442         allqueue(REDRAWBUTSSCENE, 0);
443
444         ima= add_image(name);
445         if(ima) {
446                 free_image_buffers(ima);        /* force read again */
447                 ima->ok= 1;
448         }
449         BIF_undo_push("Change background picture");
450 }
451
452 static void ftype_pic(char *name)
453 {
454         strcpy(G.scene->r.ftype, name);
455         allqueue(REDRAWBUTSSCENE, 0);
456 }
457
458
459 static void scene_change_set(Scene *sc, Scene *set) {
460         if (sc->set!=set) {
461                 sc->set= set;
462                 
463                 allqueue(REDRAWBUTSSCENE, 0);
464                 allqueue(REDRAWVIEW3D, 0);
465                 BIF_undo_push("Change set Scene");
466         }
467 }
468
469 static void run_playanim(char *file) {
470         extern char bprogname[];        /* usiblender.c */
471         char str[FILE_MAXDIR+FILE_MAXFILE];
472         int pos[2], size[2];
473
474         calc_renderwin_rectangle(G.winpos, pos, size);
475
476         sprintf(str, "%s -a -p %d %d \"%s\"", bprogname, pos[0], pos[1], file);
477         system(str);
478 }
479
480 void do_render_panels(unsigned short event)
481 {
482         ScrArea *sa;
483         ID *id;
484         char file[FILE_MAXDIR+FILE_MAXFILE];
485
486         switch(event) {
487
488         case B_DORENDER:
489                 BIF_do_render(0);
490                 break;
491         case B_RTCHANGED:
492                 allqueue(REDRAWALL, 0);
493                 break;
494         case B_SWITCHRENDER:
495                 /* new panels added, so... */
496                 G.buts->re_align= 1;
497                 allqueue(REDRAWBUTSSCENE, 0);
498                 break;
499         case B_PLAYANIM:
500 #ifdef WITH_QUICKTIME
501                 if(G.scene->r.imtype == R_QUICKTIME)
502                         makeqtstring(file);
503                 else
504 #endif
505                         makeavistring(file);
506                 if(BLI_exist(file)) {
507                         run_playanim(file);
508                 }
509                 else {
510                         makepicstring(file, G.scene->r.sfra);
511                         if(BLI_exist(file)) {
512                                 run_playanim(file);
513                         }
514                         else error("Can't find image: %s", file);
515                 }
516                 break;
517                 
518         case B_DOANIM:
519                 BIF_do_render(1);
520                 break;
521         
522         case B_FS_PIC:
523                 sa= closest_bigger_area();
524                 areawinset(sa->win);
525                 if(G.qual == LR_CTRLKEY)
526                         activate_imageselect(FILE_SPECIAL, "SELECT OUTPUT PICTURES", G.scene->r.pic, output_pic);
527                 else
528                         activate_fileselect(FILE_SPECIAL, "SELECT OUTPUT PICTURES", G.scene->r.pic, output_pic);
529                 break;
530
531         case B_FS_BACKBUF:
532                 sa= closest_bigger_area();
533                 areawinset(sa->win);
534                 if(G.qual == LR_CTRLKEY)
535                         activate_imageselect(FILE_SPECIAL, "SELECT BACKBUF PICTURE", G.scene->r.backbuf, backbuf_pic);
536                 else
537                         activate_fileselect(FILE_SPECIAL, "SELECT BACKBUF PICTURE", G.scene->r.backbuf, backbuf_pic);
538                 break;
539
540         case B_FS_FTYPE:
541                 sa= closest_bigger_area();
542                 areawinset(sa->win);
543                 if(G.qual == LR_CTRLKEY)
544                         activate_imageselect(FILE_SPECIAL, "SELECT FTYPE", G.scene->r.ftype, ftype_pic);
545                 else
546                         activate_fileselect(FILE_SPECIAL, "SELECT FTYPE", G.scene->r.ftype, ftype_pic);
547                 break;
548         
549         case B_PR_PAL:
550                 G.scene->r.xsch= 720;
551                 G.scene->r.ysch= 576;
552                 G.scene->r.xasp= 54;
553                 G.scene->r.yasp= 51;
554                 G.scene->r.size= 100;
555                 G.scene->r.frs_sec= 25;
556                 G.scene->r.mode &= ~R_PANORAMA;
557                 G.scene->r.xparts=  G.scene->r.yparts= 1;
558                 
559                 BLI_init_rctf(&G.scene->r.safety, 0.1, 0.9, 0.1, 0.9);
560                 BIF_undo_push("Set PAL");
561                 allqueue(REDRAWBUTSSCENE, 0);
562                 allqueue(REDRAWVIEWCAM, 0);
563                 break;
564
565         case B_FILETYPEMENU:
566                 allqueue(REDRAWBUTSSCENE, 0);
567 #if defined (_WIN32) || defined (__APPLE__)
568                 // fall through to codec settings if this is the first
569                 // time R_AVICODEC is selected for this scene.
570                 if (((G.scene->r.imtype == R_AVICODEC) 
571                          && (G.scene->r.avicodecdata == NULL)) ||
572                         ((G.scene->r.imtype == R_QUICKTIME) 
573                          && (G.scene->r.qtcodecdata == NULL))) {
574                 } else {
575                   break;
576                 }
577 #endif /*_WIN32 || __APPLE__ */
578
579         case B_SELECTCODEC:
580 #if defined (_WIN32) || defined (__APPLE__)
581                 if ((G.scene->r.imtype == R_QUICKTIME)) { /* || (G.scene->r.qtcodecdata)) */
582 #ifdef WITH_QUICKTIME
583                         get_qtcodec_settings();
584 #endif /* WITH_QUICKTIME */
585                 }
586 #if defined (_WIN32) && !defined(FREE_WINDOWS)
587                 else
588                         get_avicodec_settings();
589 #endif /* _WIN32 && !FREE_WINDOWS */
590 #endif /* _WIN32 || __APPLE__ */
591                 break;
592
593         case B_PR_FULL:
594                 G.scene->r.xsch= 1280;
595                 G.scene->r.ysch= 1024;
596                 G.scene->r.xasp= 1;
597                 G.scene->r.yasp= 1;
598                 G.scene->r.size= 100;
599                 G.scene->r.mode &= ~R_PANORAMA;
600                 G.scene->r.xparts=  G.scene->r.yparts= 1;
601
602                 BLI_init_rctf(&G.scene->r.safety, 0.1, 0.9, 0.1, 0.9);
603                 BIF_undo_push("Set FULL");
604                 allqueue(REDRAWBUTSSCENE, 0);
605                 allqueue(REDRAWVIEWCAM, 0);
606                 break;
607         case B_PR_PRV:
608                 G.scene->r.xsch= 640;
609                 G.scene->r.ysch= 512;
610                 G.scene->r.xasp= 1;
611                 G.scene->r.yasp= 1;
612                 G.scene->r.size= 50;
613                 G.scene->r.mode &= ~R_PANORAMA;
614                 G.scene->r.xparts=  G.scene->r.yparts= 1;
615
616                 BLI_init_rctf(&G.scene->r.safety, 0.1, 0.9, 0.1, 0.9);
617                 allqueue(REDRAWVIEWCAM, 0);
618                 allqueue(REDRAWBUTSSCENE, 0);
619                 break;
620         case B_PR_CDI:
621                 G.scene->r.xsch= 384;
622                 G.scene->r.ysch= 280;
623                 G.scene->r.xasp= 1;
624                 G.scene->r.yasp= 1;
625                 G.scene->r.size= 100;
626                 G.scene->r.mode &= ~R_PANORAMA;
627                 G.scene->r.xparts=  G.scene->r.yparts= 1;
628
629                 BLI_init_rctf(&G.scene->r.safety, 0.15, 0.85, 0.15, 0.85);
630                 allqueue(REDRAWVIEWCAM, 0);
631                 allqueue(REDRAWBUTSSCENE, 0);
632                 break;
633         case B_PR_PAL169:
634                 G.scene->r.xsch= 720;
635                 G.scene->r.ysch= 576;
636                 G.scene->r.xasp= 64;
637                 G.scene->r.yasp= 45;
638                 G.scene->r.size= 100;
639                 G.scene->r.frs_sec= 25;
640                 G.scene->r.mode &= ~R_PANORAMA;
641                 G.scene->r.xparts=  G.scene->r.yparts= 1;
642
643                 BLI_init_rctf(&G.scene->r.safety, 0.1, 0.9, 0.1, 0.9);
644                 BIF_undo_push("Set PAL 16/9");
645                 allqueue(REDRAWVIEWCAM, 0);
646                 allqueue(REDRAWBUTSSCENE, 0);
647                 break;
648         case B_PR_D2MAC:
649                 G.scene->r.xsch= 1024;
650                 G.scene->r.ysch= 576;
651                 G.scene->r.xasp= 1;
652                 G.scene->r.yasp= 1;
653                 G.scene->r.size= 50;
654                 G.scene->r.mode &= ~R_PANORAMA;
655                 G.scene->r.xparts=  G.scene->r.yparts= 1;
656
657                 BLI_init_rctf(&G.scene->r.safety, 0.1, 0.9, 0.1, 0.9);
658                 allqueue(REDRAWVIEWCAM, 0);
659                 allqueue(REDRAWBUTSSCENE, 0);
660                 break;
661         case B_PR_MPEG:
662                 G.scene->r.xsch= 368;
663                 G.scene->r.ysch= 272;
664                 G.scene->r.xasp= 105;
665                 G.scene->r.yasp= 100;
666                 G.scene->r.size= 100;
667                 G.scene->r.mode &= ~R_PANORAMA;
668                 G.scene->r.xparts=  G.scene->r.yparts= 1;
669
670                 BLI_init_rctf(&G.scene->r.safety, 0.1, 0.9, 0.1, 0.9);
671                 allqueue(REDRAWVIEWCAM, 0);
672                 allqueue(REDRAWBUTSSCENE, 0);
673                 break;
674         case B_PR_PC:
675                 G.scene->r.xsch= 640;
676                 G.scene->r.ysch= 480;
677                 G.scene->r.xasp= 100;
678                 G.scene->r.yasp= 100;
679                 G.scene->r.size= 100;
680                 G.scene->r.mode &= ~R_PANORAMA;
681                 G.scene->r.xparts=  G.scene->r.yparts= 1;
682
683                 BLI_init_rctf(&G.scene->r.safety, 0.0, 1.0, 0.0, 1.0);
684                 BIF_undo_push("Set PC");
685                 allqueue(REDRAWVIEWCAM, 0);
686                 allqueue(REDRAWBUTSSCENE, 0);
687                 break;
688         case B_PR_PRESET:
689                 G.scene->r.xsch= 720;
690                 G.scene->r.ysch= 576;
691                 G.scene->r.xasp= 54;
692                 G.scene->r.yasp= 51;
693                 G.scene->r.size= 100;
694                 G.scene->r.mode= R_OSA+R_SHADOW+R_FIELDS;
695                 G.scene->r.imtype= R_TARGA;
696                 G.scene->r.xparts=  G.scene->r.yparts= 1;
697
698                 BLI_init_rctf(&G.scene->r.safety, 0.1, 0.9, 0.1, 0.9);
699                 BIF_undo_push("Set Default");
700                 allqueue(REDRAWVIEWCAM, 0);
701                 allqueue(REDRAWBUTSSCENE, 0);
702                 break;
703         case B_PR_PANO:
704                 G.scene->r.xsch= 36;
705                 G.scene->r.ysch= 176;
706                 G.scene->r.xasp= 115;
707                 G.scene->r.yasp= 100;
708                 G.scene->r.size= 100;
709                 G.scene->r.mode |= R_PANORAMA;
710                 G.scene->r.xparts=  16;
711                 G.scene->r.yparts= 1;
712
713                 BLI_init_rctf(&G.scene->r.safety, 0.1, 0.9, 0.1, 0.9);
714                 BIF_undo_push("Set Panorama");
715                 allqueue(REDRAWVIEWCAM, 0);
716                 allqueue(REDRAWBUTSSCENE, 0);
717                 break;
718         case B_PR_NTSC:
719                 G.scene->r.xsch= 720;
720                 G.scene->r.ysch= 480;
721                 G.scene->r.xasp= 10;
722                 G.scene->r.yasp= 11;
723                 G.scene->r.size= 100;
724                 G.scene->r.frs_sec= 30;
725                 G.scene->r.mode &= ~R_PANORAMA;
726                 G.scene->r.xparts=  G.scene->r.yparts= 1;
727                 
728                 BLI_init_rctf(&G.scene->r.safety, 0.1, 0.9, 0.1, 0.9);
729                 BIF_undo_push("Set NTSC");
730                 allqueue(REDRAWBUTSSCENE, 0);
731                 allqueue(REDRAWVIEWCAM, 0);
732                 break;
733
734         case B_SETBROWSE:
735                 id= (ID*) G.scene->set;
736                 
737                 if (G.buts->menunr==-2) {
738                          activate_databrowse(id, ID_SCE, 0, B_SETBROWSE, &G.buts->menunr, do_render_panels);
739                 } else if (G.buts->menunr>0) {
740                         Scene *newset= (Scene*) BLI_findlink(&G.main->scene, G.buts->menunr-1);
741                         
742                         if (newset==G.scene)
743                                 error("Not allowed");
744                         else if (newset)
745                                 scene_change_set(G.scene, newset);
746                 }  
747                 break;
748         case B_CLEARSET:
749                 scene_change_set(G.scene, NULL);
750                 break;
751         case B_FBUF_REDO:
752                 if(R.rectftot) {
753                         /* copy is needed... not so nice, but how better? */
754                         R.r.postgamma= G.scene->r.postgamma;
755                         R.r.postigamma= 1.0/R.r.postgamma;
756                         R.r.postadd= G.scene->r.postadd;
757                         R.r.postmul= G.scene->r.postmul;
758                         R.r.posthue= G.scene->r.posthue;
759                         R.r.postsat= G.scene->r.postsat;
760                         R.r.dither_intensity= G.scene->r.dither_intensity;
761                         
762                         RE_floatbuffer_to_output();
763                         BIF_redraw_render_rect();
764                 }
765                 break;
766         case B_SET_EDGE:
767                 G.scene->r.mode &= ~R_ZBLUR;
768                 allqueue(REDRAWBUTSSCENE, 0);
769                 break;
770         case B_SET_ZBLUR:
771                 G.scene->r.mode &= ~R_EDGE;
772                 allqueue(REDRAWBUTSSCENE, 0);
773                 break;
774         }
775 }
776
777 static uiBlock *edge_render_menu(void *arg_unused)
778 {
779         uiBlock *block;
780         
781         block= uiNewBlock(&curarea->uiblocks, "edge render", UI_EMBOSS, UI_HELV, curarea->win);
782                 
783         /* use this for a fake extra empy space around the buttons */
784         uiDefBut(block, LABEL, 0, "",  290, -15, 220, 115, NULL,  0, 0, 0, 0, "");
785         
786         uiBlockBeginAlign(block);
787         uiDefButS(block, NUM, 0,"Eint:",        370,75,135,19,  &G.scene->r.edgeint, 0.0, 255.0, 0, 0,
788                   "Sets edge intensity for Toon shading");
789         uiDefButS(block, NUM, 0,"AntiShift",370,55,135,19,  &(G.scene->r.same_mat_redux), 0, 255.0, 0, 0,
790                   "For unified renderer: reduce intensity on boundaries "
791                   "with identical materials with this number.");
792
793         uiBlockBeginAlign(block);
794         uiDefButI(block, TOG, 0,"Shift",        295,75,70,19,  &G.compat, 0, 0, 0, 0,
795                   "For unified renderer: use old offsets for edges");
796         uiDefButI(block, TOG, 0,"All",          295,55,70,19,  &G.notonlysolid, 0, 0, 0, 0,
797                   "For unified renderer: also consider transparent faces for toon shading");
798         uiBlockEndAlign(block);
799         
800         /* colour settings for the toon shading */
801         uiDefButF(block, COL, 0, "",            295,-10,30,60,  &(G.scene->r.edgeR), 0, 0, 0, B_EDGECOLSLI, "");
802         
803         uiBlockBeginAlign(block);
804         uiDefButF(block, NUMSLI, 0, "R ",   330, 30, 175,19,   &G.scene->r.edgeR, 0.0, 1.0, B_EDGECOLSLI, 0,
805                   "For unified renderer: Colour for edges in toon shading mode.");
806         uiDefButF(block, NUMSLI, 0, "G ",       330, 10, 175,19,  &G.scene->r.edgeG, 0.0, 1.0, B_EDGECOLSLI, 0,
807                   "For unified renderer: Colour for edges in toon shading mode.");
808         uiDefButF(block, NUMSLI, 0, "B ",       330, -10, 175,19,  &G.scene->r.edgeB, 0.0, 1.0, B_EDGECOLSLI, 0,
809                   "For unified renderer: Colour for edges in toon shading mode.");
810
811         
812         uiBlockSetDirection(block, UI_TOP);
813         
814         return block;
815 }
816
817 static uiBlock *post_render_menu(void *arg_unused)
818 {
819         uiBlock *block;
820         
821         block= uiNewBlock(&curarea->uiblocks, "post render", UI_EMBOSS, UI_HELV, curarea->win);
822                 
823         /* use this for a fake extra empy space around the buttons */
824         uiDefBut(block, LABEL, 0, "",                   -10, -10, 200, 120, NULL, 0, 0, 0, 0, "");
825         uiBlockBeginAlign(block);
826         uiDefButF(block, NUMSLI, 0, "Add:",             0,80,180,19, &G.scene->r.postadd, -1.0, 1.0, 0, 0, "");
827         uiDefButF(block, NUMSLI, 0, "Mul:",             0,60,180,19,  &G.scene->r.postmul, 0.01, 4.0, 0, 0, "");
828         uiDefButF(block, NUMSLI, 0, "Gamma:",   0,40,180,19,  &G.scene->r.postgamma, 0.1, 4.0, 0, 0, "");
829         uiDefButF(block, NUMSLI, 0, "Hue:",             0,20,180,19,  &G.scene->r.posthue, -0.5, 0.5, 0, 0, "");
830         uiDefButF(block, NUMSLI, 0, "Sat:",             0, 0,180,19,  &G.scene->r.postsat, 0.0, 4.0, 0, 0, "");
831
832         uiBlockSetDirection(block, UI_TOP);
833         
834         addqueue(curarea->win, UI_BUT_EVENT, B_FBUF_REDO);
835         
836         return block;
837 }
838
839
840 static uiBlock *framing_render_menu(void *arg_unused)
841 {
842         uiBlock *block;
843         short yco = 190, xco = 0;
844         int randomcolorindex = 1234;
845
846         block= uiNewBlock(&curarea->uiblocks, "framing_options", UI_EMBOSS, UI_HELV, curarea->win);
847
848         /* use this for a fake extra empy space around the buttons */
849         uiDefBut(block, LABEL, 0, "",                   -5, -10, 295, 224, NULL, 0, 0, 0, 0, "");
850
851         uiDefBut(block, LABEL, B_NOP, "Framing:", xco, yco, 68,19, 0, 0, 0, 0, 0, "");
852         uiBlockBeginAlign(block);
853         uiDefButC(block, ROW, 0, "Stretch",     xco += 70, yco, 68, 19, &G.scene->framing.type, 1.0, SCE_GAMEFRAMING_SCALE , 0, 0, "Stretch or squeeze the viewport to fill the display window");
854         uiDefButC(block, ROW, 0, "Expose",      xco += 70, yco, 68, 19, &G.scene->framing.type, 1.0, SCE_GAMEFRAMING_EXTEND, 0, 0, "Show the entire viewport in the display window, viewing more horizontally or vertically");
855         uiDefButC(block, ROW, 0, "Letterbox",       xco += 70, yco, 68, 19, &G.scene->framing.type, 1.0, SCE_GAMEFRAMING_BARS  , 0, 0, "Show the entire viewport in the display window, using bar horizontally or vertically");
856         uiBlockEndAlign(block);
857
858         yco -= 25;
859         xco = 40;
860
861         uiDefButF(block, COL, 0, "",                0, yco - 58 + 18, 33, 58, &G.scene->framing.col[0], 0, 0, 0, randomcolorindex, "");
862
863         uiBlockBeginAlign(block);
864         uiDefButF(block, NUMSLI, 0, "R ", xco,yco,243,18, &G.scene->framing.col[0], 0.0, 1.0, randomcolorindex, 0, "Set the red component of the bars");
865         yco -= 20;
866         uiDefButF(block, NUMSLI, 0, "G ", xco,yco,243,18, &G.scene->framing.col[1], 0.0, 1.0, randomcolorindex, 0, "Set the green component of the bars");
867         yco -= 20;
868         uiDefButF(block, NUMSLI, 0, "B ", xco,yco,243,18, &G.scene->framing.col[2], 0.0, 1.0, randomcolorindex, 0, "Set the blue component of the bars");
869         uiBlockEndAlign(block);
870         
871         xco = 0;
872         uiDefBut(block, LABEL, 0, "Fullscreen:",                xco, yco-=30, 100, 19, 0, 0.0, 0.0, 0, 0, "");
873         uiDefButS(block, TOG, 0, "Fullscreen", xco+70, yco, 68, 19, &G.scene->r.fullscreen, 0.0, 0.0, 0, 0, "Starts player in a new fullscreen display");
874         uiBlockBeginAlign(block);
875         uiDefButS(block, NUM, 0, "X:",          xco+40, yco-=27, 100, 19, &G.scene->r.xplay, 10.0, 2000.0, 0, 0, "Displays current X screen/window resolution. Click to change.");
876         uiDefButS(block, NUM, 0, "Y:",          xco+140, yco, 100, 19, &G.scene->r.yplay,    10.0, 2000.0, 0, 0, "Displays current Y screen/window resolution. Click to change.");
877         uiDefButS(block, NUM, 0, "Freq:",       xco+40, yco-=21, 100, 19, &G.scene->r.freqplay, 10.0, 2000.0, 0, 0, "Displays clock frequency of fullscreen display. Click to change.");
878         uiDefButS(block, NUM, 0, "Bits:",       xco+140, yco, 100, 19, &G.scene->r.depth, 8.0, 32.0, 800.0, 0, "Displays bit depth of full screen display. Click to change.");
879         uiBlockEndAlign(block);
880
881         /* stereo settings */
882         /* can't use any definition from the game engine here so hardcode it. Change it here when it changes there!
883          * RAS_IRasterizer has definitions:
884          * RAS_STEREO_NOSTEREO           1
885          * RAS_STEREO_QUADBUFFERED 2
886          * RAS_STEREO_ABOVEBELOW         3
887          * RAS_STEREO_INTERLACED         4       future
888          * RAS_STEREO_ANAGLYPH          5
889          * RAS_STEREO_SIDEBYSIDE        6
890          * RAS_STEREO_VINTERLACE        7
891          */
892         uiBlockBeginAlign(block);
893         uiDefButS(block, ROW, 0, "No Stereo", xco, yco-=30, 88, 19, &(G.scene->r.stereomode), 7.0, 1.0, 0, 0, "Disables stereo");
894         uiDefButS(block, ROW, 0, "Pageflip", xco+=90, yco, 88, 19, &(G.scene->r.stereomode), 7.0, 2.0, 0, 0, "Enables hardware pageflip stereo method");
895         uiDefButS(block, ROW, 0, "Syncdouble", xco+=90, yco, 88, 19, &(G.scene->r.stereomode), 7.0, 3.0, 0, 0, "Enables syncdoubling stereo method");
896         uiDefButS(block, ROW, 0, "Anaglyph", xco-=180, yco-=21, 88, 19, &(G.scene->r.stereomode), 7.0, 5.0, 0, 0, "Enables anaglyph (Red-Blue) stereo method");
897         uiDefButS(block, ROW, 0, "Side by Side", xco+=90, yco, 88, 19, &(G.scene->r.stereomode), 7.0, 6.0, 0, 0, "Enables side by side left and right images");
898         uiDefButS(block, ROW, 0, "V Interlace", xco+=90, yco, 88, 19, &(G.scene->r.stereomode), 7.0, 7.0, 0, 0, "Enables interlaced vertical strips for autostereo display");
899         
900         uiBlockEndAlign(block);
901
902         uiBlockSetDirection(block, UI_TOP);
903
904         return block;
905 }
906
907
908 static char *imagetype_pup(void)
909 {
910         static char string[1024];
911         char formatstring[1024];
912
913         strcpy(formatstring, "Save image as: %%t|%s %%x%d|%s %%x%d|%s %%x%d|%s %%x%d|%s %%x%d|%s %%x%d|%s %%x%d|%s %%x%d|%s %%x%d");
914
915 #ifdef __sgi
916         strcat(formatstring, "|%s %%x%d");      // add space for Movie
917 #endif
918
919         strcat(formatstring, "|%s %%x%d");      // add space for PNG
920         strcat(formatstring, "|%s %%x%d");      // add space for BMP
921
922 #ifdef _WIN32
923         strcat(formatstring, "|%s %%x%d");      // add space for AVI Codec
924 #endif
925
926 #ifdef WITH_QUICKTIME
927         if(G.have_quicktime)
928                 strcat(formatstring, "|%s %%x%d");      // add space for Quicktime
929 #endif
930
931         if(G.have_quicktime) {
932                 sprintf(string, formatstring,
933                         "AVI Raw",        R_AVIRAW,
934                         "AVI Jpeg",       R_AVIJPEG,
935 #ifdef _WIN32
936                         "AVI Codec",      R_AVICODEC,
937 #endif
938 #ifdef WITH_QUICKTIME
939                         "QuickTime",      R_QUICKTIME,
940 #endif
941                         "Targa",          R_TARGA,
942                         "Targa Raw",      R_RAWTGA,
943                         "PNG",            R_PNG,
944                         "BMP",            R_BMP,
945                         "Jpeg",           R_JPEG90,
946                         "HamX",           R_HAMX,
947                         "Iris",           R_IRIS,
948                         "Iris + Zbuffer", R_IRIZ,
949                         "Ftype",          R_FTYPE,
950                         "Movie",          R_MOVIE
951                 );
952         } else {
953                 sprintf(string, formatstring,
954                         "AVI Raw",        R_AVIRAW,
955                         "AVI Jpeg",       R_AVIJPEG,
956 #ifdef _WIN32
957                         "AVI Codec",      R_AVICODEC,
958 #endif
959                         "Targa",          R_TARGA,
960                         "Targa Raw",      R_RAWTGA,
961                         "PNG",            R_PNG,
962                         "BMP",            R_BMP,
963                         "Jpeg",           R_JPEG90,
964                         "HamX",           R_HAMX,
965                         "Iris",           R_IRIS,
966                         "Iris + Zbuffer", R_IRIZ,
967                         "Ftype",          R_FTYPE,
968                         "Movie",          R_MOVIE
969                 );
970         }
971
972         return (string);
973 }
974
975 #ifdef _WIN32
976 static char *avicodec_str(void)
977 {
978         static char string[1024];
979
980         sprintf(string, "Codec: %s", G.scene->r.avicodecdata->avicodecname);
981
982         return string;
983 }
984 #endif
985
986 static void render_panel_output(void)
987 {
988         ID *id;
989         int a,b;
990         uiBlock *block;
991         char *strp;
992
993
994         block= uiNewBlock(&curarea->uiblocks, "render_panel_output", UI_EMBOSS, UI_HELV, curarea->win);
995         if(uiNewPanel(curarea, block, "Output", "Render", 0, 0, 318, 204)==0) return;
996         
997         uiBlockBeginAlign(block);
998         uiDefIconBut(block, BUT, B_FS_PIC, ICON_FILESEL,        10, 190, 20, 20, 0, 0, 0, 0, 0, "Open Fileselect to get Pics dir/name");
999         uiDefBut(block, TEX,0,"",                                                       31, 190, 279, 20,G.scene->r.pic, 0.0,79.0, 0, 0, "Directory/name to save rendered Pics to");
1000         uiDefIconBut(block, BUT,B_FS_BACKBUF, ICON_FILESEL, 10, 168, 20, 20, 0, 0, 0, 0, 0, "Open Fileselect to get Backbuf image");
1001         uiDefBut(block, TEX,0,"",                                                       31, 168, 279, 20,G.scene->r.backbuf, 0.0,79.0, 0, 0, "Image to use as background for rendering");
1002         uiDefIconBut(block, BUT,B_FS_FTYPE, ICON_FILESEL,       10, 146, 20, 20, 0, 0, 0, 0, 0, "Open Fileselect to get Ftype image");
1003         uiDefBut(block, TEX,0,"",                                                       31, 146, 279, 20,G.scene->r.ftype,0.0,79.0, 0, 0, "Image to use with FTYPE Image type");
1004         uiBlockEndAlign(block);
1005         
1006         
1007         /* SET BUTTON */
1008         uiBlockBeginAlign(block);
1009         id= (ID *)G.scene->set;
1010         IDnames_to_pupstring(&strp, NULL, NULL, &(G.main->scene), id, &(G.buts->menunr));
1011         if(strp[0])
1012                 uiDefButS(block, MENU, B_SETBROWSE, strp, 10, 120, 20, 20, &(G.buts->menunr), 0, 0, 0, 0, "Scene to link as a Set");
1013         MEM_freeN(strp);
1014
1015         if(G.scene->set) {
1016                 uiSetButLock(1, NULL);
1017                 uiDefIDPoinBut(block, test_scenepoin_but, 0, "",        31, 120, 100, 20, &(G.scene->set), "Name of the Set");
1018                 uiClearButLock();
1019                 uiDefIconBut(block, BUT, B_CLEARSET, ICON_X,            132, 120, 20, 20, 0, 0, 0, 0, 0, "Remove Set link");
1020         }
1021         uiBlockEndAlign(block);
1022
1023         uiBlockSetCol(block, TH_BUT_SETTING1);
1024         uiDefButS(block, TOG|BIT|0, B_NOP,"Backbuf",    10, 94, 80, 20, &G.scene->r.bufflag, 0, 0, 0, 0, "Enable/Disable use of Backbuf image");        
1025         uiDefButI(block, TOG|BIT|19, B_NOP,"Threads",   10, 68, 80, 20, &G.scene->r.mode, 0, 0, 0, 0, "Enable/Disable render in two threads");  
1026         uiBlockSetCol(block, TH_AUTO);
1027                 
1028         uiBlockBeginAlign(block);
1029         for(b=2; b>=0; b--)
1030                 for(a=0; a<3; a++)
1031                         uiDefButS(block, TOG|BIT|(3*b+a), 800,"",       (short)(10+18*a),(short)(10+14*b),16,12, &G.winpos, 0, 0, 0, 0, "Render window placement on screen");
1032         uiBlockEndAlign(block);
1033
1034         uiBlockBeginAlign(block);
1035         uiDefButS(block, TOG|BIT|2, REDRAWVIEW3D, "Passepartout", 72, 30, 122, 20, &G.scene->r.scemode, 0.0, 0.0, 0, 0, "Draws darkened passepartout in camera view");
1036         uiDefButS(block, ROW, B_REDR, "DispWin",        72, 10, 60, 20, &G.displaymode, 0.0, (float)R_DISPLAYWIN, 0, 0, "Sets render output to display in a seperate window");
1037         uiDefButS(block, ROW, B_REDR, "DispView",       134, 10, 60, 20, &G.displaymode, 0.0, (float)R_DISPLAYVIEW, 0, 0, "Sets render output to display in 3D view");
1038         uiBlockEndAlign(block);
1039
1040         uiDefButS(block, TOG|BIT|4, 0, "Extensions", 205, 10, 105, 19, &G.scene->r.scemode, 0.0, 0.0, 0, 0, "Adds extensions to the output when rendering animations");
1041
1042         /* removed, for time being unified and normal render will use same gamma for blending (2.0) */
1043         //if (G.scene->r.mode & R_GAMMA) {
1044         //      uiDefButF(block, NUMSLI, 0,"Gamma:",            10, 68, 142, 20,
1045         //                       &(G.scene->r.gamma), 0.2, 5.0, B_GAMMASLI, 0,
1046         //                       "The gamma value for blending oversampled images (1.0 = no correction).");
1047         //}
1048 }
1049
1050 static void render_panel_render(void)
1051 {
1052         uiBlock *block;
1053
1054
1055         block= uiNewBlock(&curarea->uiblocks, "render_panel_render", UI_EMBOSS, UI_HELV, curarea->win);
1056         if(uiNewPanel(curarea, block, "Render", "Render", 320, 0, 318, 204)==0) return;
1057
1058         uiBlockBeginAlign(block);
1059         uiDefBut(block, BUT,B_DORENDER,"RENDER",        369, 164, 191,37, 0, 0, 0, 0, 0, "Start the rendering");
1060         /* yafray: on request, render engine menu is back again, and moved to Render panel */
1061         uiDefButS(block, MENU, B_SWITCHRENDER, "Rendering Engine %t|Blender Internal %x0|YafRay %x1", 
1062                                                                                                 369, 142, 191, 20, &G.scene->r.renderer, 0, 0, 0, 0, "Choose rendering engine");        
1063
1064         uiBlockBeginAlign(block);
1065         uiDefButI(block, TOG|BIT|0, 0, "OSA",           369,109,122,20,&G.scene->r.mode, 0, 0, 0, 0, "Enables Oversampling (Anti-aliasing)");
1066         uiDefButS(block, ROW,B_DIFF,"5",                        369,88,29,20,&G.scene->r.osa,2.0,5.0, 0, 0, "Sets oversample level to 5");
1067         uiDefButS(block, ROW,B_DIFF,"8",                        400,88,29,20,&G.scene->r.osa,2.0,8.0, 0, 0, "Sets oversample level to 8 (Recommended)");
1068         uiDefButS(block, ROW,B_DIFF,"11",                       431,88,29,20,&G.scene->r.osa,2.0,11.0, 0, 0, "Sets oversample level to 11");
1069         uiDefButS(block, ROW,B_DIFF,"16",                       462,88,29,20,&G.scene->r.osa,2.0,16.0, 0, 0, "Sets oversample level to 16");
1070         uiBlockEndAlign(block);
1071
1072         uiBlockBeginAlign(block);
1073         uiDefButI(block, TOG|BIT|14, 0, "MBLUR",        496,109,64,20,&G.scene->r.mode, 0, 0, 0, 0, "Enables Motion Blur calculation");
1074         uiDefButF(block, NUM,B_DIFF,"Bf:",                      496,88,64,20,&G.scene->r.blurfac, 0.01, 5.0, 10, 2, "Sets motion blur factor");
1075         uiBlockEndAlign(block);
1076
1077         uiBlockBeginAlign(block);
1078         uiDefButS(block, NUM,B_DIFF,"Xparts:",          369,46,95,29,&G.scene->r.xparts,1.0, 64.0, 0, 0, "Sets the number of horizontal parts to render image in (For panorama sets number of camera slices)");
1079         uiDefButS(block, NUM,B_DIFF,"Yparts:",          465,46,95,29,&G.scene->r.yparts,1.0, 64.0, 0, 0, "Sets the number of vertical parts to render image in");
1080         uiBlockEndAlign(block);
1081
1082         uiBlockBeginAlign(block);
1083         uiDefButS(block, ROW,800,"Sky",         369,13,35,20,&G.scene->r.alphamode,3.0,0.0, 0, 0, "Fill background with sky");
1084         uiDefButS(block, ROW,800,"Premul",      405,13,50,20,&G.scene->r.alphamode,3.0,1.0, 0, 0, "Multiply alpha in advance");
1085         uiDefButS(block, ROW,800,"Key",         456,13,35,20,&G.scene->r.alphamode,3.0,2.0, 0, 0, "Alpha and colour values remain unchanged");
1086         uiBlockEndAlign(block);
1087
1088         if(G.scene->r.mode & R_RAYTRACE)
1089                 uiDefButS(block, MENU, B_DIFF,"Octree resolution %t|64 %x64|128 %x128|256 %x256|512 %x512",     496,13,64,20,&G.scene->r.ocres,0.0,0.0, 0, 0, "Octree resolution for ray tracing");
1090
1091         uiBlockBeginAlign(block);
1092         uiDefButI(block, TOG|BIT|1,0,"Shadow",  565,172,60,29, &G.scene->r.mode, 0, 0, 0, 0, "Enable shadow calculation");
1093         uiDefButI(block, TOG|BIT|4,0,"EnvMap",  627,172,60,29, &G.scene->r.mode, 0, 0, 0, 0, "Enable environment map rendering");
1094         uiDefButI(block, TOG|BIT|10,0,"Pano",   565,142,40,29, &G.scene->r.mode, 0, 0, 0, 0, "Enable panorama rendering (output width is multiplied by Xparts)");
1095         uiDefButI(block, TOG|BIT|16,B_REDR,"Ray",606,142,40,29, &G.scene->r.mode, 0, 0, 0, 0, "Enable ray tracing");
1096         uiDefButI(block, TOG|BIT|8,0,"Radio",   647,142,40,29, &G.scene->r.mode, 0, 0, 0, 0, "Enable radiosity rendering");
1097         uiBlockEndAlign(block);
1098         
1099         uiBlockBeginAlign(block);
1100         uiDefButS(block, ROW,B_DIFF,"100%",                     565,109,122,20,&G.scene->r.size,1.0,100.0, 0, 0, "Set render size to defined size");
1101         uiDefButS(block, ROW,B_DIFF,"75%",                      565,88,40,20,&G.scene->r.size,1.0,75.0, 0, 0, "Set render size to 3/4 of defined size");
1102         uiDefButS(block, ROW,B_DIFF,"50%",                      606,88,40,20,&G.scene->r.size,1.0,50.0, 0, 0, "Set render size to 1/2 of defined size");
1103         uiDefButS(block, ROW,B_DIFF,"25%",                      647,88,40,20,&G.scene->r.size,1.0,25.0, 0, 0, "Set render size to 1/4 of defined size");
1104         uiBlockEndAlign(block);
1105
1106         uiBlockBeginAlign(block);
1107         uiDefButI(block, TOG|BIT|6,0,"Fields",  565,55,60,20,&G.scene->r.mode, 0, 0, 0, 0, "Enables field rendering");
1108         uiDefButI(block, TOG|BIT|13,0,"Odd",    627,55,39,20,&G.scene->r.mode, 0, 0, 0, 0, "Enables Odd field first rendering (Default: Even field)");
1109         uiDefButI(block, TOG|BIT|7,0,"X",               668,55,19,20,&G.scene->r.mode, 0, 0, 0, 0, "Disables time difference in field calculations");
1110         
1111         uiDefButI(block, TOG|BIT|17,0,"Gauss",  565,34,60,20, &G.scene->r.mode, 0, 0, 0, 0, "Enable Gaussian sampling filter for antialiasing");
1112         uiDefButF(block, NUM,B_DIFF,"",                 627,34,60,20,&G.scene->r.gauss,0.5, 1.5, 100, 2, "Sets the Gaussian filter size");
1113         
1114         uiDefButI(block, TOG|BIT|9,REDRAWVIEWCAM, "Border",     565,13,60,20, &G.scene->r.mode, 0, 0, 0, 0, "Render a small cut-out of the image");
1115         uiDefButI(block, TOG|BIT|2, B_REDR, "Gamma",    627,13,60,20, &G.scene->r.mode, 0, 0, 0, 0, "Enable gamma correction");
1116         uiBlockEndAlign(block);
1117
1118 }
1119
1120 static void render_panel_anim(void)
1121 {
1122         uiBlock *block;
1123
1124
1125         block= uiNewBlock(&curarea->uiblocks, "render_panel_anim", UI_EMBOSS, UI_HELV, curarea->win);
1126         if(uiNewPanel(curarea, block, "Anim", "Render", 640, 0, 318, 204)==0) return;
1127
1128
1129         uiDefBut(block, BUT,B_DOANIM,"ANIM",            692,142,192,47, 0, 0, 0, 0, 0, "Start rendering a sequence");
1130
1131         uiBlockSetCol(block, TH_BUT_SETTING1);
1132         uiBlockBeginAlign(block);
1133         uiDefButS(block, TOG|BIT|0, 0, "Do Sequence",692,114,192,20, &G.scene->r.scemode, 0, 0, 0, 0, "Enables sequence output rendering (Default: 3D rendering)");
1134         uiDefButS(block, TOG|BIT|1, 0, "Render Daemon",692,90,192,20, &G.scene->r.scemode, 0, 0, 0, 0, "Let external network render current scene");
1135         uiBlockEndAlign(block);
1136
1137         uiBlockSetCol(block, TH_AUTO);
1138         uiDefBut(block, BUT,B_PLAYANIM, "PLAY",692,40,94,33, 0, 0, 0, 0, 0, "Play animation of rendered images/avi (searches Pics: field)");
1139         uiDefButS(block, NUM, B_RTCHANGED, "rt:",789,40,95,33, &G.rt, -1000.0, 1000.0, 0, 0, "General testing/debug button");
1140
1141         uiBlockBeginAlign(block);
1142         uiDefButS(block, NUM,REDRAWSEQ,"Sta:",692,10,94,24, &G.scene->r.sfra,1.0,MAXFRAMEF, 0, 0, "The start frame of the animation");
1143         uiDefButS(block, NUM,REDRAWSEQ,"End:",789,10,95,24, &G.scene->r.efra,1.0,MAXFRAMEF, 0, 0, "The end  frame of the animation");
1144         uiBlockEndAlign(block);
1145 }
1146
1147 static void render_panel_format(void)
1148 {
1149         uiBlock *block;
1150         int yofs;
1151
1152
1153         block= uiNewBlock(&curarea->uiblocks, "render_panel_format", UI_EMBOSS, UI_HELV, curarea->win);
1154         if(uiNewPanel(curarea, block, "Format", "Render", 960, 0, 318, 204)==0) return;
1155         uiDefBlockBut(block, framing_render_menu, NULL, 
1156                                   "Game framing settings", 
1157                                   892, 169, 227, 20, "Display game framing settings");
1158         /* uiDefIconTextBlockBut(block, framing_render_menu, NULL, 
1159                                                    ICON_BLOCKBUT_CORNER, 
1160                                                    "Game framing settings", 
1161                                                    892, 169, 227, 20, 
1162                                                    "Display game framing settings"); */
1163
1164         uiBlockBeginAlign(block);
1165         uiDefButS(block, NUM,REDRAWVIEWCAM,"SizeX:",    892 ,136,112,27, &G.scene->r.xsch, 4.0, 10000.0, 0, 0, "The image width in pixels");
1166         uiDefButS(block, NUM,REDRAWVIEWCAM,"SizeY:",    1007,136,112,27, &G.scene->r.ysch, 4.0,10000.0, 0, 0, "The image height in scanlines");
1167         uiDefButS(block, NUM,REDRAWVIEWCAM,"AspX:",     892 ,114,112,20, &G.scene->r.xasp, 1.0,200.0, 0, 0, "The horizontal aspect ratio");
1168         uiDefButS(block, NUM,REDRAWVIEWCAM,"AspY:",     1007,114,112,20, &G.scene->r.yasp, 1.0,200.0, 0, 0, "The vertical aspect ratio");
1169         uiBlockEndAlign(block);
1170
1171         yofs = 54;
1172
1173 #ifdef __sgi
1174         yofs = 76;
1175         uiDefButS(block, NUM,B_DIFF,"MaxSize:", 892,32,165,20, &G.scene->r.maximsize, 0.0, 500.0, 0, 0, "Maximum size per frame to save in an SGI movie");
1176         uiDefButI(block, TOG|BIT|12,0,"Cosmo", 1059,32,60,20, &G.scene->r.mode, 0, 0, 0, 0, "Attempt to save SGI movies using Cosmo hardware");
1177 #endif
1178
1179         uiDefButS(block, MENU,B_FILETYPEMENU,imagetype_pup(),   892,yofs,174,20, &G.scene->r.imtype, 0, 0, 0, 0, "Images are saved in this file format");
1180         uiDefButI(block, TOG|BIT|11,B_DIFF, "Crop",          1068,yofs,51,20, &G.scene->r.mode, 0, 0, 0, 0, "Exclude border rendering from total image");
1181
1182         yofs -= 22;
1183
1184         if(G.scene->r.quality==0) G.scene->r.quality= 90;
1185
1186 #ifdef WITH_QUICKTIME
1187         if (G.scene->r.imtype == R_AVICODEC || G.scene->r.imtype == R_QUICKTIME) {
1188 #else /* WITH_QUICKTIME */
1189         if (0) {
1190 #endif
1191                 if(G.scene->r.imtype == R_QUICKTIME) {
1192 #ifdef WITH_QUICKTIME
1193 #if defined (_WIN32) || defined (__APPLE__)
1194                         //glColor3f(0.65, 0.65, 0.7);
1195                         //glRecti(892,yofs+46,892+225,yofs+45+20);
1196                         if(G.scene->r.qtcodecdata == NULL)
1197                                 uiDefBut(block, LABEL, 0, "Codec: not set",  892,yofs+44,225,20, 0, 0, 0, 0, 0, "");
1198                         else
1199                                 uiDefBut(block, LABEL, 0, G.scene->r.qtcodecdata->qtcodecname,  892,yofs+44,225,20, 0, 0, 0, 0, 0, "");
1200                         uiDefBut(block, BUT,B_SELECTCODEC, "Set codec",  892,yofs,112,20, 0, 0, 0, 0, 0, "Set codec settings for Quicktime");
1201 #endif
1202 #endif /* WITH_QUICKTIME */
1203                 } else {
1204 #ifdef _WIN32
1205                         //glColor3f(0.65, 0.65, 0.7);
1206                         //glRecti(892,yofs+46,892+225,yofs+45+20);
1207                         if(G.scene->r.avicodecdata == NULL)
1208                                 uiDefBut(block, LABEL, 0, "Codec: not set.",  892,yofs+43,225,20, 0, 0, 0, 0, 0, "");
1209                         else
1210                                 uiDefBut(block, LABEL, 0, avicodec_str(),  892,yofs+43,225,20, 0, 0, 0, 0, 0, "");
1211 #endif
1212                         uiDefBut(block, BUT,B_SELECTCODEC, "Set codec",  892,yofs,112,20, 0, 0, 0, 0, 0, "Set codec settings for AVI");
1213                 }
1214         } else {
1215                 uiDefButS(block, NUM,B_DIFF, "Quality:",           892,yofs,112,20, &G.scene->r.quality, 10.0, 100.0, 0, 0, "Quality setting for JPEG images, AVI Jpeg and SGI movies");
1216         }
1217         uiDefButS(block, NUM,REDRAWALL,"Frs/sec:",   1006,yofs,113,20, &G.scene->r.frs_sec, 1.0, 120.0, 100.0, 0, "Frames per second");
1218
1219
1220         uiBlockBeginAlign(block);
1221         uiDefButS(block, ROW,B_DIFF,"BW",                       892, 10,74,19, &G.scene->r.planes, 5.0,(float)R_PLANESBW, 0, 0, "Images are saved with BW (grayscale) data");
1222         uiDefButS(block, ROW,B_DIFF,"RGB",                  968, 10,74,19, &G.scene->r.planes, 5.0,(float)R_PLANES24, 0, 0, "Images are saved with RGB (color) data");
1223         uiDefButS(block, ROW,B_DIFF,"RGBA",                1044, 10,75,19, &G.scene->r.planes, 5.0,(float)R_PLANES32, 0, 0, "Images are saved with RGB and Alpha data (if supported)");
1224
1225         uiBlockBeginAlign(block);
1226         uiDefBut(block, BUT,B_PR_PAL, "PAL",            1146,170,100,18, 0, 0, 0, 0, 0, "Size preset: Image size - 720x576, Aspect ratio - 54x51, 25 fps");
1227         uiDefBut(block, BUT,B_PR_NTSC, "NTSC",          1146,150,100,18, 0, 0, 0, 0, 0, "Size preset: Image size - 720x480, Aspect ratio - 10x11, 30 fps");
1228         uiDefBut(block, BUT,B_PR_PRESET, "Default",     1146,130,100,18, 0, 0, 0, 0, 0, "Same as PAL, with render settings (OSA, Shadows, Fields)");
1229         uiDefBut(block, BUT,B_PR_PRV, "Preview",        1146,110,100,18, 0, 0, 0, 0, 0, "Size preset: Image size - 640x512, Render size 50%");
1230         uiDefBut(block, BUT,B_PR_PC, "PC",                      1146,90,100,18, 0, 0, 0, 0, 0, "Size preset: Image size - 640x480, Aspect ratio - 100x100");
1231         uiDefBut(block, BUT,B_PR_PAL169, "PAL 16:9",1146,70,100,18, 0, 0, 0, 0, 0, "Size preset: Image size - 720x576, Aspect ratio - 64x45");
1232         uiDefBut(block, BUT,B_PR_PANO, "PANO",          1146,50,100,18, 0, 0, 0, 0, 0, "Standard panorama settings");
1233         uiDefBut(block, BUT,B_PR_FULL, "FULL",          1146,30,100,18, 0, 0, 0, 0, 0, "Size preset: Image size - 1280x1024, Aspect ratio - 1x1");
1234         uiDefButI(block, TOG|BIT|15, B_REDR, "Unified Renderer", 1146,10,100,18,  &G.scene->r.mode, 0, 0, 0, 0, "Use the unified renderer.");
1235         uiBlockEndAlign(block);
1236 }
1237
1238
1239 /* yafray: global illumination options panel */
1240 static void render_panel_yafrayGI()
1241 {
1242         uiBlock *block;
1243
1244         block= uiNewBlock(&curarea->uiblocks, "render_panel_yafrayGI", UI_EMBOSS, UI_HELV, curarea->win);
1245         uiNewPanelTabbed("Render", "Render");
1246         if(uiNewPanel(curarea, block, "YafRay GI", "Render", 320, 0, 318, 204)==0) return;
1247
1248         // label to force a boundbox for buttons not to be centered
1249         uiDefBut(block, LABEL, 0, " ", 305,180,10,10, 0, 0, 0, 0, 0, "");
1250
1251         uiDefBut(block, LABEL, 0, "Method", 5,175,70,20, 0, 1.0, 0, 0, 0, "");
1252         uiDefButS(block, MENU, B_REDR, "GiMethod %t|None %x0|SkyDome %x1|Full %x2 |", 70,175,89,20, &G.scene->r.GImethod, 0, 0, 0, 0, "Global Illumination Method");
1253         uiDefBut(block, LABEL, 0, "Quality", 5,150,70,20, 0, 1.0, 0, 0, 0, "");
1254         uiDefButS(block, MENU, B_REDR, "GiQuality %t|None %x0|Low %x1|Medium %x2 |High %x3|Higher %x4|Best %x5|", 
1255                         70,150,89,20, &G.scene->r.GIquality, 0, 0, 0, 0, "Global Illumination Quality");
1256
1257         if (G.scene->r.GImethod>0) {
1258                 uiDefButF(block, NUM, B_DIFF, "EmitPwr:", 5,35,154,20, &G.scene->r.GIpower, 0.01, 100.0, 10, 0, "arealight, material emit and background intensity scaling, 1 is normal");
1259                 if (G.scene->r.GImethod==2) uiDefButF(block, NUM, B_DIFF, "GI Pwr:", 5,10,154,20, &G.scene->r.GIindirpower, 0.01, 100.0, 10, 0, "GI indirect lighting intensity scaling, 1 is normal");
1260         }
1261
1262         if (G.scene->r.GImethod==2) 
1263         {
1264                 if (G.scene->r.GIdepth==0) G.scene->r.GIdepth=2;
1265                 uiDefButI(block, NUM, B_DIFF, "Depth:", 180,175,110,20, &G.scene->r.GIdepth, 1.0, 100.0, 10, 10, "Number of bounces of the indirect light");
1266                 uiDefButI(block, NUM, B_DIFF, "CDepth:", 180,150,110,20, &G.scene->r.GIcausdepth, 1.0, 100.0, 10, 10, "Number of bounces inside objects (for caustics)");
1267                 uiDefButS(block,TOG|BIT|0, B_REDR, "Cache",70,125,89,20, &G.scene->r.GIcache, 0, 0, 0, 0, "Cache irradiance samples (faster)");
1268                 uiDefButS(block,TOG|BIT|0, B_REDR, "Photons",180,125,89,20, &G.scene->r.GIphotons, 0, 0, 0, 0, "Use global photons to help in GI");
1269                 if (G.scene->r.GIcache) 
1270                 {
1271                         uiDefBut(block, LABEL, 0, "Cache parameters:", 5,105,130,20, 0, 1.0, 0, 0, 0, "");
1272                         if (G.scene->r.GIshadowquality==0.0) G.scene->r.GIshadowquality=0.9;
1273                         uiDefButF(block, NUM, B_DIFF,"ShadQu:", 5,85,154,20,    &(G.scene->r.GIshadowquality), 0.01, 1.0 ,1,0, "Sets the shadow quality, keep it under 0.95 :-) ");
1274                         if (G.scene->r.GIpixelspersample==0) G.scene->r.GIpixelspersample=10;
1275                         uiDefButI(block, NUM, B_DIFF, "Prec:",  5,60,75,20, &G.scene->r.GIpixelspersample, 1, 50, 10, 10, "Maximum number of pixels without samples, the lower the better and slower");
1276                         if (G.scene->r.GIrefinement==0) G.scene->r.GIrefinement=1.0;
1277                         uiDefButF(block, NUM, B_DIFF, "Ref:", 84,60,75,20, &G.scene->r.GIrefinement, 0.001, 1.0, 1, 0, "Threshold to refine shadows EXPERIMENTAL. 1 = no refinement");
1278                 }
1279                 if (G.scene->r.GIphotons) 
1280                 {
1281                         uiDefBut(block, LABEL, 0, "Photon parameters:", 170,105,130,20, 0, 1.0, 0, 0, 0, "");
1282                         if(G.scene->r.GIphotoncount==0) G.scene->r.GIphotoncount=100000;
1283                         uiDefButI(block, NUM, B_DIFF, "Count:", 170,85,140,20, &G.scene->r.GIphotoncount, 
1284                                         0, 10000000, 10, 10, "Number of photons to shoot");
1285                         if(G.scene->r.GIphotonradius==0.0) G.scene->r.GIphotonradius=1.0;
1286                         uiDefButF(block, NUMSLI, B_DIFF,"Radius:", 170,60,140,20,       &(G.scene->r.GIphotonradius), 
1287                                         0.00001, 100.0 ,0,0, "Radius to search for photons to mix (blur)");
1288                         if(G.scene->r.GImixphotons==0) G.scene->r.GImixphotons=100;
1289                         uiDefButI(block, NUM, B_DIFF, "MixCount:", 170,35,140,20, &G.scene->r.GImixphotons, 
1290                                         0, 1000, 10, 10, "Number of photons to mix");
1291                         uiDefButS(block,TOG|BIT|0, B_REDR, "Tune Photons",170,10,140,20, &G.scene->r.GIdirect, 
1292                                         0, 0, 0, 0, "Show the photonmap directly in the render for tuning");
1293                 }
1294         }
1295 }
1296
1297 /* yafray: global  options panel */
1298 static void render_panel_yafrayGlobal()
1299 {
1300         uiBlock *block;
1301
1302         block= uiNewBlock(&curarea->uiblocks, "render_panel_yafrayGlobal", UI_EMBOSS, UI_HELV, curarea->win);
1303         uiNewPanelTabbed("Render", "Render");
1304         if(uiNewPanel(curarea, block, "YafRay", "Render", 320, 0, 318, 204)==0) return;
1305
1306         // label to force a boundbox for buttons not to be centered
1307         uiDefBut(block, LABEL, 0, " ", 305,180,10,10, 0, 0, 0, 0, 0, "");
1308
1309         uiDefButF(block, NUMSLI, B_DIFF,"Bi ", 5,35,150,20,     &(G.scene->r.YF_raybias), 
1310                                 0.0, 10.0 ,0,0, "Shadow ray bias to avoid self shadowing");
1311         uiDefButI(block, NUM, B_DIFF, "Raydepth ", 5,60,150,20,
1312                                 &G.scene->r.YF_raydepth, 1.0, 80.0, 10, 10, "Maximum render ray depth from the camera");
1313         uiDefButF(block, NUMSLI, B_DIFF, "Gam ", 5,10,150,20, &G.scene->r.YF_gamma, 0.001, 5.0, 0, 0, "Gamma correction, 1 is off");
1314         uiDefButF(block, NUMSLI, B_DIFF, "Exp ", 160,10,150,20,&G.scene->r.YF_exposure, 0.0, 10.0, 0, 0, "Exposure adjustment, 0 is off");
1315         
1316         uiDefButI(block, NUM, B_DIFF, "Processors:", 160,35,150,20,
1317                                 &G.scene->r.YF_numprocs, 1.0, 8.0, 10, 10, "Number of processors to use");
1318
1319         /*AA Settings*/
1320
1321         uiDefButS(block,TOGN|BIT|0, B_REDR, "Auto AA", 5,140,150,20, &G.scene->r.YF_AA, 
1322                                         0, 0, 0, 0, "Set AA using OSA and GI quality, disable for manual control");
1323         uiDefButS(block,TOGN|BIT|0, B_REDR, "xml", 175,140,75,20, &G.scene->r.YFexportxml,
1324                                         0, 0, 0, 0, "Export to an xml file and call yafray instead of plugin");
1325         if(G.scene->r.YF_AA){
1326                 uiDefButI(block, NUM, B_DIFF, "AA Passes ", 5,115,150,20, &G.scene->r.YF_AApasses, 0, 64, 10, 10, "Number of AA passes (0 is no AA)");
1327                 uiDefButI(block, NUM, B_DIFF, "AA Samples ", 160,115,150,20, &G.scene->r.YF_AAsamples, 0, 2048, 10, 10, "Number of samples per pass");
1328                 uiDefButF(block, NUMSLI, B_DIFF, "Psz ", 5,90,150,20, &G.scene->r.YF_AApixelsize, 1.0, 2.0, 0, 0, "AA pixel filter size");
1329                 uiDefButF(block, NUMSLI, B_DIFF, "Thr ", 160,90,150,20, &G.scene->r.YF_AAthreshold, 0.000001, 1.0, 0, 0, "AA threshold");
1330         }
1331 }
1332
1333 static void render_panel_sfx(void)
1334 {
1335         uiBlock *block;
1336         
1337         block= uiNewBlock(&curarea->uiblocks, "editing_panel_camera_dof", UI_EMBOSS, UI_HELV, curarea->win);
1338         uiNewPanelTabbed("Output", "Render");
1339         if(uiNewPanel(curarea, block, "Post Effects", "Render", 320, 0, 318, 204)==0) return;
1340         
1341         uiBlockBeginAlign(block);
1342         uiDefButI(block, TOG|BIT|20,B_SET_ZBLUR,"Zblur",        10,180,140,20,&G.scene->r.mode,0,0, 0, 0, "Apply blur based on depth values in z-buffer");
1343         uiDefButF(block, NUM,B_DIFF, "ZMin:",           10,160,140,20, &G.scene->r.zmin, 0.0, 1.0, 0, 0, "Specify the start distance with maximum blur");                               
1344         uiDefButF(block, NUM,B_DIFF, "Focus:",          10,140,140,20, &G.scene->r.focus, 0.0, 1.0, 0, 0, "Specify the focus distance (not blurred)");
1345         uiDefButF(block, NUM,B_DIFF, "Blur:",           10,120,140,20, &G.scene->r.zblur, 1.0, 100.0, 0, 0, "Specify the maximum blur radius"); 
1346         uiDefButF(block, NUM,B_DIFF, "Gamma:",          10,100,140,20, &G.scene->r.zgamma, 0.05, 2.0, 0, 0, "Use Gamma corrected addition of colors");
1347         uiDefButF(block, NUM,B_DIFF, "Sigma:",          10,80,140,20, &G.scene->r.zsigma, 1.0, 20.0, 0, 0, "Filter type control, higher value is stronger gaussian");
1348         
1349         /* Toon shading buttons */
1350         uiBlockBeginAlign(block);
1351         uiDefButI(block, TOG|BIT|5, B_SET_EDGE, "Edge", 160, 180, 150, 20, &G.scene->r.mode, 0, 0, 0, 0, "Enable Toon edge shading");
1352         uiDefBlockBut(block, edge_render_menu, NULL, "Edge Settings", 160, 160, 150, 20, "Display edge settings");
1353         
1354         /* postprocess render buttons */
1355         uiBlockBeginAlign(block);
1356         if(R.rectftot)
1357                 uiDefIconTextButI(block, TOG|BIT|18, B_NOP, ICON_IMAGE_DEHLT," Fbuf", 160, 130, 150, 20, &G.scene->r.mode, 0, 0, 0, 0, "Keep RGBA float buffer after render; buffer available");
1358         else
1359                 uiDefButI(block, TOG|BIT|18, 0,"Fbuf",          160, 130, 150, 20, &G.scene->r.mode, 0, 0, 0, 0, "Keep RGBA float buffer after render, no buffer available now");
1360         uiDefBlockBut(block, post_render_menu, NULL, "Post process", 160, 110, 150, 20, "Applies on RGBA floats while render or with Fbuf available");
1361         uiBlockEndAlign(block);
1362         
1363         /* Dither control */
1364         uiDefButF(block, NUM,B_DIFF, "Dither:",                 160,80,150,20, &G.scene->r.dither_intensity, 0.0, 2.0, 0, 0, "The amount of dithering noise present in the output image (0.0 = no dithering)");
1365         
1366 }
1367
1368
1369
1370 void render_panels()
1371 {
1372
1373         render_panel_output();
1374         render_panel_sfx();
1375         render_panel_render();
1376         render_panel_anim();
1377         render_panel_format();
1378         /* yafray: GI & Global panel, only available when yafray enabled for rendering */
1379         if (G.scene->r.renderer==R_YAFRAY) {
1380                 if (G.scene->r.YF_gamma==0.0) G.scene->r.YF_gamma=1.0;
1381                 if (G.scene->r.YF_raybias==0.0) G.scene->r.YF_raybias=0.001;
1382                 if (G.scene->r.YF_raydepth==0) G.scene->r.YF_raydepth=5;
1383                 if (G.scene->r.YF_AApixelsize==0.0) G.scene->r.YF_AApixelsize=1.5;
1384                 if (G.scene->r.YF_AAthreshold==0.0) G.scene->r.YF_AAthreshold=0.05;
1385                 if (G.scene->r.GIpower==0.0) G.scene->r.GIpower=1.0;
1386                 if (G.scene->r.GIindirpower==0.0) G.scene->r.GIindirpower=1.0;
1387                 render_panel_yafrayGlobal();
1388                 render_panel_yafrayGI();
1389         }
1390
1391 }
1392
1393 /* --------------------------------------------- */
1394
1395 void anim_panels()
1396 {
1397         uiBlock *block;
1398
1399         block= uiNewBlock(&curarea->uiblocks, "anim_panel", UI_EMBOSS, UI_HELV, curarea->win);
1400         if(uiNewPanel(curarea, block, "Anim", "Anim", 0, 0, 318, 204)==0) return;
1401
1402         uiDefButS(block, NUM,REDRAWSEQ,"Sta:",  320,17,93,27,&G.scene->r.sfra,1.0,MAXFRAMEF, 0, 0, "Specify the start frame of the animation");
1403         uiDefButS(block, NUM,REDRAWSEQ,"End:",  416,17,95,27,&G.scene->r.efra,1.0,MAXFRAMEF, 0, 0, "Specify the end frame of the animation");
1404
1405         uiDefButS(block, NUM,B_FRAMEMAP,"Map Old:",     320,69,93,22,&G.scene->r.framapto,1.0,900.0, 0, 0, "Specify old map value in frames");
1406         uiDefButS(block, NUM,B_FRAMEMAP,"Map New:",     416,69,95,22,&G.scene->r.images,1.0,900.0, 0, 0, "Specify new map value in frames");
1407
1408         uiDefButS(block, NUM,REDRAWSEQ,"Frs/sec:",   320,47,93,19, &G.scene->r.frs_sec, 1.0, 120.0, 100.0, 0, "Frames per second");
1409
1410         uiDefButS(block, TOG|BIT|1, B_SOUND_CHANGED, "Sync",    416,47,95,19, &G.scene->audio.flag, 0, 0, 0, 0, "Use sample clock for syncing animation to audio");
1411
1412
1413 }
1414
1415 /* --------------------------------------------- */
1416
1417 void sound_panels()
1418 {
1419         bSound *sound;
1420
1421         sound = G.buts->lockpoin;
1422
1423         sound_panel_sound(sound);
1424         sound_panel_listener();
1425         sound_panel_sequencer();
1426 }
1427
1428
1429