1 /* Stereograph 0.10b, 09/02/2000; 2 * Copyright (c) 2000 by Fabian Januszewski <fabian.linux@januszewski.de> 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation; either version 2 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 */ 18 19 20 #include <stdio.h> 21 #include <stdlib.h> 22 23 #include "renderer.h" 24 #include "gfxio.h" 25 #include "stereograph.h" 26 27 28 char *base_file_name; 29 char *texture_file_name; 30 char *stereo_file_name; 31 32 /* interface to the renderer */ 33 struct PARAMS *pParam; 34 struct GFX_DATA *pBase, *pTexture, *pStereo; 35 36 37 void print_info(void) { 38 printf("SYNOPSIS\n stereograph [OPTIONS] -b [FILENAME] -t [FILENAME] -o [FILENAME]\n\n"); 39 printf("OPTIONS\n -a anti-aliasing -d distance -x texture_start_x -y texture_start_y -z zoom\n\n"); 40 } 41 42 int main (int argc, char **argv) { 43 44 int last_error = 0; 45 printf("Stereograph for linux Version %s\n(c) 2000 Fabian Januszewski\n\n", "0.10"); 46 47 Get_GFX_Pointers(&pParam, &pBase, &pTexture, &pStereo); 48 49 pParam->Zoom = 1; 50 pParam->AA = 4; 51 pParam->Startx = 0; 52 pParam->Starty = 0; 53 pParam->Front = 1.0; 54 pParam->Distance = 0.6; 55 56 pBase->Data = NULL; 57 pTexture->Data = NULL; 58 pStereo->Data = NULL; 59 base_file_name = NULL; 60 texture_file_name = NULL; 61 stereo_file_name = NULL; 62 63 parse_args(argc, argv); 64 65 if(base_file_name && texture_file_name && stereo_file_name) { 66 printf("loading base '%s'...", base_file_name); 67 if(!Read_Gfx_File(base_file_name, pBase)) { 68 printf("loading texture '%s'...", texture_file_name); 69 if(!Read_Gfx_File(texture_file_name, pTexture)) { 70 71 /* setting up renderer; */ 72 printf("initializing renderer..."); 73 if(!(last_error = Initialize_Renderer())) { 74 int y, s; 75 printf("success;\n"); 76 printf("using parametres as follows (zadxy): %i %i %f %i %i;\n", pParam->Zoom, pParam->AA, pParam->Distance, pParam->Startx, pParam->Starty); 77 printf("processing..."); 78 79 for(y = 0, s = 0; y < pBase->Height; y++) { 80 ProcessLine(y); 81 /* print simple status points (without refresh) */ 82 for( ; s < (58 * y / pBase->Height); s++) 83 printf("."); 84 } 85 86 printf("completed;\n"); 87 88 printf("writing stereogram to disk..."); 89 Write_TARGA(stereo_file_name, pStereo); 90 } else { 91 printf("FAILED;\n"); 92 switch (last_error) { 93 case -1 : 94 printf("illegal parametre;\n\n"); 95 print_info(); 96 break; 97 case -2 : 98 printf("width of texture file greater than the base;\nthis state is not processable;\n"); 99 break; 100 case -3 : 101 printf("could not allocate memory.\n"); 102 } 103 return -1; 104 } 105 Clear_Renderer(); 106 } 107 free(pTexture->Data); 108 } 109 free(pBase->Data); 110 } else { 111 printf("NOTIFY: must specify base, texture and output files!\n\n"); 112 print_info(); 113 return -1; 114 } 115 return 0; 116 } 117 118 int parse_args (int argc, char **argv) { 119 int z; 120 for(z = 1; z < argc; z++) 121 if(argv[z][0] == '-') 122 switch(argv[z][1]) { 123 case 'b' : 124 base_file_name = argv[++z]; 125 break; 126 case 't' : 127 texture_file_name = argv[++z]; 128 break; 129 case 'o' : 130 stereo_file_name = argv[++z]; 131 break; 132 case 'x' : 133 pParam->Startx = atoi(argv[++z]); 134 break; 135 case 'y' : 136 pParam->Starty = atoi(argv[++z]); 137 break; 138 /*case 'f' : 139 pParam->Front = (float) atof(argv[++z]); 140 break;*/ 141 case 'd' : 142 pParam->Distance = (float) atof(argv[++z]); 143 break; 144 case 'a' : 145 pParam->AA = atoi(argv[++z]); 146 break; 147 case 'z' : 148 pParam->Zoom = atoi(argv[++z]); 149 break; 150 printf("invalid argument '%c';\n", argv[z][1]); 151 return -1; 152 } 153 return 0; 154 } |