4 * ***** BEGIN GPL LICENSE BLOCK *****
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.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
21 * All rights reserved.
23 * The Original Code is: all of this file.
25 * Contributor(s): none yet.
27 * ***** END GPL LICENSE BLOCK *****
33 /* for setuid / getuid */
35 #include <sys/types.h>
39 /* This little block needed for linking to Blender... */
41 #include "MEM_guardedalloc.h"
44 #include "BLI_winstuff.h"
47 #include "GEN_messaging.h"
50 #include "DNA_scene_types.h"
52 #include "BLI_blenlib.h"
53 #include "blendef.h" /* for MAXFRAME */
56 #include "BKE_utildefines.h"
57 #include "BKE_blender.h"
59 #include "BKE_global.h"
61 #include "BKE_material.h"
62 #include "BKE_packedFile.h"
63 #include "BKE_scene.h"
67 #include "BIF_graphics.h"
68 #include "BIF_mainqueue.h"
69 #include "BIF_graphics.h"
70 #include "BIF_editsound.h"
71 #include "BIF_usiblender.h"
72 #include "BIF_drawscene.h" /* set_scene() */
73 #include "BIF_screen.h" /* waitcursor and more */
74 #include "BIF_usiblender.h"
75 #include "BIF_toolbox.h"
77 #include "BLO_writefile.h"
78 #include "BLO_readfile.h"
80 #include "IMB_imbuf.h" // for quicktime_init
82 #ifndef DISABLE_PYTHON
83 #include "BPY_extern.h"
86 #include "RE_pipeline.h"
89 #include "GPU_extensions.h"
91 #include "playanim_ext.h"
96 /* for passing information between creator and gameengine */
97 #include "SYS_System.h"
102 # include <sys/types.h>
103 # include <floatingpoint.h>
104 # include <sys/rtprio.h>
108 #include "binreloc.h"
113 extern char * build_date;
114 extern char * build_time;
115 extern char * build_platform;
116 extern char * build_type;
119 /* Local Function prototypes */
120 static void print_help(void);
121 static void print_version(void);
124 /* defined in ghostwinlay and winlay, we can't include carbon here, conflict with DNA */
126 extern int checkAppleVideoCard(void);
127 extern void getMacAvailableBounds(short *top, short *left, short *bottom, short *right);
128 extern void winlay_get_screensize(int *width_r, int *height_r);
129 extern void winlay_process_events(int wait_for_event);
133 /* for the callbacks: */
135 extern int pluginapi_force_ref(void); /* from blenpluginapi:pluginapi.c */
137 char bprogname[FILE_MAXDIR+FILE_MAXFILE]; /* from blenpluginapi:pluginapi.c */
138 char btempdir[FILE_MAXDIR+FILE_MAXFILE];
140 /* Initialise callbacks for the modules that need them */
141 static void setCallbacks(void);
143 #if defined(__sgi) || defined(__alpha__)
144 static void fpe_handler(int sig)
146 // printf("SIGFPE trapped\n");
150 /* handling ctrl-c event in console */
151 static void blender_esc(int sig)
153 static int count = 0;
155 G.afbreek = 1; /* forces render loop to read queue, not sure if its needed */
159 printf("\nBlender killed\n");
162 printf("\nSent an internal break event. Press ^C again to kill Blender\n");
167 static void print_version(void)
170 printf ("Blender %d.%02d (sub %d) Build\n", G.version/100, G.version%100, BLENDER_SUBVERSION);
171 printf ("\tbuild date: %s\n", build_date);
172 printf ("\tbuild time: %s\n", build_time);
173 printf ("\tbuild revision: %s\n", build_rev);
174 printf ("\tbuild platform: %s\n", build_platform);
175 printf ("\tbuild type: %s\n", build_type);
177 printf ("Blender %d.%02d (sub %d) Build\n", G.version/100, G.version%100, BLENDER_SUBVERSION);
181 static void print_help(void)
183 printf ("Blender %d.%02d (sub %d) Build\n", G.version/100, G.version%100, BLENDER_SUBVERSION);
184 printf ("Usage: blender [args ...] [file] [args ...]\n");
185 printf ("\nRender options:\n");
186 printf (" -b <file>\tRender <file> in background (doesn't load the user defaults .B.blend file)\n");
187 printf (" -a render frames from start to end (inclusive), only works when used after -b\n");
188 printf (" -S <name>\tSet scene <name>\n");
189 printf (" -f <frame>\tRender frame <frame> and save it\n");
190 printf (" -s <frame>\tSet start to frame <frame> (use before the -a argument)\n");
191 printf (" -e <frame>\tSet end to frame <frame> (use before the -a argument)\n");
192 printf (" -o <path>\tSet the render path and file name.\n");
193 printf (" Use // at the start of the path to\n");
194 printf (" render relative to the blend file.\n");
195 printf (" The # characters are replaced by the frame number, and used to define zero padding.\n");
196 printf (" ani_##_test.png becomes ani_01_test.png\n");
197 printf (" test-######.png becomes test-000001.png\n");
198 printf (" When the filename has no #, The suffix #### is added to the filename\n");
199 printf (" The frame number will be added at the end of the filename.\n");
200 printf (" eg: blender -b foobar.blend -o //render_ -F PNG -x 1 -a\n");
201 printf ("\nFormat options:\n");
202 printf (" -F <format>\tSet the render format, Valid options are...\n");
203 printf (" \tTGA IRIS HAMX JPEG MOVIE IRIZ RAWTGA\n");
204 printf (" \tAVIRAW AVIJPEG PNG BMP FRAMESERVER\n");
205 printf (" (formats that can be compiled into blender, not available on all systems)\n");
206 printf (" \tHDR TIFF EXR MULTILAYER MPEG AVICODEC QUICKTIME CINEON DPX DDS\n");
207 printf (" -x <bool>\tSet option to add the file extension to the end of the file.\n");
208 printf (" -t <threads>\tUse amount of <threads> for rendering (background mode only).\n");
209 printf (" [1-8], 0 for systems processor count.\n");
210 printf ("\nAnimation playback options:\n");
211 printf (" -a <options> <file(s)>\tPlayback <file(s)>, only operates this way when -b is not used.\n");
212 printf (" -p <sx> <sy>\tOpen with lower left corner at <sx>, <sy>\n");
213 printf (" -m\t\tRead from disk (Don't buffer)\n");
214 printf (" -f <fps> <fps-base>\t\tSpecify FPS to start with\n");
215 printf (" -j <frame>\tSet frame step to <frame>\n");
217 printf ("\nWindow options:\n");
218 printf (" -w\t\tForce opening with borders (default)\n");
219 printf (" -W\t\tForce opening without borders\n");
220 printf (" -p <sx> <sy> <w> <h>\tOpen with lower left corner at <sx>, <sy>\n");
221 printf (" \tand width and height <w>, <h>\n");
222 printf ("\nGame Engine specific options:\n");
223 printf (" -g fixedtime\t\tRun on 50 hertz without dropping frames\n");
224 printf (" -g vertexarrays\tUse Vertex Arrays for rendering (usually faster)\n");
225 printf (" -g noaudio\t\tNo audio in Game Engine\n");
226 printf (" -g nomipmap\t\tNo Texture Mipmapping\n");
227 printf (" -g linearmipmap\tLinear Texture Mipmapping instead of Nearest (default)\n");
229 printf ("\nMisc options:\n");
230 printf (" -d\t\tTurn debugging on\n");
231 printf (" -noaudio\tDisable audio on systems that support audio\n");
232 printf (" -nojoystick\tDisable joystick support\n");
233 printf (" -noglsl\tDisable GLSL shading\n");
234 printf (" -h\t\tPrint this help text\n");
235 printf (" -y\t\tDisable automatic python script execution (scriptlinks, pydrivers, pyconstraints, pynodes)\n");
236 printf (" -P <filename>\tRun the given Python script (filename or Blender Text)\n");
238 printf (" -R\t\tRegister .blend extension\n");
240 printf (" -v\t\tPrint Blender version and exit\n");
241 printf (" --\t\tEnds option processing. Following arguments are \n");
242 printf (" \t\t passed unchanged. Access via Python's sys.argv\n");
243 printf ("\nEnvironment Variables:\n");
244 printf (" $HOME\t\t\tStore files such as .blender/ .B.blend .Bfs .Blog here.\n");
246 printf (" $TEMP\t\tStore temporary files here.\n");
248 printf (" $TMP or $TMPDIR\tStore temporary files here.\n");
249 printf (" $BF_TIFF_LIB\t\tUse an alternative libtiff.so for loading tiff image files.\n");
252 printf (" $SDL_AUDIODRIVER\tLibSDL audio driver - alsa, esd, alsa, dma.\n");
254 printf (" $IMAGEEDITOR\t\tImage editor executable, launch with the IKey from the file selector.\n");
255 printf (" $WINEDITOR\t\tText editor executable, launch with the EKey from the file selector.\n");
256 printf (" $PYTHONHOME\t\tPath to the python directory, eg. /usr/lib/python.\n");
257 printf ("\nNote: Arguments must be separated by white space. eg:\n");
258 printf (" \"blender -ba test.blend\"\n");
259 printf (" ...will ignore the 'a'\n");
260 printf (" \"blender -b test.blend -f8\"\n");
261 printf (" ...will ignore 8 because there is no space between the -f and the frame value\n");
262 printf ("Note: Arguments are executed in the order they are given. eg:\n");
263 printf (" \"blender -b test.blend -f 1 -o /tmp\"\n");
264 printf (" ...may not render to /tmp because '-f 1' renders before the output path is set\n");
265 printf (" \"blender -b -o /tmp test.blend -f 1\"\n");
266 printf (" ...may not render to /tmp because loading the blend file overwrites the output path that was set\n");
267 printf (" \"blender -b test.blend -o /tmp -f 1\" works as expected.\n\n");
271 double PIL_check_seconds_timer(void);
272 extern void winlay_get_screensize(int *width_r, int *height_r);
274 static void main_init_screen( void )
276 setscreen(G.curscreen);
278 if(G.main->scene.first==0) {
279 set_scene( add_scene("1") );
283 int main(int argc, char **argv)
285 int a, i, stax, stay, sizx, sizy, scr_init = 0;
286 SYS_SystemHandle syshandle;
288 #if defined(WIN32) || defined (__linux__)
301 /* patch to ignore argument finder gives us (pid?) */
302 if (argc==2 && strncmp(argv[1], "-psn_", 5)==0) {
303 extern int GHOST_HACK_getFirstFile(char buf[]);
304 static char firstfilebuf[512];
309 /* first let us check if we are hardware accelerated and with VRAM > 16 Mo */
311 if (checkAppleVideoCard()) {
312 short top, left, bottom, right;
314 winlay_get_screensize(&scr_x, &scr_y);
315 getMacAvailableBounds(&top, &left, &bottom, &right);
316 setprefsize(left +10,scr_y - bottom +10,right-left -20,bottom - 64, 0);
319 winlay_get_screensize(&scr_x, &scr_y);
321 /* 40 + 684 + (headers) 22 + 22 = 768, the powerbook screen height */
322 setprefsize(120, 40, 850, 684, 0);
325 winlay_process_events(0);
326 if (GHOST_HACK_getFirstFile(firstfilebuf)) {
328 argv[1]= firstfilebuf;
339 signal (SIGFPE, fpe_handler);
343 signal (SIGFPE, fpe_handler);
346 // copy path to executable in bprogname. playanim and creting runtimes
349 BLI_where_am_i(bprogname, argv[0]);
351 /* Hack - force inclusion of the plugin api functions,
352 * see blenpluginapi:pluginapi.c
354 pluginapi_force_ref();
358 initglobals(); /* blender.c */
360 syshandle = SYS_GetSystem();
361 GEN_init_messaging_system();
363 /* first test for background */
365 G.f |= G_DOSCRIPTLINKS; /* script links enabled by default */
367 for(a=1; a<argc; a++) {
369 /* Handle unix and windows style help requests */
370 if ((!strcmp(argv[a], "--help")) || (!strcmp(argv[a], "/?"))){
375 /* end argument processing after -- */
376 if (!strcmp( argv[a], "--")){
381 /* Handle long version request */
382 if (!strcmp(argv[a], "--version")){
387 /* Handle -* switches */
388 else if(argv[a][0] == '-') {
390 case 'a': /* -b was not given, play an animation */
392 /* exception here, see below, it probably needs happens after qt init? */
395 playanim(argc-1, argv+1);
405 G.f &= ~G_DOSCRIPTLINKS;
409 printf ("-y was used to disable script links because,\n");
410 printf ("\t-p being taken, Ton was of the opinion that Y\n");
411 printf ("\tlooked like a split (disabled) snake, and also\n");
412 printf ("\twas similar to a python's tongue (unproven).\n\n");
414 printf ("\tZr agreed because it gave him a reason to add a\n");
415 printf ("\tcompletely useless text into Blender.\n\n");
417 printf ("\tADDENDUM! Ton, in defense, found this picture of\n");
418 printf ("\tan Australian python, exhibiting her (his/its) forked\n");
419 printf ("\tY tongue. It could be part of an H Zr retorted!\n\n");
420 printf ("\thttp://www.users.bigpond.com/snake.man/\n");
437 setuid(getuid()); /* end superuser */
440 /* for all platforms, even windos has it! */
441 if(G.background) signal(SIGINT, blender_esc); /* ctrl c out bg render */
443 /* background render uses this font too */
444 BKE_font_register_builtin(datatoc_Bfont, datatoc_Bfont_size);
448 if(G.background==0) {
449 winlay_get_screensize(&sizx, &sizy);
453 for(a=1; a<argc; a++) {
454 if(argv[a][0] == '-') {
456 case 'p': /* prefsize */
458 printf ("-p requires four arguments\n");
469 G.windowstate = G_WINDOWSTATE_BORDER;
473 G.f |= G_DEBUG; /* std output printf's */
474 printf ("Blender %d.%02d (sub %d) Build\n", G.version/100, G.version%100, BLENDER_SUBVERSION);
475 MEM_set_memory_debug();
477 printf("Build: %s %s %s %s\n", build_date, build_time, build_platform, build_type);
479 #endif // NAN_BUILDINFO
480 for (i = 0; i < argc; i++) {
481 printf("argv[%d] = %s\n", i, argv[i]);
486 G.windowstate = G_WINDOWSTATE_BORDER;
489 /* XXX, fixme mein, borderless on OSX */
490 G.windowstate = G_WINDOWSTATE_FULLSCREEN;
493 /* Registering filetypes only makes sense on windows... */
495 RegisterBlendExtension(argv[0]);
500 if (BLI_strcasecmp(argv[a], "-noaudio") == 0|| BLI_strcasecmp(argv[a], "-nosound") == 0) {
502 notify the gameengine that no audio is wanted, even if the user didn't give
506 SYS_WriteCommandLineInt(syshandle,"noaudio",1);
508 if (G.f & G_DEBUG) printf("setting audio to: %d\n", audio);
510 if (BLI_strcasecmp(argv[a], "-nojoystick") == 0) {
512 don't initialize joysticks if user doesn't want to use joysticks
513 failed joystick initialization delays over 5 seconds, before game engine start
515 SYS_WriteCommandLineInt(syshandle,"nojoystick",1);
516 if (G.f & G_DEBUG) printf("disabling nojoystick\n");
518 if (BLI_strcasecmp(argv[a], "-noglsl") == 0)
519 GPU_extensions_disable();
525 if ( (G.windowstate == G_WINDOWSTATE_BORDER) || (G.windowstate == G_WINDOWSTATE_FULLSCREEN))
526 setprefsize(stax, stay, sizx, sizy, 0);
527 #ifndef DISABLE_PYTHON
528 BPY_start_python(argc, argv);
531 * NOTE: sound_init_audio() *must be* after start_python,
532 * at least on FreeBSD.
533 * added note (ton): i removed it altogether
536 BIF_init(); /* loads .B.blend */
538 BLI_where_is_temp( btempdir, 1 ); /* call after loading the .B.blend so we can read U.tempdir */
541 #if (defined(WIN32) || defined(WIN64)) && !defined(FREE_WINDOWS)
542 _putenv_s("SDL_VIDEODRIVER", "dummy");
544 setenv("SDL_VIDEODRIVER", "dummy", 1); /* initializing the video driver can cause crashes on some systems - Campbell */
547 /* On linux the default SDL driver dma often would not play
548 * use alsa if none is set */
549 if ( getenv("SDL_AUDIODRIVER") == NULL) {
550 setenv("SDL_AUDIODRIVER", "alsa", 1);
556 #ifndef DISABLE_PYTHON
557 BPY_start_python(argc, argv);
559 BLI_where_is_temp( btempdir, 0 ); /* call after loading the .B.blend so we can read U.tempdir */
561 // (ton) Commented out. I have no idea whats thisfor... will mail around!
562 // SYS_WriteCommandLineInt(syshandle,"noaudio",1);
564 // sound_init_audio();
565 // if (G.f & G_DEBUG) printf("setting audio to: %d\n", audio);
567 #ifndef DISABLE_PYTHON
569 * NOTE: the U.pythondir string is NULL until BIF_init() is executed,
570 * so we provide the BPY_ function below to append the user defined
571 * pythondir to Python's sys.path at this point. Simply putting
572 * BIF_init() before BPY_start_python() crashes Blender at startup.
573 * Update: now this function also inits the bpymenus, which also depend
576 BPY_post_start_python();
579 #ifdef WITH_QUICKTIME
583 #endif /* WITH_QUICKTIME */
585 /* dynamically load libtiff, if available */
587 if (!G.have_libtiff && (G.f & G_DEBUG)) {
588 printf("Unable to load: libtiff.\n");
589 printf("Try setting the BF_TIFF_LIB environment variable if you want this support.\n");
590 printf("Example: setenv BF_TIFF_LIB /usr/lib/libtiff.so\n");
593 /* OK we are ready for it */
595 for(a=1; a<argc; a++) {
596 if (G.afbreek==1) break;
598 if(argv[a][0] == '-') {
600 case '-': /* -- ends argument processing */
604 case 'p': /* prefsize */
611 gameengine parameters are automaticly put into system
612 -g [paramname = value]
616 -g maxvertexarraysize = 512
621 char* paramname = argv[a];
622 /* check for single value versus assignment */
623 if (a+1 < argc && (*(argv[a+1]) == '='))
630 SYS_WriteCommandLineString(syshandle,paramname,argv[a]);
633 printf("error: argument assignment (%s) without value.\n",paramname);
639 SYS_WriteCommandLineInt(syshandle,argv[a],1);
642 if (!strcmp(argv[a],"nomipmap"))
644 GPU_set_mipmap(0); //doMipMap = 0;
647 if (!strcmp(argv[a],"linearmipmap"))
649 GPU_set_linear_mipmap(1); //linearMipMap = 1;
653 } /* if (*(argv[a+1]) == '=') */
654 } /* if(++a < argc) */
661 int frame= MIN2(MAXFRAME, MAX2(1, atoi(argv[a])));
662 Render *re= RE_NewRender(G.scene->id.name);
663 #ifndef DISABLE_PYTHON
664 if (G.f & G_DOSCRIPTLINKS)
665 BPY_do_all_scripts(SCRIPT_RENDER, 0);
667 RE_BlenderAnim(re, G.scene, frame, frame, G.scene->frame_step);
668 #ifndef DISABLE_PYTHON
669 BPY_do_all_scripts(SCRIPT_POSTRENDER, 0);
673 printf("\nError: no blend loaded. cannot use '-f'.\n");
678 Render *re= RE_NewRender(G.scene->id.name);
679 #ifndef DISABLE_PYTHON
680 if (G.f & G_DOSCRIPTLINKS)
681 BPY_do_all_scripts(SCRIPT_RENDER, 1);
683 RE_BlenderAnim(re, G.scene, G.scene->r.sfra, G.scene->r.efra, G.scene->frame_step);
684 #ifndef DISABLE_PYTHON
685 if (G.f & G_DOSCRIPTLINKS)
686 BPY_do_all_scripts(SCRIPT_POSTRENDER, 1);
689 printf("\nError: no blend loaded. cannot use '-a'.\n");
694 set_scene_name(argv[a]);
700 int frame= MIN2(MAXFRAME, MAX2(1, atoi(argv[a])));
701 if (a < argc) (G.scene->r.sfra) = frame;
703 printf("\nError: no blend loaded. cannot use '-s'.\n");
709 int frame= MIN2(MAXFRAME, MAX2(1, atoi(argv[a])));
710 if (a < argc) (G.scene->r.efra) = frame;
712 printf("\nError: no blend loaded. cannot use '-e'.\n");
718 int fstep= MIN2(MAXFRAME, MAX2(1, atoi(argv[a])));
719 if (a < argc) (G.scene->frame_step) = fstep;
721 printf("\nError: no blend loaded. cannot use '-j'.\n");
725 #ifndef DISABLE_PYTHON
728 /* If we're not running in background mode, then give python a valid screen */
729 if ((G.background==0) && (scr_init==0)) {
733 BPY_run_python_script (argv[a]);
735 else printf("\nError: you must specify a Python script after '-P '.\n");
737 printf("This blender was built without python support\n");
738 #endif /* DISABLE_PYTHON */
744 BLI_strncpy(G.scene->r.pic, argv[a], FILE_MAXDIR);
746 printf("\nError: no blend loaded. cannot use '-o'.\n");
749 printf("\nError: you must specify a path after '-o '.\n");
756 printf("\nError: no blend loaded. order the arguments so '-F ' is after the blend is loaded.\n");
758 if (!strcmp(argv[a],"TGA")) G.scene->r.imtype = R_TARGA;
759 else if (!strcmp(argv[a],"IRIS")) G.scene->r.imtype = R_IRIS;
760 else if (!strcmp(argv[a],"HAMX")) G.scene->r.imtype = R_HAMX;
762 else if (!strcmp(argv[a],"DDS")) G.scene->r.imtype = R_DDS;
764 else if (!strcmp(argv[a],"JPEG")) G.scene->r.imtype = R_JPEG90;
765 else if (!strcmp(argv[a],"MOVIE")) G.scene->r.imtype = R_MOVIE;
766 else if (!strcmp(argv[a],"IRIZ")) G.scene->r.imtype = R_IRIZ;
767 else if (!strcmp(argv[a],"RAWTGA")) G.scene->r.imtype = R_RAWTGA;
768 else if (!strcmp(argv[a],"AVIRAW")) G.scene->r.imtype = R_AVIRAW;
769 else if (!strcmp(argv[a],"AVIJPEG")) G.scene->r.imtype = R_AVIJPEG;
770 else if (!strcmp(argv[a],"PNG")) G.scene->r.imtype = R_PNG;
771 else if (!strcmp(argv[a],"AVICODEC")) G.scene->r.imtype = R_AVICODEC;
772 else if (!strcmp(argv[a],"QUICKTIME")) G.scene->r.imtype = R_QUICKTIME;
773 else if (!strcmp(argv[a],"BMP")) G.scene->r.imtype = R_BMP;
774 else if (!strcmp(argv[a],"HDR")) G.scene->r.imtype = R_RADHDR;
775 else if (!strcmp(argv[a],"TIFF")) G.scene->r.imtype = R_TIFF;
777 else if (!strcmp(argv[a],"EXR")) G.scene->r.imtype = R_OPENEXR;
778 else if (!strcmp(argv[a],"MULTILAYER")) G.scene->r.imtype = R_MULTILAYER;
780 else if (!strcmp(argv[a],"MPEG")) G.scene->r.imtype = R_FFMPEG;
781 else if (!strcmp(argv[a],"FRAMESERVER")) G.scene->r.imtype = R_FRAMESERVER;
782 else if (!strcmp(argv[a],"CINEON")) G.scene->r.imtype = R_CINEON;
783 else if (!strcmp(argv[a],"DPX")) G.scene->r.imtype = R_DPX;
785 else if (!strcmp(argv[a],"JP2")) G.scene->r.imtype = R_JP2;
787 else printf("\nError: Format from '-F' not known or not compiled in this release.\n");
790 printf("\nError: no blend loaded. cannot use '-x'.\n");
798 RE_set_max_threads(atoi(argv[a]));
800 printf("Warning: threads can only be set in background mode\n");
803 printf("\nError: you must specify a number of threads between 0 and 8 '-t '.\n");
806 case 'x': /* extension */
810 if (argv[a][0] == '0') {
811 G.scene->r.scemode &= ~R_EXTENSION;
812 } else if (argv[a][0] == '1') {
813 G.scene->r.scemode |= R_EXTENSION;
815 printf("\nError: Use '-x 1' or '-x 0' To set the extension option.\n");
818 printf("\nError: no blend loaded. order the arguments so '-o ' is after '-x '.\n");
821 printf("\nError: you must specify a path after '- '.\n");
828 /* Make the path absolute because its needed for relative linked blends to be found */
829 char filename[FILE_MAXDIR + FILE_MAXFILE];
831 BLI_strncpy(filename, argv[a], sizeof(filename));
832 BLI_convertstringcwd(filename);
835 int retval = BKE_read_file(filename, NULL);
836 sound_initialize_sounds();
838 /*we successfully loaded a blend file, get sure that
840 if (retval!=0) G.relbase_valid = 1;
842 /* happens for the UI on file reading too */
844 BKE_write_undo("original"); /* save current state */
846 /* we are not running in background mode here, but start blender in UI mode with
847 a file - this should do everything a 'load file' does */
848 BIF_read_file(filename);
854 /* actually incorrect, but works for now (ton) */
862 screenmain(); /* main display loop */
865 } /* end of int main(argc,argv) */
867 static void error_cb(char *err)
872 static void mem_error_cb(char *errorStr)
874 fprintf(stderr, errorStr);
878 static void setCallbacks(void)
880 /* Error output from the alloc routines: */
881 MEM_set_error_callback(mem_error_cb);
886 BLI_setErrorCallBack(error_cb); /* */
887 BLI_setInterruptCallBack(blender_test_break);