X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fprogrambuilder.h;h=053eb567487a9a03964235a5d04b3d84c555a68c;hp=69170e02ef979f543b16f1fc53ef0c9adbc0c2d1;hb=HEAD;hpb=d542522823423f9ed2a5d412de9250ee8367334b diff --git a/source/programbuilder.h b/source/programbuilder.h deleted file mode 100644 index 69170e02..00000000 --- a/source/programbuilder.h +++ /dev/null @@ -1,135 +0,0 @@ -#ifndef MSP_GL_PROGRAMBUILDER_H_ -#define MSP_GL_PROGRAMBUILDER_H_ - -#include -#include -#include -#include - -namespace Msp { -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: - struct StandardFeatures - { - class Loader: public DataFile::ObjectLoader - { - public: - Loader(StandardFeatures &); - }; - - bool texture; - bool material; - bool lighting; - bool specular; - bool normalmap; - bool shadow; - bool reflection; - bool legacy; - std::string custom; - - StandardFeatures(); - - std::string create_flags() const; - }; - -private: - enum VariableScope - { - NO_SCOPE, - UNIFORM, - ATTRIBUTE, - VERTEX, - FRAGMENT - }; - - enum InterfaceFlags - { - NO_INTERFACE = 0, - INPUT = 1, - OUTPUT = 2, - PASSTHROUGH = INPUT|OUTPUT, - GOAL = 4 - }; - - struct VariableDefinition - { - VariableScope scope; - const char *name; - const char *type; - const char *expression; - const char *flags; - }; - - struct ShaderVariable - { - std::string name; - const VariableDefinition *variable; - std::string resolved_name; - bool fuzzy_space; - std::string resolved_space; - std::list referenced_vars; - std::list referenced_by; - bool inlined; - bool inline_parens; - - ShaderVariable(const std::string &); - - 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(bool, bool); - bool is_referenced_from(VariableScope) const; - InterfaceFlags get_interface_flags(VariableScope) const; - std::string create_declaration(char = 0) const; - std::string create_replacement(VariableScope) const; - std::string create_expression() const; - }; - - enum MatchLevel - { - NO_MATCH, - EXACT, - FUZZY - }; - - StandardFeatures features; - std::list custom_variables; - std::string feature_flags; - bool optimize; - - static const VariableDefinition standard_variables[]; - static const char interfaces[]; - -public: - ProgramBuilder(const StandardFeatures &); - - void set_optimize(bool); - Program *create_program() const; - void add_shaders(Program &) const; -private: - std::string create_source(const std::list &, VariableScope) const; - bool evaluate_flags(const char *) const; - static MatchLevel name_match(const char *, const char *, const char ** = 0); - static bool parse_identifier(const char *, unsigned &, unsigned &); - static std::vector extract_identifiers(const char *); - static std::string replace_identifiers(const char *, const std::map &); -}; - -} // namespace GL -} // namespace Msp - -#endif