X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fprogrambuilder.h;h=7840ecf00a2ef993a3590b6dd802f798b3d5878e;hb=e37851b98dde5082ee92570354746f2f92e21940;hp=82a954b58b481faf4809cac719baa3aa1c48079a;hpb=83bfb4bc26cf20cada1fcda47064b75d8e49fa08;p=libs%2Fgl.git diff --git a/source/programbuilder.h b/source/programbuilder.h index 82a954b5..7840ecf0 100644 --- a/source/programbuilder.h +++ b/source/programbuilder.h @@ -11,6 +11,13 @@ namespace GL { class Program; +class invalid_variable_definition: public std::invalid_argument +{ +public: + invalid_variable_definition(const std::string &w): std::invalid_argument(w) { } + virtual ~invalid_variable_definition() throw() { } +}; + class ProgramBuilder { public: @@ -29,13 +36,15 @@ public: bool normalmap; bool shadow; bool reflection; - bool transform; + bool legacy; + std::string custom; StandardFeatures(); std::string create_flags() const; }; +private: enum VariableScope { NO_SCOPE, @@ -45,8 +54,7 @@ public: FRAGMENT }; -private: - struct StandardVariable + struct VariableDefinition { VariableScope scope; const char *name; @@ -58,7 +66,7 @@ private: struct ShaderVariable { std::string name; - const StandardVariable *variable; + const VariableDefinition *variable; std::string resolved_name; bool fuzzy_space; std::string resolved_space; @@ -69,12 +77,12 @@ private: ShaderVariable(const std::string &); - void resolve(const StandardVariable &); + void resolve(const VariableDefinition &); void resolve(ShaderVariable &); void resolve_space(const std::string &); void add_reference(ShaderVariable &); void update_reference(ShaderVariable &, ShaderVariable &); - void check_inline(); + void check_inline(bool); bool is_referenced_from(VariableScope) const; std::string get_expression() const; }; @@ -87,10 +95,11 @@ private: }; StandardFeatures features; + std::list custom_variables; std::string feature_flags; bool optimize; - static const StandardVariable standard_variables[]; + static const VariableDefinition standard_variables[]; public: ProgramBuilder(const StandardFeatures &);