X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=vg_build_utils_shader.h;h=72afd4e862de9449cbed2401a019ae58d9220b66;hb=a548f6ad8db187ef0fbada42db0ae1ab3af01529;hp=77ce897e4f32297706aa692b2b9ff670b10742c5;hpb=76f30a0f4aef82c10b4affbeab3f0271936ce7ca;p=vg.git diff --git a/vg_build_utils_shader.h b/vg_build_utils_shader.h index 77ce897..72afd4e 100644 --- a/vg_build_utils_shader.h +++ b/vg_build_utils_shader.h @@ -35,6 +35,8 @@ static void vg_shader_set_include_dir( char *dir ) static void parse_uniform_name( char *start, struct uniform *uf ) { uf->array = 0; + int type_set = 0; + for( int i=0;; i++ ) { if( start[i] == '\0' ) @@ -43,20 +45,28 @@ static void parse_uniform_name( char *start, struct uniform *uf ) if( start[i] == ';' ) { start[i] = '\0'; - strncpy( uf->name, start, sizeof(uf->name) ); + vg_strncpy( start, uf->name, sizeof(uf->name), + k_strncpy_always_add_null ); } if( start[i] == '[' ) { start[i] = '\0'; - strncpy( uf->name, start, sizeof(uf->name) ); + vg_strncpy( start, uf->name, sizeof(uf->name), + k_strncpy_always_add_null ); uf->array = 1; } if( start[i] == ' ' ) { start[i] = '\0'; - strncpy( uf->type, start, sizeof(uf->type) ); + + if( !type_set ) + { + vg_strncpy( start, uf->type, sizeof(uf->type), + k_strncpy_always_add_null ); + type_set = 1; + } start = start+i+1; i=0; } @@ -80,7 +90,9 @@ static int compile_subshader( FILE *header, char *name ) else { fprintf( header, "{\n" - ".static_src = \n" ); + ".orig_file = \"%s\",\n" + ".static_src = \n", + name ); char *cur = full, *start = full; while( 1 ) @@ -199,7 +211,8 @@ int vg_build_shader( char *src_vert, /* path/to/vert.vs */ for( int i=0; iarray ) continue; + if( uf->array ) + continue; for( int j=0; j