int parseArguments(int argc, char *argv[]) { if ( argc <1 ) { fprintf(stderr,"Something weird is happening , argument zero should be executable path :S \n"); return 1; } else if ( argc == 1 ) { fprintf(stderr,"Usage flashyslideshow \"path\\to\\directory\\of\\album\"\n\n"); strncpy((char * ) frame.program_data_directory,argv[0],MAX_PATH); } else { int i=0; for (i=0; i<argc; i++) { if (strcmp(argv[i],"-web")==0) { //Recursive Directory command fprintf(stderr,"Web Interface Enabled %u - %s\n",i,argv[i]); if (!WebInterfaceCompiledIn()) { //Web interface has been enabled by user BUT its not compiled in! :S EmmitDialogWarning( (char *) "Please note that this build of FlashySlideshow hasn't got a compiled in WebInterface..!\n To download it run ./update_from_git.sh from the project's root dir and enable it at the CMake file..\n\n\nCheck here for more info :\nhttps://github.com/AmmarkoV/FlashySlideshows\n"); } frame.enable_web_interface=1; } else if (strcmp(argv[i],"-r")==0) { //Recursive Directory command fprintf(stderr,"Recursive Directory Enabled %u - %s\n",i,argv[i]); frame.recursive=1; } else if (strcmp(argv[i],"-fullscreen")==0) { //Fullscreen window fprintf(stderr,"Auto Fullscreen %u - %s\n",i,argv[i]); frame.fullscreen=1; } else if (strcmp(argv[i],"-play")==0) { //Recursive Directory command fprintf(stderr,"AutoStarting Playback %u - %s\n",i,argv[i]); ToggleAutomaticSlideshow(); } else if (strcmp(argv[i],"-sfx")==0) { //Sound Effects command fprintf(stderr,"%u Sound Effects Enabled %s\n",i,argv[i]); frame.enable_sound_effects=1; } else if (strcmp(argv[i],"-file_move")==0) { //Move Files command fprintf(stderr,"%u Move Sorting Enabled with keys 0 to 9 %s\n",i,argv[i]); frame.allow_operation_move=1; } else if (strcmp(argv[i],"-file_resize")==0) { //Resize Files command if (i+1<=argc) { fprintf(stderr,"%u Move Resized Enabled at Resolution %s with keys 0 to 9 %s\n",i,argv[i+1],argv[i]); frame.allow_operation_resize=1; strcpy(frame.rescale_resolution_string,argv[i+1]); } } else if (strcmp(argv[i],"-file_copy")==0) { //File Copy command fprintf(stderr,"%u Move Sorting Enabled with keys 0 to 9 %s\n",i,argv[i]); frame.allow_operation_copy=1; } else if (strcmp(argv[i],"-file_link")==0) { //File Copy command fprintf(stderr,"%u Link Sorting Enabled with keys 0 to 9 %s\n",i,argv[i]); frame.allow_operation_link=1; } else if (strcmp(argv[i],"-no_hud")==0) { //File Copy command fprintf(stderr,"Hud Disabled.."); frame.disable_hud=1; } else if (strcmp(argv[i],"-no_background")==0) { //File Copy command fprintf(stderr,"Background Disabled.."); frame.plain_background_no_image=1; } else if (strcmp(argv[i],"-fd")==0) { //Face Detection command fprintf(stderr,"%u Face Detection Enabled %s\n",i,argv[i]); } else if (strcmp(argv[i],"-v")==0) { //Visuals Enabled command fprintf(stderr,"%u Visuals Enabled %s\n",i,argv[i]); } else if (strcmp(argv[i],"-m")==0) { //Mipmaping Enabled command fprintf(stderr,"%u Mipmaping Enabled %s\n",i,argv[i]); frame.mipmaping=1; } else if (strcmp(argv[i],"-q")==0) { //Quality command if (i+1<=argc) { frame.quality_setting=atoi(argv[i+1]); // Quality fprintf(stderr,"%u Image Quality %s = %s ( %u )\n",i,argv[i],argv[i+1],frame.quality_setting); if (frame.quality_setting>=3) { frame.try_for_best_render_quality=1; } fprintf(stderr," Rendering Quality Switch %u\n",frame.try_for_best_render_quality); //THIS HAS A SECOND PAYLOAD THAT HAPPENS AFTERWARDS----> to initialize frame.gpu.maximum_frame_total_size } } else if (strcmp(argv[i],"-images_per_line")==0) { //Images per line command if (i+1<=argc) { frame.images_per_line=atoi(argv[i+1]); // Background fprintf(stderr,"%u Images per line Manually Chosen %s = %s ( %u )\n",i,argv[i],argv[i+1],frame.images_per_line); frame.active_image_x=((unsigned int) frame.images_per_line/2); frame.active_image_y=1; frame.active_image_place=PictureXYtoID(frame.active_image_x,frame.active_image_y); frame.last_image_x=frame.active_image_x; frame.last_image_y=frame.active_image_y; frame.last_image_place=frame.active_image_place; GetLayoutCoordinatesForXY(frame.active_image_x,frame.active_image_y,&frame.vx,&frame.vy,&frame.vz); frame.vz=8.0; frame.desired_x=frame.vx; frame.desired_y=frame.vy; frame.desired_z=GetLayoutMaximumZ()-0.5; fprintf(stderr,"Setting Center to %u,%u (%u) --> coords %0.2f,%0.2f,%0.2f\n",frame.active_image_x,frame.active_image_y,frame.active_image_place,frame.vx,frame.vy,frame.vz); } } else if (strcmp(argv[i],"-b")==0) { //Quality command if (i+1<=argc) { frame.background_number=atoi(argv[i+1]); // Background fprintf(stderr,"%u Frame Background Manually Chosen %s = %s ( %u )\n",i,argv[i],argv[i+1],frame.background_number); } } else if (strcmp(argv[i],"-d")==0) { //Transition delay command if (i+1<=argc) { frame.time_ms_between_two_transitions=atoi(argv[i+1]); fprintf(stderr,"%u Transition Delay %s = %s ( %u ) \n",i,argv[i],argv[i+1],frame.time_ms_between_two_transitions); } } else if (strcmp(argv[i],"-t")==0) { //Transition Type command if (i+1<=argc) { fprintf(stderr,"%u Transition Type %s=%s\n",i,argv[i],argv[i+1]); if ( *argv[i+1]=='0' ) { fprintf(stderr,"3D Seek\n"); frame.transitions.transition_mode=0; } else if ( *argv[i+1]=='1' ) { fprintf(stderr,"Immediate\n"); frame.transitions.transition_mode=1; } else if ( *argv[i+1]=='2' ) { fprintf(stderr,"Transparency\n"); frame.transitions.transition_mode=2; } else { fprintf(stderr,"Incorrect Transition Type..\n"); } } } else if (strcmp(argv[i],"-l")==0) { //Layout Type command if (i+1<=argc) { fprintf(stderr,"%u Layout Type %s=%s\n",i,argv[i],argv[i+1]); if ( *argv[i+1]=='0' ) { fprintf(stderr,"Basic Layout\n"); frame.layout.layout_mode=0; } else if ( *argv[i+1]=='1' ) { fprintf(stderr,"Expo\n"); frame.layout.layout_mode=1; } else { fprintf(stderr,"Incorrect Layout Type..\n"); } } } else if (strcmp(argv[i],"-s")==0) { //Sorting Type command if (i+1<=argc) { fprintf(stderr,"%u Sorting Type %s=%s\n",i,argv[i],argv[i+1]); if ( *argv[i+1]=='0' ) { fprintf(stderr,"Ascending Name\n"); frame.sort_type=0; frame.sort_ascending=1; frame.sort_randomization=0; } else if ( *argv[i+1]=='1' ) { fprintf(stderr,"Ascending Date\n"); frame.sort_type=1; frame.sort_ascending=1; frame.sort_randomization=0; } else if ( *argv[i+1]=='2' ) { fprintf(stderr,"Ascending Size\n"); frame.sort_type=2; frame.sort_ascending=1; frame.sort_randomization=0; } else if ( *argv[i+1]=='3' ) { fprintf(stderr,"Descending Name\n"); frame.sort_type=0; frame.sort_ascending=0; frame.sort_randomization=0; } else if ( *argv[i+1]=='4' ) { fprintf(stderr,"Descending Date\n"); frame.sort_type=1; frame.sort_ascending=0; frame.sort_randomization=0; } else if ( *argv[i+1]=='5' ) { fprintf(stderr,"Descending Size\n"); frame.sort_type=2; frame.sort_ascending=0; frame.sort_randomization=0; } else if ( *argv[i+1]=='r' ) { fprintf(stderr,"Randomized\n"); frame.sort_randomization=1; } else { fprintf(stderr,"Incorrect Sorting Type..\n"); } } } } strncpy((char * ) frame.program_data_directory,argv[0],MAX_PATH); strncpy((char * ) frame.album_directory,argv[argc-1],MAX_PATH); if ( strncmp((char*)frame.album_directory,"pick",4)==0 ) { /* PICK ALBUM DIR VIA GUI */ if ( LaunchGUI_PickDir() == 0 ) { fprintf(stderr,"No dir selected! \n"); return 0; } } } strcat((char * ) frame.album_directory,"/"); fprintf(stderr,"Slideshow directory is = %s (%u chars) \n", frame.album_directory ,(unsigned int) strlen((char*) frame.album_directory)); return 1; }
int main(int argc, char *argv[]) { /* Initialize Slideshow variables before the arguments are parsed..*/ InitSlideShow(); DisableScreenSaver(); strcpy((char * ) frame.album_directory,"album"); // album or test_album for debugging.. strcpy((char * ) frame.copy_directory,"Copied"); strcpy((char * ) frame.move_directory,"Moved"); strcpy((char * ) frame.resize_directory,"Resized"); strcpy((char * ) frame.link_directory,"Linked"); /* Parse Commandline arguments >>>>>>>>>>>>>>>>>> */ if (!parseArguments(argc,argv)) { fprintf(stderr,"Invalid arguments\n"); EnableScreenSaver(); return 1; } /* Turn on VSYNC to prevent tearing >>>>>>>>>>>>>>>>>> */ putenv( (char *) "__GL_SYNC_TO_VBLANK=1" ); //putenv( (char *) "__GL_SYNC_TO_VBLANK=1 __GL_YIELD=\"USLEEP\" " ); /* GLUT Initialization >>>>>>>>>>>>>>>>>> */ glutInit(&argc, argv); //Initializing Display Mode should be right after glutInit to ensure the window will get created using the correct flags..! ( double buffering etc ) glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_ALPHA | GLUT_DEPTH ); // depth buffer and multisampling disabled for older systems..! |GLUT_MULTISAMPLE | GLUT_DEPTH glutSetOption (GLUT_ACTION_ON_WINDOW_CLOSE ,GLUT_ACTION_CONTINUE_EXECUTION); int width_x=glutGet(GLUT_SCREEN_WIDTH); int width_y=glutGet(GLUT_SCREEN_HEIGHT)-50; // 50 for the lxpanel bar :P fprintf(stderr,"System Resolution is %ux%u\n",width_x,width_y); if (width_x>1024) { width_x=1024; } if (width_y>600) { width_y=600; } char title[512]={0}; sprintf(title,"Flashy Slideshows v%s %s - build %u - %s/%s/%s ",AutoVersion::FULLVERSION_STRING,AutoVersion::STATUS,(unsigned int) AutoVersion::BUILDS_COUNT,AutoVersion::DATE,AutoVersion::MONTH,AutoVersion::YEAR); fprintf(stderr,"Window Resolution is %ux%u\n",width_x,width_y); glutInitWindowSize(width_x,width_y); glutInitWindowPosition(0,0); frame.windowX=0; frame.windowY=0; frame.windowWidth=width_x; frame.windowHeight=width_y; originalWindow = glutCreateWindow(title); if (frame.fullscreen) { frame.fullscreen=0; ToggleFullscreen(); } InitGlut(); /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> */ /* OpenGL Initialization >>>>>>>>>>>>>>>>> */ glClearColor(0,0,0,0); glEnable(GL_CULL_FACE); glCullFace(GL_BACK); //glEnable(GL_DEPTH_TEST); //glDepthFunc(GL_LESS); //glClearDepth(1.0); // Enables Clearing Of The Depth Buffer if (frame.try_for_best_render_quality) { glEnable(GL_NORMALIZE); glShadeModel(GL_SMOOTH); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); glHint(GL_POINT_SMOOTH_HINT, GL_NICEST); glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST); } else { glShadeModel(GL_FLAT); } /* LIGHTING , ENABLED ON GOOD RENDERING QUALITY ( TO ENABLE TRANSPARENCY ETC ) */ if (frame.try_for_best_render_quality) { frame.lighting_enabled=1; glEnable(GL_COLOR_MATERIAL); glEnable(GL_LIGHT0); glEnable(GL_LIGHTING); glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient); glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse); //glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular); //glLightfv(GL_LIGHT0, GL_POSITION, light_position); glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient); glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); //glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); //glMaterialfv(GL_FRONT, GL_SHININESS, high_shininess); } else { frame.lighting_enabled=0; } /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> */ //Now that we have an OpenGL context we can query the maximum texture dimension.. QueryAndSaveGPUAndSystemCapabilities(); /* Initialize WxWidgets */ WxWidgetsContext wxlibstuff; wxlibstuff.OnInit(); fprintf(stderr,"Done with wxWidgets initialization\n"); LoadStockTexturesAndSounds(); InitEffects(); if (!LoadPicturesOfDirectory((char*)frame.album_directory,frame.sort_type,frame.sort_ascending,frame.sort_randomization,frame.recursive)) { EmmitDialogWarning( (char *) "Could not find any pictures in the directory of your selection"); return 0; } frame.total_images=GetTotalViewableFilesInDirectory(); if (!CreateSlideshowPictureStructure(GetTotalViewableFilesInDirectory())) { fprintf(stderr,"Unrecoverable error , could not allocate enough memory for %u Picture structure pointers..\nYou may try to re-run when more RAM will be availiable\n",GetTotalViewableFilesInDirectory()); return 1; } /*At this point we have initialized the picture structures and the slideshow structures so lets make sure that the camera is over an existing picture..! */ PutCameraOverExistingPictureIfItIsOff(); /* Initialize Joystick Thread (if a joystick is connected and detected )*/ StartJoystickControl(); /* Initialize Picture Loading Thread */ loadpicturesthread_id=0; pthread_create( &loadpicturesthread_id, NULL,ManageLoadingPicturesMemory_Thread,0); //This has to happen after LoadStockTexturesAndSounds in order for frame.app_clipart_dir to get populated if (frame.enable_web_interface) { if (!StartWebInterface((char*) "0.0.0.0", 8080 , (char*) frame.album_directory , ( char*) frame.app_clipart_dir)) { // EmmitDialogWarning( (char *) "Could not initialize web interface"); fprintf(stderr,"\n\nCould not initialize web interface\n\n"); } } gettimeofday(&last_frame,0x0); /* Start Rendering */ glutMainLoop(); fprintf(stderr,"Gracefully closing program\n"); if (frame.enable_web_interface) { StopWebInterface(); } EnableScreenSaver(); StopJoystickControl(); UnLoadStockTexturesAndSounds(); DestroySlideshowPictureStructure(); wxlibstuff.OnClose(); return EXIT_SUCCESS; }