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

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

Click here to go back to the directory listing.
Click here to download this file.
last modified: 2000-04-10 00:39:23