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