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 &);
38 std::string create_flags() const;
51 struct StandardVariable
56 const char *expression;
63 const StandardVariable *variable;
64 std::string resolved_name;
66 std::string resolved_space;
67 std::list<ShaderVariable *> referenced_vars;
68 std::list<ShaderVariable *> referenced_by;
72 ShaderVariable(const std::string &);
74 void resolve(const StandardVariable &);
75 void resolve(ShaderVariable &);
76 void resolve_space(const std::string &);
77 void add_reference(ShaderVariable &);
78 void update_reference(ShaderVariable &, ShaderVariable &);
79 void check_inline(bool);
80 bool is_referenced_from(VariableScope) const;
81 std::string get_expression() const;
91 StandardFeatures features;
92 std::string feature_flags;
95 static const StandardVariable standard_variables[];
98 ProgramBuilder(const StandardFeatures &);
100 void set_optimize(bool);
101 Program *create_program() const;
102 void add_shaders(Program &) const;
104 std::string create_source(const std::list<ShaderVariable *> &, VariableScope) const;
105 bool evaluate_flags(const char *) const;
106 static MatchLevel name_match(const char *, const char *, const char ** = 0);
107 static bool parse_identifier(const char *, unsigned &, unsigned &);
108 static std::vector<std::string> extract_identifiers(const char *);
109 static std::string replace_identifiers(const char *, const std::map<std::string, std::string> &);