code_function_body;
bool init;
+ const char *preprocessed_dir;
}
static vg_shaderbuild;
}
}
- snprintf( uf->uniform_code_id, 64, "_uniform_%s_%s",
- vg_shaderbuild.current_shader_name,
- uf->name );
+ snprintf( uf->uniform_code_id, 64, "_uniform_%s_%s", vg_shaderbuild.current_shader_name, uf->name );
}
-static int compile_subshader( vg_str *str, char *name )
+static int compile_subshader( vg_str *str, char *name, const char *path_write_full )
{
char error[256];
char *full = stb_include_file( name, "", vg_shaderbuild.shader_dir, error );
}
else
{
+ if( path_write_full )
+ {
+ FILE *fp = fopen( path_write_full, "w" );
+ if( !fp )
+ {
+ free( full );
+ fprintf( stderr, "Cant open %s\n", path_write_full );
+ return 0;
+ }
+ fputs( "#version 330 core\n", fp );
+ fputs( full, fp );
+ fclose( fp );
+ }
+
vg_strcatf( str, "{\n"
".orig_file = \"%s\",\n"
".static_src = \n",
if( !strncmp(start,"uniform",7) )
{
start += 8;
- struct uniform *uf =
- &vg_shaderbuild.uniform_buffer[
- vg_shaderbuild.uniform_count ++ ];
-
+ struct uniform *uf = &vg_shaderbuild.uniform_buffer[ vg_shaderbuild.uniform_count ++ ];
parse_uniform_name( start, uf );
}
" .name = \"%s\",\n"
" .vs = \n", name, name, name );
+ char pcpath[ 260 ];
+ if( vg_shaderbuild.preprocessed_dir )
+ snprintf( pcpath, sizeof(pcpath), "%s/%s.vert", vg_shaderbuild.preprocessed_dir, name );
+
vg_shaderbuild.uniform_count = 0;
- if( !compile_subshader( c_body, src_vert ) )
+ if( !compile_subshader( c_body, src_vert, vg_shaderbuild.preprocessed_dir? pcpath: NULL ) )
{
fclose( header );
vg_fatal_error( "Failed to assemble vertex source code" );
}
+ if( vg_shaderbuild.preprocessed_dir )
+ snprintf( pcpath, sizeof(pcpath), "%s/%s.frag", vg_shaderbuild.preprocessed_dir, name );
+
vg_strcatf( c_body, "\n .fs = \n" );
- if( !compile_subshader( c_body, src_frag ) )
+ if( !compile_subshader( c_body, src_frag, vg_shaderbuild.preprocessed_dir? pcpath: NULL ) )
{
fclose( header );
vg_fatal_error( "Failed to assemble fragment source code" );
if( (arg = vg_long_opt_arg( "load-step-delay", "Loader step delay (ms)" )) )
vg.load_step_delay = atoi(arg);
+ if( (arg = vg_long_opt_arg( "log", "Log output to text file (without console colours)" )) )
+ {
+ vg_log.plain_output_file = fopen( arg, "w" );
+ if( !vg_log.plain_output_file )
+ vg_error( "Could not open '%s' for logging.\n", arg );
+ }
+
vg.window_name = window_name;
}
#endif
char buffer[4096], line[96];
-
vsnprintf( buffer, VG_ARRAY_LEN(buffer), fmt, args );
+
+#ifdef VG_ENGINE
+ if( vg_log.plain_output_file )
+ {
+ fputs( prefix, vg_log.plain_output_file );
+ fputs( " | ", vg_log.plain_output_file );
+ fputs( buffer, vg_log.plain_output_file );
+ }
+#endif
+
int line_length = snprintf( line, 90, "%s%7s" KNRM "|%s ", colour, prefix, colour );
for( u32 i=0; i<VG_ARRAY_LEN(buffer); i ++ )
const char *colour,
const char *fmt, ... )
{
-
va_list args;
va_start( args, fmt );
_vg_logx_va( file,