MaterialShaderProgramCreator.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #ifndef ANKI_RESOURCE_MATERIAL_SHADER_PROGRAM_CREATOR_H
  2. #define ANKI_RESOURCE_MATERIAL_SHADER_PROGRAM_CREATOR_H
  3. #include "anki/util/StringList.h"
  4. namespace anki {
  5. class XmlElement;
  6. /// Creator of shader programs. This class parses between
  7. /// <shaderProgam></shaderProgram> located inside a <material></material>
  8. /// and creates the source of a custom program.
  9. ///
  10. /// @note Be carefull when you change the methods. Create as less unique
  11. /// shaders as possible
  12. class MaterialShaderProgramCreator
  13. {
  14. public:
  15. struct Input
  16. {
  17. std::string name;
  18. std::string type;
  19. StringList value;
  20. Bool constant;
  21. U32 arraySize;
  22. };
  23. explicit MaterialShaderProgramCreator(const XmlElement& pt,
  24. Bool enableUniformBlocks = false);
  25. ~MaterialShaderProgramCreator();
  26. /// Get the shader program source code. This is the one and only public
  27. /// member
  28. const std::string& getShaderProgramSource() const
  29. {
  30. return source;
  31. }
  32. const PtrVector<Input>& getInputVariables() const
  33. {
  34. return inputs;
  35. }
  36. private:
  37. /// The lines of the shader program source
  38. StringList srcLines;
  39. std::string source; ///< Shader program final source
  40. PtrVector<Input> inputs;
  41. Bool enableUniformBlocks;
  42. /// Parse what is within the
  43. /// @code <shaderProgram></shaderProgram> @endcode
  44. void parseShaderProgramTag(const XmlElement& el);
  45. /// Parse what is within the
  46. /// @code <shader></shader> @endcode
  47. void parseShaderTag(const XmlElement& el);
  48. /// Parse what is within the @code <input></input> @endcode
  49. void parseInputTag(const XmlElement& el,
  50. std::string& line);
  51. /// Parse what is within the @code <operation></operation> @endcode
  52. void parseOperationTag(const XmlElement& el);
  53. };
  54. } // end namespace anki
  55. #endif