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