revised model loading order
[csRadar.git] / csRadar.c
index b05b6a6be3126ae06e7d385c4923f90bd7f99498..e68237c5f46edf4d3220f2c8dac68506c01c2852 100644 (file)
--- a/csRadar.c
+++ b/csRadar.c
@@ -4,8 +4,10 @@
 #include <string.h>
 #include <math.h>
 #include <time.h>
+#include <stdarg.h>
 
 // CSR lib
+#include "csrLog.h"
 #include "csrOpt.h"
 #include "csrTypes.h"
 #include "csrMath.h"
@@ -43,6 +45,7 @@ int main( int argc, char *argv[] )
        char output_path[ 512 ];                // Full path eg. /home/harry/my_map.vmf
        char vmf_name[ 128 ];                   // Just the base name eg. my_map
        int output_set = 0;
+       EMSAA sampling_mode = k_EMSAA_RGSS;
 
        while( csr_argp( argc, argv ) )
        {
@@ -50,13 +53,10 @@ int main( int argc, char *argv[] )
                {
                        if( num_strings == 20 )
                        {
-                               fprintf( stderr, "Too many arguments! Max 20\n" );
-                               fs_exit();
-                               exit(0);
+                               log_error( "Too many arguments! Max 20\n" );
+                               goto IL_CSR_EXIT;
                        }
                        
-                       printf( "got: %s\n", arg );
-                       
                        strings[ num_strings ++ ] = arg;
                }
                
@@ -82,11 +82,36 @@ int main( int argc, char *argv[] )
                {
                        padding = atof( arg );
                }
+               
+               if( (arg = csr_long_opt_arg( "multi-sample" )) )
+               {
+                       if( !strcmp( arg, "none" ))
+                       {
+                               sampling_mode = k_EMSAA_none;
+                       }
+                       else if( !strcmp( arg, "rgss" ))
+                       {
+                               sampling_mode = k_EMSAA_RGSS;
+                       }
+                       else if( !strcmp( arg, "2x" ))
+                       {
+                               sampling_mode = k_EMSAA_2x2;
+                       }
+                       else if( !strcmp( arg, "8r" ))
+                       {
+                               sampling_mode = k_EMSAA_8R;
+                       }
+                       else
+                       {
+                               log_error( "Invalid sampling pattern '%s'\n", arg );
+                               goto IL_CSR_EXIT;
+                       }
+               }
 
                if( csr_opt( 'v' ) || csr_long_opt( "version" ) )
                {
                        printf( "csRadar version: " CSR_VERSION "\n" );
-                       return 0;
+                       goto IL_CSR_EXIT;
                }
                
                if( csr_opt( 'h' ) || csr_long_opt( "help" ) )
@@ -106,21 +131,22 @@ int main( int argc, char *argv[] )
                                "   -r 1024                        Output resolution\n"
                                "   -o <output>                    Specify output name/path\n"
                                "   --padding=128                  When cropping radar, add padding units to border\n"
-                               "   --standard-layers              Use standard TAR layers/groups\n"
+                               //"   --standard-layers              Use standard TAR layers/groups\n"
                                "   --no-txt                       Don't create matching radar txt\n"
-                               "   --multi-sample=                [ none, 2, 4, 4r, 8kn (default), 16c ]\n"
+                               "   --multi-sample=RGSS            [ none, 2x, rgss, 8r ]\n"
+                               "   --extension=TAR                Use an extension binary instead\n"
                                "\n"
                                "   -v --version                   Display program version\n"
                                "   -h --help                      Display this help text\n"
                        );
                        
-                       return 0;
+                       goto IL_CSR_EXIT;
                }
        }
        
        if( num_strings )
        {
-               vmf_map *map = vmf_init( strings[0], 1 );
+               vmf_map *map = vmf_init( strings[0] );
        
                if( map )
                {
@@ -139,16 +165,17 @@ int main( int argc, char *argv[] )
                        
                        strcpy( vmf_name, base_name );
                        
-                       printf( "output_path: '%s'\nvmf_name: '%s'\n", output_path, vmf_name );
-                       
+                       log_info( "output_path: '%s'\n", output_path );
+                       log_info( "vmf_name: '%s'\n", vmf_name );
                        
-                       // Main
-                                       
+                       // Main                 
                        csr_target target;
                        
-                       csr_create_target( &target, resolution, resolution );
+                       csr_create_target( &target, resolution, resolution, sampling_mode );
                        csr_rt_clear( &target );
                        
+                       csr_use_program( &target, frag_gbuffer );
+                       
                        // Compute bounds
                        csr_filter filter = 
                        {
@@ -180,8 +207,12 @@ int main( int argc, char *argv[] )
                                        }
                                }
                                
-                               filter.compute_bounds_only = 0;
-                               csr_auto_fit( &target, padding );
+                               if( i == 0 )
+                               {
+                                       filter.compute_bounds_only = 0;
+                                       csr_auto_fit( &target, padding );
+                                       vmf_load_models( map );
+                               }
                        }
                        
                        if( write_txt )
@@ -199,15 +230,15 @@ int main( int argc, char *argv[] )
                }
                else
                {
-                       fprintf( stderr, "Could not load VMF\n" );
+                       log_error( "Could not load VMF\n" );
                }
        }
        else
        {
-               fprintf( stderr, "Missing required argument: mapfile\n" );
+               log_error( "Missing required argument: mapfile\n" );
        }
        
+IL_CSR_EXIT:
        fs_exit();
-
        return 0;
 }