1 #ifndef MSP_GL_PROGRAMBUILDER_H_
2 #define MSP_GL_PROGRAMBUILDER_H_
7 #include <msp/datafile/objectloader.h>
14 class invalid_variable_definition: public std::invalid_argument
17 invalid_variable_definition(const std::string &w): std::invalid_argument(w) { }
18 virtual ~invalid_variable_definition() throw() { }
24 struct StandardFeatures
26 class Loader: public DataFile::ObjectLoader<StandardFeatures>
29 Loader(StandardFeatures &);
44 std::string create_flags() const;
57 struct VariableDefinition
62 const char *expression;
69 const VariableDefinition *variable;
70 std::string resolved_name;
72 std::string resolved_space;
73 std::list<ShaderVariable *> referenced_vars;
74 std::list<ShaderVariable *> referenced_by;
78 ShaderVariable(const std::string &);
80 void resolve(const VariableDefinition &);
81 void resolve(ShaderVariable &);
82 void resolve_space(const std::string &);
83 void add_reference(ShaderVariable &);
84 void update_reference(ShaderVariable &, ShaderVariable &);
85 void check_inline(bool);
86 bool is_referenced_from(VariableScope) const;
87 std::string get_expression() const;
97 StandardFeatures features;
98 std::list<VariableDefinition> custom_variables;
99 std::string feature_flags;
102 static const VariableDefinition standard_variables[];
105 ProgramBuilder(const StandardFeatures &);
107 void set_optimize(bool);
108 Program *create_program() const;
109 void add_shaders(Program &) const;
111 std::string create_source(const std::list<ShaderVariable *> &, VariableScope) const;
112 bool evaluate_flags(const char *) const;
113 static MatchLevel name_match(const char *, const char *, const char ** = 0);
114 static bool parse_identifier(const char *, unsigned &, unsigned &);
115 static std::vector<std::string> extract_identifiers(const char *);
116 static std::string replace_identifiers(const char *, const std::map<std::string, std::string> &);