diff options
Diffstat (limited to 'source/creator/creator.c')
-rw-r--r-- | source/creator/creator.c | 136 |
1 files changed, 56 insertions, 80 deletions
diff --git a/source/creator/creator.c b/source/creator/creator.c index 872a5f4d497..bfc03c976fb 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -29,6 +29,13 @@ #include <stdlib.h> #include <string.h> + +/* for setuid / getuid */ +#ifdef __sgi +#include <sys/types.h> +#include <unistd.h> +#endif + /* This little block needed for linking to Blender... */ #include "MEM_guardedalloc.h" @@ -43,8 +50,6 @@ #include "DNA_scene_types.h" #include "BLI_blenlib.h" -#include "blendef.h" /* for MAXFRAME */ - #include "BKE_utildefines.h" #include "BKE_blender.h" @@ -56,20 +61,6 @@ #include "BKE_scene.h" #include "BKE_node.h" -#include "BIF_gl.h" -#include "BIF_graphics.h" -#include "BIF_mainqueue.h" -#include "BIF_graphics.h" -#include "BIF_editsound.h" -#include "BIF_usiblender.h" -#include "BIF_drawscene.h" /* set_scene() */ -#include "BIF_screen.h" /* waitcursor and more */ -#include "BIF_usiblender.h" -#include "BIF_toolbox.h" - -#include "BLO_writefile.h" -#include "BLO_readfile.h" - #include "IMB_imbuf.h" // for quicktime_init #ifndef DISABLE_PYTHON @@ -78,14 +69,16 @@ #include "RE_pipeline.h" +//XXX #include "playanim_ext.h" +#include "wm_event_types.h" +//XXX #include "nla.h" +//XXX #include "datatoc.h" + +#include "WM_api.h" + #include "GPU_draw.h" #include "GPU_extensions.h" -#include "playanim_ext.h" -#include "mydevice.h" -#include "nla.h" -#include "datatoc.h" - /* for passing information between creator and gameengine */ #include "SYS_System.h" @@ -113,16 +106,6 @@ extern char * build_type; static void print_help(void); static void print_version(void); - -/* defined in ghostwinlay and winlay, we can't include carbon here, conflict with DNA */ -#ifdef __APPLE__ -extern int checkAppleVideoCard(void); -extern void getMacAvailableBounds(short *top, short *left, short *bottom, short *right); -extern void winlay_get_screensize(int *width_r, int *height_r); -extern void winlay_process_events(int wait_for_event); -#endif - - /* for the callbacks: */ extern int pluginapi_force_ref(void); /* from blenpluginapi:pluginapi.c */ @@ -201,7 +184,7 @@ static void print_help(void) printf (" -t <threads>\tUse amount of <threads> for rendering (background mode only).\n"); printf (" [1-8], 0 for systems processor count.\n"); printf ("\nAnimation playback options:\n"); - printf (" -a <file(s)>\tPlayback <file(s)>, only operates this way when -b is not used.\n"); + printf (" -a <options> <file(s)>\tPlayback <file(s)>, only operates this way when -b is not used.\n"); printf (" -p <sx> <sy>\tOpen with lower left corner at <sx>, <sy>\n"); printf (" -m\t\tRead from disk (Don't buffer)\n"); printf (" -f <fps> <fps-base>\t\tSpecify FPS to start with\n"); @@ -262,21 +245,24 @@ static void print_help(void) double PIL_check_seconds_timer(void); -extern void winlay_get_screensize(int *width_r, int *height_r); -static void main_init_screen( void ) +/* XXX This was here to fix a crash when running python scripts + * with -P that used the screen. + * + * static void main_init_screen( void ) { setscreen(G.curscreen); if(G.main->scene.first==0) { set_scene( add_scene("1") ); } -} +}*/ int main(int argc, char **argv) { - int a, i, stax, stay, sizx, sizy, scr_init = 0; SYS_SystemHandle syshandle; + bContext *C= MEM_callocN(sizeof(bContext), "creator.c context"); + int a, i, stax, stay, sizx, sizy /*XXX, scr_init = 0*/; #if defined(WIN32) || defined (__linux__) int audio = 1; @@ -293,29 +279,13 @@ int main(int argc, char **argv) #ifdef __APPLE__ /* patch to ignore argument finder gives us (pid?) */ if (argc==2 && strncmp(argv[1], "-psn_", 5)==0) { + extern void wm_window_process_events(int wait_for_event); extern int GHOST_HACK_getFirstFile(char buf[]); static char firstfilebuf[512]; - int scr_x,scr_y; argc= 1; - /* first let us check if we are hardware accelerated and with VRAM > 16 Mo */ - - if (checkAppleVideoCard()) { - short top, left, bottom, right; - - winlay_get_screensize(&scr_x, &scr_y); - getMacAvailableBounds(&top, &left, &bottom, &right); - setprefsize(left +10,scr_y - bottom +10,right-left -20,bottom - 64, 0); - - } else { - winlay_get_screensize(&scr_x, &scr_y); - - /* 40 + 684 + (headers) 22 + 22 = 768, the powerbook screen height */ - setprefsize(120, 40, 850, 684, 0); - } - - winlay_process_events(0); + wm_window_process_events(0); if (GHOST_HACK_getFirstFile(firstfilebuf)) { argc= 2; argv[1]= firstfilebuf; @@ -385,7 +355,7 @@ int main(int argc, char **argv) /* exception here, see below, it probably needs happens after qt init? */ libtiff_init(); - playanim(argc-1, argv+1); +// XXX playanim(argc-1, argv+1); exit(0); break; case 'b': @@ -434,15 +404,11 @@ int main(int argc, char **argv) if(G.background) signal(SIGINT, blender_esc); /* ctrl c out bg render */ /* background render uses this font too */ - BKE_font_register_builtin(datatoc_Bfont, datatoc_Bfont_size); + //XXX BKE_font_register_builtin(datatoc_Bfont, datatoc_Bfont_size); init_def_material(); if(G.background==0) { - winlay_get_screensize(&sizx, &sizy); - stax=0; - stay=0; - for(a=1; a<argc; a++) { if(argv[a][0] == '-') { switch(argv[a][1]) { @@ -459,8 +425,8 @@ int main(int argc, char **argv) sizx= atoi(argv[a]); a++; sizy= atoi(argv[a]); - G.windowstate = G_WINDOWSTATE_BORDER; + WM_setprefsize(stax, stay, sizx, sizy); break; case 'd': G.f |= G_DEBUG; /* std output printf's */ @@ -476,11 +442,11 @@ int main(int argc, char **argv) break; case 'w': - G.windowstate = G_WINDOWSTATE_BORDER; + /* with borders XXX OLD CRUFT!*/ break; case 'W': + /* borderless, win + linux XXX OLD CRUFT */ /* XXX, fixme mein, borderless on OSX */ - G.windowstate = G_WINDOWSTATE_FULLSCREEN; break; case 'R': /* Registering filetypes only makes sense on windows... */ @@ -515,8 +481,6 @@ int main(int argc, char **argv) } } - if ( (G.windowstate == G_WINDOWSTATE_BORDER) || (G.windowstate == G_WINDOWSTATE_FULLSCREEN)) - setprefsize(stax, stay, sizx, sizy, 0); #ifndef DISABLE_PYTHON BPY_start_python(argc, argv); #endif @@ -526,8 +490,9 @@ int main(int argc, char **argv) * added note (ton): i removed it altogether */ - BIF_init(); /* loads .B.blend */ + WM_init(C); + // XXX BRECHT SOLVE BLI_where_is_temp( btempdir, 1 ); /* call after loading the .B.blend so we can read U.tempdir */ #ifndef DISABLE_SDL @@ -554,10 +519,10 @@ int main(int argc, char **argv) } #ifndef DISABLE_PYTHON /** - * NOTE: the U.pythondir string is NULL until BIF_init() is executed, + * NOTE: the U.pythondir string is NULL until WM_init() is executed, * so we provide the BPY_ function below to append the user defined * pythondir to Python's sys.path at this point. Simply putting - * BIF_init() before BPY_start_python() crashes Blender at startup. + * WM_init() before BPY_start_python() crashes Blender at startup. * Update: now this function also inits the bpymenus, which also depend * on U.pythondir. */ @@ -710,7 +675,13 @@ int main(int argc, char **argv) } break; case 'P': + #ifndef DISABLE_PYTHON + //XXX + // FOR TESTING ONLY + a++; + BPY_run_python_script (argv[a]); +#if 0 a++; if (a < argc) { /* If we're not running in background mode, then give python a valid screen */ @@ -721,6 +692,7 @@ int main(int argc, char **argv) BPY_run_python_script (argv[a]); } 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 */ @@ -813,41 +785,45 @@ int main(int argc, char **argv) BLI_convertstringcwd(filename); if (G.background) { - int retval = BKE_read_file(filename, NULL); - sound_initialize_sounds(); + int retval = BKE_read_file(C, argv[a], NULL); +// XXX sound_initialize_sounds(); /*we successfully loaded a blend file, get sure that pointcache works */ if (retval!=0) G.relbase_valid = 1; - /* happens for the UI on file reading too */ - BKE_reset_undo(); - BKE_write_undo("original"); /* save current state */ + /* 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 */ - BIF_read_file(filename); + WM_read_file(C, filename); } } } - + if(G.background) { /* actually incorrect, but works for now (ton) */ - exit_usiblender(); + WM_exit(C); } + + + WM_main(C); - if (scr_init==0) { + /*XXX if (scr_init==0) { main_init_screen(); } - screenmain(); /* main display loop */ + screenmain();*/ /* main display loop */ return 0; } /* end of int main(argc,argv) */ static void error_cb(char *err) { - error("%s", err); + + printf("%s\n", err); /* XXX do this in WM too */ } static void mem_error_cb(char *errorStr) @@ -865,6 +841,6 @@ static void setCallbacks(void) /* BLI_blenlib: */ BLI_setErrorCallBack(error_cb); /* */ - BLI_setInterruptCallBack(blender_test_break); +// XXX BLI_setInterruptCallBack(blender_test_break); } |