~ubuntu-branches/ubuntu/maverick/blender/maverick

« back to all changes in this revision

Viewing changes to source/creator/creator.c

  • Committer: Bazaar Package Importer
  • Author(s): Khashayar Naderehvandi, Khashayar Naderehvandi, Alessio Treglia
  • Date: 2009-01-22 16:53:59 UTC
  • mfrom: (14.1.1 experimental)
  • Revision ID: james.westby@ubuntu.com-20090122165359-v0996tn7fbit64ni
Tags: 2.48a+dfsg-1ubuntu1
[ Khashayar Naderehvandi ]
* Merge from debian experimental (LP: #320045), Ubuntu remaining changes:
  - Add patch correcting header file locations.
  - Add libvorbis-dev and libgsm1-dev to Build-Depends.
  - Use avcodec_decode_audio2() in source/blender/src/hddaudio.c

[ Alessio Treglia ]
* Add missing previous changelog entries.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * $Id: creator.c 14710 2008-05-06 18:57:24Z campbellbarton $
 
2
 * $Id: creator.c 17109 2008-10-19 06:12:11Z campbellbarton $
3
3
 *
4
4
 * ***** BEGIN GPL LICENSE BLOCK *****
5
5
 *
70
70
#include "BLO_writefile.h"
71
71
#include "BLO_readfile.h"
72
72
 
73
 
#include "BDR_drawmesh.h"
74
 
 
75
73
#include "IMB_imbuf.h"  // for quicktime_init
76
74
 
77
75
#include "BPY_extern.h"
78
76
 
79
77
#include "RE_pipeline.h"
80
78
 
 
79
#include "GPU_draw.h"
 
80
#include "GPU_extensions.h"
 
81
 
81
82
#include "playanim_ext.h"
82
83
#include "mydevice.h"
83
84
#include "nla.h"
107
108
#endif
108
109
 
109
110
/*      Local Function prototypes */
110
 
static void print_help();
111
 
static void print_version();
 
111
static void print_help(void);
 
112
static void print_version(void);
112
113
 
113
114
 
114
115
/* defined in ghostwinlay and winlay, we can't include carbon here, conflict with DNA */
128
129
char btempdir[FILE_MAXDIR+FILE_MAXFILE];
129
130
 
130
131
/* Initialise callbacks for the modules that need them */
131
 
void setCallbacks(void); 
 
132
static void setCallbacks(void); 
132
133
 
133
134
#if defined(__sgi) || defined(__alpha__)
134
135
static void fpe_handler(int sig)
195
196
        printf ("    (formats that can be compiled into blender, not available on all systems)\n");
196
197
        printf ("    \tHDR TIFF EXR MULTILAYER MPEG AVICODEC QUICKTIME CINEON DPX DDS\n");
197
198
        printf ("    -x <bool>\tSet option to add the file extension to the end of the file.\n");
198
 
        printf ("    -t <threads>\tUse amount of <threads> for rendering.\n");
 
199
        printf ("    -t <threads>\tUse amount of <threads> for rendering (background mode only).\n");
199
200
        printf ("      [1-8], 0 for systems processor count.\n");
200
201
        printf ("\nAnimation playback options:\n");
201
202
        printf ("  -a <file(s)>\tPlayback <file(s)>, only operates this way when -b is not used.\n");
202
203
        printf ("    -p <sx> <sy>\tOpen with lower left corner at <sx>, <sy>\n");
203
204
        printf ("    -m\t\tRead from disk (Don't buffer)\n");
204
205
        printf ("    -f <fps> <fps-base>\t\tSpecify FPS to start with\n");
 
206
        printf ("    -j <frame>\tSet frame step to <frame>\n");
205
207
                                
206
208
        printf ("\nWindow options:\n");
207
209
        printf ("  -w\t\tForce opening with borders (default)\n");
218
220
        printf ("\nMisc options:\n");
219
221
        printf ("  -d\t\tTurn debugging on\n");
220
222
        printf ("  -noaudio\tDisable audio on systems that support audio\n");
 
223
        printf ("  -nojoystick\tDisable joystick support\n");
 
224
        printf ("  -noglsl\tDisable GLSL shading\n");
221
225
        printf ("  -h\t\tPrint this help text\n");
222
 
        printf ("  -y\t\tDisable script links, use -Y to find out why its -y\n");
 
226
        printf ("  -y\t\tDisable automatic python script execution (scriptlinks, pydrivers, pyconstraints, pynodes)\n");
223
227
        printf ("  -P <filename>\tRun the given Python script (filename or Blender Text)\n");
224
228
#ifdef WIN32
225
229
        printf ("  -R\t\tRegister .blend extension\n");
233
237
        printf ("  $TEMP\t\tStore temporary files here.\n");
234
238
#else
235
239
        printf ("  $TMP or $TMPDIR\tStore temporary files here.\n");
 
240
        printf ("  $BF_TIFF_LIB\t\tUse an alternative libtiff.so for loading tiff image files.\n");
 
241
#endif
 
242
#ifndef DISABLE_SDL
236
243
        printf ("  $SDL_AUDIODRIVER\tLibSDL audio driver - alsa, esd, alsa, dma.\n");
237
 
        printf ("  $BF_TIFF_LIB\t\tUse an alternative libtiff.so for loading tiff image files.\n");
238
244
#endif
239
245
        printf ("  $IMAGEEDITOR\t\tImage editor executable, launch with the IKey from the file selector.\n");
240
246
        printf ("  $WINEDITOR\t\tText editor executable, launch with the EKey from the file selector.\n");
267
273
 
268
274
int main(int argc, char **argv)
269
275
{
270
 
        int a, i, stax=0, stay=0, sizx, sizy, scr_init = 0;
 
276
        int a, i, stax, stay, sizx, sizy, scr_init = 0;
271
277
        SYS_SystemHandle syshandle;
272
278
 
273
279
#if defined(WIN32) || defined (__linux__)
301
307
                        setprefsize(left +10,scr_y - bottom +10,right-left -20,bottom - 64, 0);
302
308
 
303
309
        } else {
304
 
                                winlay_get_screensize(&scr_x, &scr_y);
 
310
                        winlay_get_screensize(&scr_x, &scr_y);
305
311
 
306
 
                /* 40 + 684 + (headers) 22 + 22 = 768, the powerbook screen height */
307
 
                setprefsize(120, 40, 850, 684, 0);
 
312
                        /* 40 + 684 + (headers) 22 + 22 = 768, the powerbook screen height */
 
313
                        setprefsize(120, 40, 850, 684, 0);
308
314
        }
309
315
    
310
316
                winlay_process_events(0);
322
328
#ifdef __linux__
323
329
    #ifdef __alpha__
324
330
        signal (SIGFPE, fpe_handler);
325
 
    #else
326
 
        if ( getenv("SDL_AUDIODRIVER") == NULL) {
327
 
                setenv("SDL_AUDIODRIVER", "alsa", 1);
328
 
        }
329
331
    #endif
330
332
#endif
331
333
#if defined(__sgi)
377
379
                else if(argv[a][0] == '-') {
378
380
                        switch(argv[a][1]) {
379
381
                        case 'a': /* -b was not given, play an animation */
 
382
                                
 
383
                                /* exception here, see below, it probably needs happens after qt init? */
 
384
                                libtiff_init();
 
385
 
380
386
                                playanim(argc-1, argv+1);
381
387
                                exit(0);
382
388
                                break;
424
430
 
425
431
        /* for all platforms, even windos has it! */
426
432
        if(G.background) signal(SIGINT, blender_esc);   /* ctrl c out bg render */
427
 
 
 
433
        
428
434
        /* background render uses this font too */
429
435
        BKE_font_register_builtin(datatoc_Bfont, datatoc_Bfont_size);
430
436
        
431
437
        init_def_material();
432
438
 
433
 
        winlay_get_screensize(&sizx, &sizy);
434
 
        stax=0;
435
 
        stay=0;
436
 
 
437
439
        if(G.background==0) {
 
440
                winlay_get_screensize(&sizx, &sizy);
 
441
                stax=0;
 
442
                stay=0;
 
443
 
438
444
                for(a=1; a<argc; a++) {
439
445
                        if(argv[a][0] == '-') {
440
446
                                switch(argv[a][1]) {
492
498
                                                audio = 0;
493
499
                                                if (G.f & G_DEBUG) printf("setting audio to: %d\n", audio);
494
500
                                        }
 
501
                                        if (BLI_strcasecmp(argv[a], "-nojoystick") == 0) {
 
502
                                                /**
 
503
                                                        don't initialize joysticks if user doesn't want to use joysticks
 
504
                                                        failed joystick initialization delays over 5 seconds, before game engine start
 
505
                                                */
 
506
                                                SYS_WriteCommandLineInt(syshandle,"nojoystick",1);
 
507
                                                if (G.f & G_DEBUG) printf("disabling nojoystick\n");
 
508
                                        }
 
509
                                        if (BLI_strcasecmp(argv[a], "-noglsl") == 0)
 
510
                                                GPU_extensions_disable();
495
511
                                        break;
496
512
                                }
497
513
                        }
512
528
                
513
529
                BLI_where_is_temp( btempdir, 1 ); /* call after loading the .B.blend so we can read U.tempdir */
514
530
 
 
531
#ifndef DISABLE_SDL
 
532
#ifdef __linux__
 
533
                /* On linux the default SDL driver dma often would not play
 
534
                 * use alsa if none is set */
 
535
                if ( getenv("SDL_AUDIODRIVER") == NULL) {
 
536
                        setenv("SDL_AUDIODRIVER", "alsa", 1);
 
537
                }
 
538
#endif
 
539
#endif
515
540
        }
516
541
        else {
517
542
                BPY_start_python(argc, argv);
600
625
                                                        /* doMipMap */
601
626
                                                        if (!strcmp(argv[a],"nomipmap"))
602
627
                                                        {
603
 
                                                                set_mipmap(0); //doMipMap = 0;
 
628
                                                                GPU_set_mipmap(0); //doMipMap = 0;
604
629
                                                        }
605
630
                                                        /* linearMipMap */
606
631
                                                        if (!strcmp(argv[a],"linearmipmap"))
607
632
                                                        {
608
 
                                                                set_linear_mipmap(1); //linearMipMap = 1;
 
633
                                                                GPU_set_linear_mipmap(1); //linearMipMap = 1;
609
634
                                                        }
610
635
 
611
636
 
619
644
                                        if (a < argc) {
620
645
                                                int frame= MIN2(MAXFRAME, MAX2(1, atoi(argv[a])));
621
646
                                                Render *re= RE_NewRender(G.scene->id.name);
622
 
                                                RE_BlenderAnim(re, G.scene, frame, frame);
 
647
 
 
648
                                                if (G.f & G_DOSCRIPTLINKS)
 
649
                                                        BPY_do_all_scripts(SCRIPT_RENDER, 0);
 
650
 
 
651
                                                RE_BlenderAnim(re, G.scene, frame, frame, G.scene->frame_step);
 
652
 
 
653
                                                BPY_do_all_scripts(SCRIPT_POSTRENDER, 0);
623
654
                                        }
624
655
                                } else {
625
656
                                        printf("\nError: no blend loaded. cannot use '-f'.\n");
628
659
                        case 'a':
629
660
                                if (G.scene) {
630
661
                                        Render *re= RE_NewRender(G.scene->id.name);
631
 
                                        RE_BlenderAnim(re, G.scene, G.scene->r.sfra, G.scene->r.efra);
 
662
 
 
663
                                        if (G.f & G_DOSCRIPTLINKS)
 
664
                                                BPY_do_all_scripts(SCRIPT_RENDER, 1);
 
665
 
 
666
                                        RE_BlenderAnim(re, G.scene, G.scene->r.sfra, G.scene->r.efra, G.scene->frame_step);
 
667
 
 
668
                                        if (G.f & G_DOSCRIPTLINKS)
 
669
                                                BPY_do_all_scripts(SCRIPT_POSTRENDER, 1);
632
670
                                } else {
633
671
                                        printf("\nError: no blend loaded. cannot use '-a'.\n");
634
672
                                }
656
694
                                        printf("\nError: no blend loaded. cannot use '-e'.\n");
657
695
                                }
658
696
                                break;
 
697
                        case 'j':
 
698
                                a++;
 
699
                                if(G.scene) {
 
700
                                        int fstep= MIN2(MAXFRAME, MAX2(1, atoi(argv[a])));
 
701
                                        if (a < argc) (G.scene->frame_step) = fstep;
 
702
                                } else {
 
703
                                        printf("\nError: no blend loaded. cannot use '-j'.\n");
 
704
                                }
 
705
                                break;
659
706
                        case 'P':
660
707
                                a++;
661
708
                                if (a < argc) {
723
770
                                a++;
724
771
                                if(G.background) {
725
772
                                        RE_set_max_threads(atoi(argv[a]));
 
773
                                } else {
 
774
                                        printf("Warning: threads can only be set in background mode\n");
726
775
                                }
727
776
                                break;
728
777
                        case 'x': /* extension */
748
797
                else {
749
798
                        
750
799
                        /* Make the path absolute because its needed for relative linked blends to be found */
751
 
                        int abs = 0;
752
 
                        int filelen;
753
 
                        char cwd[FILE_MAXDIR + FILE_MAXFILE];
754
800
                        char filename[FILE_MAXDIR + FILE_MAXFILE];
755
 
                        cwd[0] = filename[0] = '\0';
756
801
                        
757
802
                        BLI_strncpy(filename, argv[a], sizeof(filename));
758
 
                        filelen = strlen(filename);
759
 
                        
760
 
                        /* relative path checks, could do more tests here... */
761
 
#ifdef WIN32
762
 
                        /* Account for X:/ and X:\ - should be enough */
763
 
                        if (filelen >= 3 && filename[1] == ':' && (filename[2] == '\\' || filename[2] == '/'))
764
 
                                abs = 1;
765
 
#else
766
 
                        if (filelen >= 2 && filename[0] == '/')
767
 
                                abs = 1 ;
768
 
#endif
769
 
                        if (!abs) {
770
 
                                BLI_getwdN(cwd); /* incase the full path to the blend isnt used */
771
 
                                
772
 
                                if (cwd[0] == '\0') {
773
 
                                        printf(
774
 
                                        "Could not get the current working directory - $PWD for an unknown reason.\n\t"
775
 
                                        "Relative linked files will not load if the entire blend path is not used.\n\t"
776
 
                                        "The 'Play' button may also fail.\n"
777
 
                                        );
778
 
                                } else {
779
 
                                        /* uses the blend path relative to cwd important for loading relative linked files.
780
 
                                        *
781
 
                                        * cwd should contain c:\ etc on win32 so the relbase can be NULL
782
 
                                        * relbase being NULL also prevents // being misunderstood as relative to the current
783
 
                                        * blend file which isnt a feature we want to use in this case since were dealing
784
 
                                        * with a path from the command line, rather then from inside Blender */
785
 
                                        
786
 
                                        BLI_make_file_string(NULL, filename, cwd, argv[a]); 
787
 
                                }
788
 
                        }
 
803
                        BLI_convertstringcwd(filename);
789
804
                        
790
805
                        if (G.background) {
791
806
                                int retval = BKE_read_file(filename, NULL);
831
846
        fflush(stderr);
832
847
}
833
848
 
834
 
void setCallbacks(void)
 
849
static void setCallbacks(void)
835
850
{
836
851
        /* Error output from the alloc routines: */
837
852
        MEM_set_error_callback(mem_error_cb);