X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=src%2Fshader.c;h=934d30d28c1ee2ead86f7a16632a136c637540ea;hb=HEAD;hp=2f7c16790fe6d81d900b9c2d535157b8d74ce3ec;hpb=deb49cc59884e298467c497d46518243ddb5a209;p=vg.git diff --git a/src/shader.c b/src/shader.c index 2f7c167..934d30d 100644 --- a/src/shader.c +++ b/src/shader.c @@ -8,6 +8,8 @@ struct uniform { char name[30]; char type[20]; + + int array; } uniform_buffer[100]; static int uniform_count; @@ -27,7 +29,7 @@ static int compile_subshader( FILE *header, char *name ) /* VG */ fprintf( header, "{\n" - ".orig_file = \"../shaders/%s\",\n" + ".orig_file = \"../../shaders/%s\",\n" ".static_src = \n", name ); char *cur = full, *start = full; @@ -44,6 +46,7 @@ static int compile_subshader( FILE *header, char *name ) { start += 8; struct uniform *uf = &uniform_buffer[ uniform_count ++ ]; + uf->array = 0; for( int i=0;; i++ ) { if( start[i] == '\0' ) @@ -54,6 +57,13 @@ static int compile_subshader( FILE *header, char *name ) start[i] = '\0'; strncpy( uf->name, start, sizeof(uf->name) ); } + + if( start[i] == '[' ) + { + start[i] = '\0'; + strncpy( uf->name, start, sizeof(uf->name) ); + uf->array = 1; + } if( start[i] == ' ' ) { @@ -143,6 +153,8 @@ int main( int argc, char *argv[] ) for( int i=0; iarray ) continue; + if( !strcmp(uf->type,"vec2") ) { fprintf( header, "static void shader_%s_%s(v2f v){\n"