Search
lxdream.org :: lxdream/src/tools/genglsl.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/tools/genglsl.c
changeset 1208:6955202d6408
prev1207:f7ca985659c6
next1209:e606e65eaf54
author nkeynes
date Tue Feb 07 11:44:19 2012 +1000 (7 years ago)
permissions -rw-r--r--
last change Add enable/disable vertex attribute calls when making a shader active
file annotate diff log raw
1.1 --- a/src/tools/genglsl.c Tue Feb 07 11:20:00 2012 +1000
1.2 +++ b/src/tools/genglsl.c Tue Feb 07 11:44:19 2012 +1000
1.3 @@ -316,7 +316,7 @@
1.4 if( var->uniform ) {
1.5 fprintf( f, "void glsl_set_%s_%s(%s value); /* uniform %s %s */ \n", program->name, var->name, getCType(var->type,var->uniform), var->type, var->name );
1.6 } else {
1.7 - fprintf( f, "void glsl_set_%s_%s_pointer(%s ptr); /* attribute %s %s */ \n", program->name, var->name, getCType(var->type,var->uniform), var->type, var->name);
1.8 + fprintf( f, "void glsl_set_%s_%s_pointer(%s ptr, GLint stride); /* attribute %s %s */ \n", program->name, var->name, getCType(var->type,var->uniform), var->type, var->name);
1.9 }
1.10 }
1.11 }
1.12 @@ -373,7 +373,26 @@
1.13 }
1.14 for( program_ptr = data->programs; program_ptr != NULL; program_ptr = program_ptr->next ) {
1.15 program_t program = program_ptr->data;
1.16 - fprintf( f, "\nvoid glsl_use_%s() {\n glsl_use_program(prog_%s_id);\n}\n", program->name, program->name );
1.17 + fprintf( f, "\nstatic void glsl_cleanup_%s() {\n", program->name );
1.18 + for( var_ptr = program->variables; var_ptr != NULL; var_ptr = var_ptr->next ) {
1.19 + variable_t var = var_ptr->data;
1.20 + if( !var->uniform ) {
1.21 + fprintf( f, " glsl_disable_attrib(var_%s_%s_loc);\n", program->name, var->name );
1.22 + }
1.23 + }
1.24 + fprintf( f, "}\n");
1.25 +
1.26 + fprintf( f, "\nvoid glsl_use_%s() {\n", program->name );
1.27 + fprintf( f, " glsl_use_program(prog_%s_id);\n", program->name );
1.28 + for( var_ptr = program->variables; var_ptr != NULL; var_ptr = var_ptr->next ) {
1.29 + variable_t var = var_ptr->data;
1.30 + if( !var->uniform ) {
1.31 + fprintf( f, " glsl_enable_attrib(var_%s_%s_loc);\n", program->name, var->name );
1.32 + }
1.33 + }
1.34 + fprintf( f, " glsl_set_cleanup_fn(glsl_cleanup_%s);\n", program->name );
1.35 + fprintf( f, "}\n");
1.36 +
1.37
1.38 for( var_ptr = program->variables; var_ptr != NULL; var_ptr = var_ptr->next ) {
1.39 variable_t var = var_ptr->data;
.