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