printf("Example: setenv BF_TIFF_LIB /usr/lib/libtiff.so\n");
}
+ /* initialize Freestyle */
+ FRS_initialize();
+ FRS_set_context(C);
+
/* OK we are ready for it */
+ BLI_argsParse(ba, 4, load_file, C);
- for(a=1; a<argc; a++) {
- if (G.afbreek==1) break;
-
- if(argv[a][0] == '-') {
- switch(argv[a][1]) {
- case '-': /* -- ends argument processing */
- a = argc;
- break;
-
- case 'p': /* prefsize */
- a+= 4;
- break;
-
- case 'g':
- {
- /**
- gameengine parameters are automaticly put into system
- -g [paramname = value]
- -g [boolparamname]
- example:
- -g novertexarrays
- -g maxvertexarraysize = 512
- */
-
- if(++a < argc)
- {
- char* paramname = argv[a];
- /* check for single value versus assignment */
- if (a+1 < argc && (*(argv[a+1]) == '='))
- {
- a++;
- if (a+1 < argc)
- {
- a++;
- /* assignment */
- SYS_WriteCommandLineString(syshandle,paramname,argv[a]);
- } else
- {
- printf("error: argument assignment (%s) without value.\n",paramname);
- }
- /* name arg eaten */
-
- } else
- {
- SYS_WriteCommandLineInt(syshandle,argv[a],1);
-
- /* doMipMap */
- if (!strcmp(argv[a],"nomipmap"))
- {
- GPU_set_mipmap(0); //doMipMap = 0;
- }
- /* linearMipMap */
- if (!strcmp(argv[a],"linearmipmap"))
- {
- GPU_set_linear_mipmap(1); //linearMipMap = 1;
- }
-
-
- } /* if (*(argv[a+1]) == '=') */
- } /* if(++a < argc) */
- break;
- }
- case 'f':
- a++;
- if (CTX_data_scene(C)) {
- Scene *scene= CTX_data_scene(C);
-
- if (a < argc) {
- int frame = atoi(argv[a]);
- Render *re = RE_NewRender(scene->id.name);
- ReportList reports;
-
- BKE_reports_init(&reports, RPT_PRINT);
-
- frame = MIN2(MAXFRAME, MAX2(MINAFRAME, frame));
-
- RE_BlenderAnim(re, scene, frame, frame, scene->r.frame_step, &reports);
- }
- } else {
- printf("\nError: no blend loaded. cannot use '-f'.\n");
- }
- break;
- case 'a':
- if (CTX_data_scene(C)) {
- Scene *scene= CTX_data_scene(C);
- Render *re= RE_NewRender(scene->id.name);
- ReportList reports;
- BKE_reports_init(&reports, RPT_PRINT);
- RE_BlenderAnim(re, scene, scene->r.sfra, scene->r.efra, scene->r.frame_step, &reports);
- } else {
- printf("\nError: no blend loaded. cannot use '-a'.\n");
- }
- break;
- case 'S':
- if(++a < argc) {
- set_scene_name(argv[a]);
- }
- break;
- case 's':
- a++;
- if (CTX_data_scene(C)) {
- Scene *scene= CTX_data_scene(C);
- if (a < argc) {
- int frame = atoi(argv[a]);
- (scene->r.sfra) = MIN2(MAXFRAME, MAX2(1, frame));
- }
- } else {
- printf("\nError: no blend loaded. cannot use '-s'.\n");
- }
- break;
- case 'e':
- a++;
- if (CTX_data_scene(C)) {
- Scene *scene= CTX_data_scene(C);
- if (a < argc) {
- int frame = atoi(argv[a]);
- (scene->r.efra) = MIN2(MAXFRAME, MAX2(1, frame));
- }
- } else {
- printf("\nError: no blend loaded. cannot use '-e'.\n");
- }
- break;
- case 'j':
- a++;
- if (CTX_data_scene(C)) {
- Scene *scene= CTX_data_scene(C);
- if (a < argc) {
- int frame = atoi(argv[a]);
- (scene->r.frame_step) = MIN2(MAXFRAME, MAX2(1, frame));
- }
- } else {
- printf("\nError: no blend loaded. cannot use '-j'.\n");
- }
- break;
- case 'P':
-
- #ifndef DISABLE_PYTHON
- a++;
-
- /* workaround for scripts not getting a bpy.context.scene, causes internal errors elsewhere */
- {
- /* XXX, temp setting the WM is ugly, splash also does this :S */
- wmWindowManager *wm= CTX_wm_manager(C);
- wmWindow *prevwin= CTX_wm_window(C);
-
- if(wm->windows.first) {
- CTX_wm_window_set(C, wm->windows.first);
+ BLI_argsFree(ba);
- BPY_run_python_script(C, argv[a], NULL, NULL); // use reports?
-
- CTX_wm_window_set(C, prevwin);
- }
- else {
- fprintf(stderr, "Python script \"%s\" running with missing context data.\n", argv[a]);
- BPY_run_python_script(C, argv[a], NULL, NULL); // use reports?
- }
- }
- #if 0
- a++;
- if (a < argc) {
- /* If we're not running in background mode, then give python a valid screen */
- if ((G.background==0) && (scr_init==0)) {
- main_init_screen();
- scr_init = 1;
- }
- BPY_run_python_script(C, argv[a], NULL, NULL); // use reports?
- }
- else printf("\nError: you must specify a Python script after '-P '.\n");
- #endif
- #else
- printf("This blender was built without python support\n");
- #endif /* DISABLE_PYTHON */
- break;
- case 'o':
- a++;
- if (a < argc){
- if (CTX_data_scene(C)) {
- Scene *scene= CTX_data_scene(C);
- BLI_strncpy(scene->r.pic, argv[a], FILE_MAXDIR);
- } else {
- printf("\nError: no blend loaded. cannot use '-o'.\n");
- }
- } else {
- printf("\nError: you must specify a path after '-o '.\n");
- }
- break;
- case 'E':
- a++;
- if (a < argc)
- {
- if (!strcmp(argv[a],"help"))
- {
- RenderEngineType *type = NULL;
-
- for( type = R_engines.first; type; type = type->next )
- {
- printf("\t%s\n", type->idname);
- }
- exit(0);
- }
- else
- {
- if (CTX_data_scene(C)==NULL)
- {
- printf("\nError: no blend loaded. order the arguments so '-E ' is after the blend is loaded.\n");
- }
- else
- {
- Scene *scene= CTX_data_scene(C);
- RenderData *rd = &scene->r;
- RenderEngineType *type = NULL;
-
- for( type = R_engines.first; type; type = type->next )
- {
- if (!strcmp(argv[a],type->idname))
- {
- BLI_strncpy(rd->engine, type->idname, sizeof(rd->engine));
- }
- }
- }
- }
- }
- else
- {
- printf("\nEngine not specified.\n");
- }
- break;
- case 'F':
- a++;
- if (a < argc){
- if (CTX_data_scene(C)==NULL) {
- printf("\nError: no blend loaded. order the arguments so '-F ' is after the blend is loaded.\n");
- } else {
- Scene *scene= CTX_data_scene(C);
- if (!strcmp(argv[a],"TGA")) scene->r.imtype = R_TARGA;
- else if (!strcmp(argv[a],"IRIS")) scene->r.imtype = R_IRIS;
- else if (!strcmp(argv[a],"HAMX")) scene->r.imtype = R_HAMX;
- #ifdef WITH_DDS
- else if (!strcmp(argv[a],"DDS")) scene->r.imtype = R_DDS;
- #endif
- else if (!strcmp(argv[a],"JPEG")) scene->r.imtype = R_JPEG90;
- else if (!strcmp(argv[a],"MOVIE")) scene->r.imtype = R_MOVIE;
- else if (!strcmp(argv[a],"IRIZ")) scene->r.imtype = R_IRIZ;
- else if (!strcmp(argv[a],"RAWTGA")) scene->r.imtype = R_RAWTGA;
- else if (!strcmp(argv[a],"AVIRAW")) scene->r.imtype = R_AVIRAW;
- else if (!strcmp(argv[a],"AVIJPEG")) scene->r.imtype = R_AVIJPEG;
- else if (!strcmp(argv[a],"PNG")) scene->r.imtype = R_PNG;
- else if (!strcmp(argv[a],"AVICODEC")) scene->r.imtype = R_AVICODEC;
- else if (!strcmp(argv[a],"QUICKTIME")) scene->r.imtype = R_QUICKTIME;
- else if (!strcmp(argv[a],"BMP")) scene->r.imtype = R_BMP;
- else if (!strcmp(argv[a],"HDR")) scene->r.imtype = R_RADHDR;
- else if (!strcmp(argv[a],"TIFF")) scene->r.imtype = R_TIFF;
- #ifdef WITH_OPENEXR
- else if (!strcmp(argv[a],"EXR")) scene->r.imtype = R_OPENEXR;
- else if (!strcmp(argv[a],"MULTILAYER")) scene->r.imtype = R_MULTILAYER;
- #endif
- else if (!strcmp(argv[a],"MPEG")) scene->r.imtype = R_FFMPEG;
- else if (!strcmp(argv[a],"FRAMESERVER")) scene->r.imtype = R_FRAMESERVER;
- else if (!strcmp(argv[a],"CINEON")) scene->r.imtype = R_CINEON;
- else if (!strcmp(argv[a],"DPX")) scene->r.imtype = R_DPX;
- #if WITH_OPENJPEG
- else if (!strcmp(argv[a],"JP2")) scene->r.imtype = R_JP2;
- #endif
- else printf("\nError: Format from '-F' not known or not compiled in this release.\n");
- }
- } else {
- printf("\nError: no blend loaded. cannot use '-x'.\n");
- }
- break;
-
- case 't':
- a++;
- if (a < argc) {
- if(G.background) {
- RE_set_max_threads(atoi(argv[a]));
- } else {
- printf("Warning: threads can only be set in background mode\n");
- }
- } else {
- printf("\nError: you must specify a number of threads between 0 and 8 '-t '.\n");
- }
- break;
- case 'x': /* extension */
- a++;
- if (a < argc) {
- if (CTX_data_scene(C)) {
- Scene *scene= CTX_data_scene(C);
- if (argv[a][0] == '0') {
- scene->r.scemode &= ~R_EXTENSION;
- } else if (argv[a][0] == '1') {
- scene->r.scemode |= R_EXTENSION;
- } else {
- printf("\nError: Use '-x 1' or '-x 0' To set the extension option.\n");
- }
- } else {
- printf("\nError: no blend loaded. order the arguments so '-o ' is after '-x '.\n");
- }
- } else {
- printf("\nError: you must specify a path after '- '.\n");
- }
- break;
- }
- }
- else {
-
- /* Make the path absolute because its needed for relative linked blends to be found */
- char filename[FILE_MAXDIR + FILE_MAXFILE];
-
- BLI_strncpy(filename, argv[a], sizeof(filename));
- BLI_convertstringcwd(filename);
-
- if (G.background) {
- int retval = BKE_read_file(C, argv[a], NULL, NULL);
-
- /*we successfully loaded a blend file, get sure that
- pointcache works */
- if (retval!=0) {
- CTX_wm_manager_set(C, NULL); /* remove wm to force check */
- WM_check(C);
- G.relbase_valid = 1;
- }
-
- /* happens for the UI on file reading too (huh? (ton))*/
- // XXX BKE_reset_undo();
- // BKE_write_undo("original"); /* save current state */
- } else {
- /* we are not running in background mode here, but start blender in UI mode with
- a file - this should do everything a 'load file' does */
- WM_read_file(C, filename, NULL);
- }
-
- file_loaded = 1;
- }
- }
-
if(G.background) {
/* actually incorrect, but works for now (ton) */
WM_exit(C);