70
70
#include "BLO_writefile.h"
71
71
#include "BLO_readfile.h"
73
#include "BDR_drawmesh.h"
75
73
#include "IMB_imbuf.h" // for quicktime_init
77
75
#include "BPY_extern.h"
79
77
#include "RE_pipeline.h"
80
#include "GPU_extensions.h"
81
82
#include "playanim_ext.h"
82
83
#include "mydevice.h"
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);
114
115
/* defined in ghostwinlay and winlay, we can't include carbon here, conflict with DNA */
128
129
char btempdir[FILE_MAXDIR+FILE_MAXFILE];
130
131
/* Initialise callbacks for the modules that need them */
131
void setCallbacks(void);
132
static void setCallbacks(void);
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");
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");
225
229
printf (" -R\t\tRegister .blend extension\n");
233
237
printf (" $TEMP\t\tStore temporary files here.\n");
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");
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");
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");
268
274
int main(int argc, char **argv)
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;
273
279
#if defined(WIN32) || defined (__linux__)
301
307
setprefsize(left +10,scr_y - bottom +10,right-left -20,bottom - 64, 0);
304
winlay_get_screensize(&scr_x, &scr_y);
310
winlay_get_screensize(&scr_x, &scr_y);
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);
310
316
winlay_process_events(0);
324
330
signal (SIGFPE, fpe_handler);
326
if ( getenv("SDL_AUDIODRIVER") == NULL) {
327
setenv("SDL_AUDIODRIVER", "alsa", 1);
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 */
383
/* exception here, see below, it probably needs happens after qt init? */
380
386
playanim(argc-1, argv+1);
425
431
/* for all platforms, even windos has it! */
426
432
if(G.background) signal(SIGINT, blender_esc); /* ctrl c out bg render */
428
434
/* background render uses this font too */
429
435
BKE_font_register_builtin(datatoc_Bfont, datatoc_Bfont_size);
431
437
init_def_material();
433
winlay_get_screensize(&sizx, &sizy);
437
439
if(G.background==0) {
440
winlay_get_screensize(&sizx, &sizy);
438
444
for(a=1; a<argc; a++) {
439
445
if(argv[a][0] == '-') {
440
446
switch(argv[a][1]) {
493
499
if (G.f & G_DEBUG) printf("setting audio to: %d\n", audio);
501
if (BLI_strcasecmp(argv[a], "-nojoystick") == 0) {
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
506
SYS_WriteCommandLineInt(syshandle,"nojoystick",1);
507
if (G.f & G_DEBUG) printf("disabling nojoystick\n");
509
if (BLI_strcasecmp(argv[a], "-noglsl") == 0)
510
GPU_extensions_disable();
513
529
BLI_where_is_temp( btempdir, 1 ); /* call after loading the .B.blend so we can read U.tempdir */
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);
517
542
BPY_start_python(argc, argv);
601
626
if (!strcmp(argv[a],"nomipmap"))
603
set_mipmap(0); //doMipMap = 0;
628
GPU_set_mipmap(0); //doMipMap = 0;
605
630
/* linearMipMap */
606
631
if (!strcmp(argv[a],"linearmipmap"))
608
set_linear_mipmap(1); //linearMipMap = 1;
633
GPU_set_linear_mipmap(1); //linearMipMap = 1;
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);
648
if (G.f & G_DOSCRIPTLINKS)
649
BPY_do_all_scripts(SCRIPT_RENDER, 0);
651
RE_BlenderAnim(re, G.scene, frame, frame, G.scene->frame_step);
653
BPY_do_all_scripts(SCRIPT_POSTRENDER, 0);
625
656
printf("\nError: no blend loaded. cannot use '-f'.\n");
630
661
Render *re= RE_NewRender(G.scene->id.name);
631
RE_BlenderAnim(re, G.scene, G.scene->r.sfra, G.scene->r.efra);
663
if (G.f & G_DOSCRIPTLINKS)
664
BPY_do_all_scripts(SCRIPT_RENDER, 1);
666
RE_BlenderAnim(re, G.scene, G.scene->r.sfra, G.scene->r.efra, G.scene->frame_step);
668
if (G.f & G_DOSCRIPTLINKS)
669
BPY_do_all_scripts(SCRIPT_POSTRENDER, 1);
633
671
printf("\nError: no blend loaded. cannot use '-a'.\n");
656
694
printf("\nError: no blend loaded. cannot use '-e'.\n");
700
int fstep= MIN2(MAXFRAME, MAX2(1, atoi(argv[a])));
701
if (a < argc) (G.scene->frame_step) = fstep;
703
printf("\nError: no blend loaded. cannot use '-j'.\n");
750
799
/* Make the path absolute because its needed for relative linked blends to be found */
753
char cwd[FILE_MAXDIR + FILE_MAXFILE];
754
800
char filename[FILE_MAXDIR + FILE_MAXFILE];
755
cwd[0] = filename[0] = '\0';
757
802
BLI_strncpy(filename, argv[a], sizeof(filename));
758
filelen = strlen(filename);
760
/* relative path checks, could do more tests here... */
762
/* Account for X:/ and X:\ - should be enough */
763
if (filelen >= 3 && filename[1] == ':' && (filename[2] == '\\' || filename[2] == '/'))
766
if (filelen >= 2 && filename[0] == '/')
770
BLI_getwdN(cwd); /* incase the full path to the blend isnt used */
772
if (cwd[0] == '\0') {
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"
779
/* uses the blend path relative to cwd important for loading relative linked files.
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 */
786
BLI_make_file_string(NULL, filename, cwd, argv[a]);
803
BLI_convertstringcwd(filename);
790
805
if (G.background) {
791
806
int retval = BKE_read_file(filename, NULL);