5751019 [rkeene@sledge /home/rkeene/devel/old/stereograph-0.13]$ cat -n stereograph.c
  1 /* Stereograph 0.13, 31/03/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     -z zoom               (quality)\n  -d distance          -e eye shift        
	 (perspective)\n  -x texture insert x  -y texture insert y   (layout)\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.13");
 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     pParam->Eyeshift = 0.0;
 56 
 57     pBase->Data = NULL;
 58     pTexture->Data = NULL;
 59     pStereo->Data = NULL;
 60     base_file_name = NULL;
 61     texture_file_name = NULL;
 62     stereo_file_name = NULL;
 63 
 64     parse_args(argc, argv);
 65 
 66     if(base_file_name && texture_file_name && stereo_file_name) {
 67         printf("loading base '%s'...", base_file_name);
 68         if(!Read_Gfx_File(base_file_name, pBase)) {
 69             printf("loading texture '%s'...", texture_file_name);
 70             if(!Read_Gfx_File(texture_file_name, pTexture)) {
 71 
 72                 /* setting up renderer; */
 73                 printf("initializing renderer...");
 74                 if(!(last_error = Initialize_Renderer())) {
 75                     int y, s;
 76                     printf("success;\n");
 77                     printf("using parametres as follows (zadexy): %i %i %f %f %i %i;\n", pParam->Zoom, pParam->AA,
	pParam->Distance, pParam->Eyeshift, pParam->Startx, pParam->Starty);
 78                     printf("processing...");
 79 
 80                     for(y = 0, s = 0; y < pBase->Height; y++) {
 81                         ProcessLine(y);
 82                         /* print simple status points (without refresh) */
 83                         for( ; s < (58 * y / pBase->Height); s++)
 84                             printf(".");
 85                     }
 86 
 87                     printf("completed;\n");
 88     
 89                     printf("writing stereogram to disk...");
 90                     Write_TARGA(stereo_file_name, pStereo);
 91                 } else {
 92                     printf("FAILED;\n");
 93                     switch (last_error) {
 94                         case -1 :
 95                             printf("illegal parametre;\n\n");
 96                             print_info();
 97                             break;
 98                         case -2 :
 99                             printf("width of texture file greater than the base;\nthis state is not processable;\n");
100                             break;
101                         case -3 :
102                             printf("could not allocate memory.\n");
103                     }
104                     return -1;
105                 }
106                 Clear_Renderer();
107             }
108             free(pTexture->Data);
109         }
110         free(pBase->Data);
111     } else {
112         printf("NOTIFY: must specify base, texture and output files!\n\n");
113         print_info();
114         return -1;
115     }
116     return 0;
117 }
118 
119 int parse_args (int argc, char **argv) {
120     int z;
121     for(z = 1; z < argc; z++)
122         if(argv[z][0] == '-')
123             switch(argv[z][1]) {
124                 case 'b' :
125                     base_file_name = argv[++z];
126                     break;
127                 case 't' :
128                     texture_file_name = argv[++z];
129                     break;
130                 case 'o' :
131                     stereo_file_name = argv[++z];
132                     break;
133                 case 'x' :
134                     pParam->Startx = atoi(argv[++z]);
135                     break;
136                 case 'y' :
137                     pParam->Starty = atoi(argv[++z]);
138                     break;
139                 /*case 'f' :
140                     pParam->Front = (float) atof(argv[++z]);
141                     break;*/
142                 case 'd' :
143                     pParam->Distance = (float) atof(argv[++z]);
144                     break;
145                 case 'e' :
146                     pParam->Eyeshift = (float) atof(argv[++z]);
147                     break;
148                 case 'a' :
149                     pParam->AA = atoi(argv[++z]);
150                     break;
151                 case 'z' :
152                     pParam->Zoom = atoi(argv[++z]);
153                     break;
154                 printf("invalid argument '%c';\n", argv[z][1]);
155                 return -1;
156             }
157     return 0;
158 }

stereograph.c is the source file that contains main().
5751020 [rkeene@sledge /home/rkeene/devel/old/stereograph-0.13]$

Click here to go back to the directory listing.
Click here to download this file.
last modified: 2000-03-31 21:52:18