+{
+ if(!features.custom.empty())
+ {
+ const char *whitespace = " \t\n";
+ string::size_type start = 0;
+ while(1)
+ {
+ start = features.custom.find_first_not_of(whitespace, start);
+ if(start==string::npos)
+ break;
+
+ string::size_type semicolon = features.custom.find(';', start);
+ if(semicolon==start)
+ {
+ ++start;
+ continue;
+ }
+ else if(semicolon==string::npos)
+ throw invalid_variable_definition(features.custom.substr(start));
+
+ string::size_type equals = features.custom.find('=', start);
+ if(equals>semicolon)
+ equals = string::npos;
+
+ VariableDefinition var;
+ string::size_type decl_end = min(equals, semicolon);
+ for(unsigned i=0;; ++i)
+ {
+ string::size_type word_end = features.custom.find_first_of(whitespace, start);
+ word_end = min(word_end, decl_end);
+ features.custom[word_end] = 0;
+
+ const char *word = &features.custom[start];
+ if(i==0)
+ {
+ if(!strcmp(word, "uniform"))
+ var.scope = UNIFORM;
+ else if(!strcmp(word, "attribute"))
+ var.scope = ATTRIBUTE;
+ else if(!strcmp(word, "vertex"))
+ var.scope = VERTEX;
+ else if(!strcmp(word, "fragment"))
+ var.scope = FRAGMENT;
+ else
+ throw invalid_variable_definition(word);
+ }
+ else if(i==1)
+ var.type = word;
+ else if(i==2)
+ var.name = word;
+
+ start = features.custom.find_first_not_of(whitespace, word_end+1);
+ if(start>=decl_end)
+ break;
+ }
+
+ if(equals!=string::npos)
+ {
+ start = features.custom.find_first_not_of(whitespace, equals+1);
+ if(start>=semicolon)
+ throw invalid_variable_definition("no expression");
+ features.custom[semicolon] = 0;
+ var.expression = &features.custom[start];
+ }
+ else
+ var.expression = 0;
+
+ var.flags = 0;
+ for(const VariableDefinition *j=standard_variables; j->name; ++j)
+ if(!strcmp(var.name, j->name))
+ var.flags = "o";
+
+ custom_variables.push_front(var);
+
+ start = semicolon+1;
+ }
+ }
+}