X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fprogrambuilder.h;h=9860b4683320ad335dda5b6fdc5072b8ef0b5f6f;hb=5ae4b00;hp=cca0c14912165616eecc7f9838e59671a9a2ebb1;hpb=825a334729ded60f7b554af4b2d5ab57122efbe9;p=libs%2Fgl.git diff --git a/source/programbuilder.h b/source/programbuilder.h index cca0c149..9860b468 100644 --- a/source/programbuilder.h +++ b/source/programbuilder.h @@ -18,9 +18,15 @@ public: virtual ~invalid_variable_definition() throw() { } }; +/** +Generates shaders with common features. +*/ class ProgramBuilder { public: + /** + Describes the features of a standard shader program. + */ struct StandardFeatures { class Loader: public DataFile::ObjectLoader @@ -33,6 +39,7 @@ public: bool material; bool lighting; unsigned max_lights; + bool skylight; bool specular; bool normalmap; bool shadow; @@ -49,6 +56,7 @@ private: enum VariableScope { NO_SCOPE, + TYPE, UNIFORM, ATTRIBUTE, VERTEX, @@ -77,7 +85,9 @@ private: { std::string name; const VariableDefinition *variable; + const VariableDefinition *type; std::string resolved_name; + std::string resolved_block; bool fuzzy_space; std::string resolved_space; bool array_sum; @@ -93,6 +103,7 @@ private: void resolve(const VariableDefinition &); void resolve(ShaderVariable &); + void resolve_type(const VariableDefinition &); void resolve_space(const std::string &); void resolve_array(const StandardFeatures &, unsigned = 0); void add_reference(ShaderVariable &); @@ -100,6 +111,7 @@ private: void check_inline(bool, bool); bool is_referenced_from(VariableScope) const; InterfaceFlags get_interface_flags(VariableScope) const; + std::string create_type_declaration() const; std::string create_declaration(char = 0, bool = false) const; std::string create_replacement(VariableScope, const char * = 0) const; std::string create_expression(const char * = 0) const; @@ -130,6 +142,7 @@ public: private: std::string create_source(const std::list &, VariableScope) const; bool evaluate_flags(const char *) const; + static const char *unqualified_name(const char *); static MatchType name_match(const char *, const char *, const char ** = 0); static bool parse_identifier(const char *, unsigned &, unsigned &); static std::vector extract_identifiers(const char *);