1 #ifndef MSP_GL_PROGRAMBUILDER_H_
2 #define MSP_GL_PROGRAMBUILDER_H_
7 #include <msp/datafile/objectloader.h>
17 struct StandardFeatures
19 class Loader: public DataFile::ObjectLoader<StandardFeatures>
22 Loader(StandardFeatures &);
36 std::string create_flags() const;
49 struct StandardVariable
54 const char *expression;
61 const StandardVariable *variable;
62 std::string resolved_name;
64 std::string resolved_space;
65 std::list<ShaderVariable *> referenced_vars;
66 std::list<ShaderVariable *> referenced_by;
70 ShaderVariable(const std::string &);
72 void resolve(const StandardVariable &);
73 void resolve(ShaderVariable &);
74 void resolve_space(const std::string &);
75 void add_reference(ShaderVariable &);
76 void update_reference(ShaderVariable &, ShaderVariable &);
78 bool is_referenced_from(VariableScope) const;
79 std::string get_expression() const;
89 StandardFeatures features;
90 std::string feature_flags;
93 static const StandardVariable standard_variables[];
96 ProgramBuilder(const StandardFeatures &);
98 void set_optimize(bool);
99 Program *create_program() const;
100 void add_shaders(Program &) const;
102 std::string create_source(const std::list<ShaderVariable *> &, VariableScope) const;
103 bool evaluate_flags(const char *) const;
104 static MatchLevel name_match(const char *, const char *, const char ** = 0);
105 static bool parse_identifier(const char *, unsigned &, unsigned &);
106 static std::vector<std::string> extract_identifiers(const char *);
107 static std::string replace_identifiers(const char *, const std::map<std::string, std::string> &);