ProgramResource.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. // Copyright (C) 2009-2015, Panagiotis Christopoulos Charitos.
  2. // All rights reserved.
  3. // Code licensed under the BSD License.
  4. // http://www.anki3d.org/LICENSE
  5. #ifndef ANKI_RESOURCE_PROGRAM_RESOURCE_H
  6. #define ANKI_RESOURCE_PROGRAM_RESOURCE_H
  7. #include "anki/resource/Common.h"
  8. #include "anki/Gl.h"
  9. namespace anki {
  10. /// @addtogroup resource
  11. /// @{
  12. /// Shader program resource
  13. class ProgramResource
  14. {
  15. public:
  16. ProgramResource(ResourceAllocator<U8>&)
  17. {}
  18. ~ProgramResource()
  19. {}
  20. const GlShaderHandle& getGlProgram() const
  21. {
  22. return m_shader;
  23. }
  24. /// Resource load
  25. ANKI_USE_RESULT Error load(
  26. const CString& filename, ResourceInitializer& init);
  27. /// Load and add extra code on top of the file
  28. ANKI_USE_RESULT Error load(
  29. const CString& filename, const CString& extraSrc,
  30. ResourceManager& manager);
  31. /// Used by @ref Material and @ref Renderer to create custom shaders in
  32. /// the cache
  33. /// @param filename The file pathname of the shader prog
  34. /// @param preAppendedSrcCode The source code we want to write on top
  35. /// of the shader prog
  36. /// @param filenamePrefix Add that at the base filename for additional
  37. /// ways to identify the file in the cache
  38. /// @param out The file pathname of the new shader prog. Its
  39. /// $HOME/.anki/cache/ + filenamePrefix + hash + .glsl
  40. static ANKI_USE_RESULT Error createToCache(
  41. const CString& filename,
  42. const CString& preAppendedSrcCode,
  43. const CString& filenamePrefix,
  44. ResourceManager& manager,
  45. TempResourceString& out);
  46. private:
  47. GlShaderHandle m_shader;
  48. };
  49. /// @}
  50. } // end namespace anki
  51. #endif