shaderPool.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /**
  2. * PANDA 3D SOFTWARE
  3. * Copyright (c) Carnegie Mellon University. All rights reserved.
  4. *
  5. * All use of this software is subject to the terms of the revised BSD
  6. * license. You should have received a copy of this license along
  7. * with this source code in a file named "LICENSE."
  8. *
  9. * @file shaderPool.h
  10. * @author aignacio
  11. * @date 2006-03
  12. */
  13. #ifndef SHADERPOOL_H
  14. #define SHADERPOOL_H
  15. #include "pandabase.h"
  16. #include "shader.h"
  17. #include "filename.h"
  18. #include "lightMutex.h"
  19. #include "pmap.h"
  20. /**
  21. * This is the preferred interface for loading shaders for the TextNode
  22. * system. It is similar to ModelPool and TexturePool in that it unifies
  23. * references to the same filename.
  24. */
  25. class EXPCL_PANDA_PGRAPH ShaderPool {
  26. PUBLISHED:
  27. INLINE static bool has_shader(const Filename &filename);
  28. INLINE static bool verify_shader(const Filename &filename);
  29. BLOCKING INLINE static CPT(Shader) load_shader(const Filename &filename);
  30. INLINE static void add_shader(const Filename &filename, Shader *shader);
  31. INLINE static void release_shader(const Filename &filename);
  32. INLINE static void release_all_shaders();
  33. INLINE static int garbage_collect();
  34. INLINE static void list_contents(std::ostream &out);
  35. static void write(std::ostream &out);
  36. private:
  37. INLINE ShaderPool();
  38. bool ns_has_shader(const Filename &orig_filename);
  39. CPT(Shader) ns_load_shader(const Filename &orig_filename);
  40. void ns_add_shader(const Filename &orig_filename, Shader *shader);
  41. void ns_release_shader(const Filename &orig_filename);
  42. void ns_release_all_shaders();
  43. int ns_garbage_collect();
  44. void ns_list_contents(std::ostream &out) const;
  45. void resolve_filename(Filename &new_filename, const Filename &orig_filename);
  46. static ShaderPool *get_ptr();
  47. static ShaderPool *_global_ptr;
  48. LightMutex _lock;
  49. typedef pmap<Filename, CPT(Shader) > Shaders;
  50. Shaders _shaders;
  51. };
  52. #include "shaderPool.I"
  53. #endif