Panda3D
shaderPool.h
Go to the documentation of this file.
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 
14 #ifndef SHADERPOOL_H
15 #define SHADERPOOL_H
16 
17 #include "pandabase.h"
18 #include "shader.h"
19 #include "filename.h"
20 #include "lightMutex.h"
21 #include "pmap.h"
22 
23 /**
24  * This is the preferred interface for loading shaders for the TextNode
25  * system. It is similar to ModelPool and TexturePool in that it unifies
26  * references to the same filename.
27  */
28 class EXPCL_PANDA_PGRAPH ShaderPool {
29 PUBLISHED:
30  INLINE static bool has_shader(const Filename &filename);
31  INLINE static bool verify_shader(const Filename &filename);
32  BLOCKING INLINE static CPT(Shader) load_shader(const Filename &filename);
33  INLINE static void add_shader(const Filename &filename, Shader *shader);
34  INLINE static void release_shader(const Filename &filename);
35  INLINE static void release_all_shaders();
36 
37  INLINE static int garbage_collect();
38 
39  INLINE static void list_contents(std::ostream &out);
40  static void write(std::ostream &out);
41 
42 private:
43  INLINE ShaderPool();
44 
45  bool ns_has_shader(const Filename &orig_filename);
46  CPT(Shader) ns_load_shader(const Filename &orig_filename);
47  void ns_add_shader(const Filename &orig_filename, Shader *shader);
48  void ns_release_shader(const Filename &orig_filename);
49  void ns_release_all_shaders();
50  int ns_garbage_collect();
51  void ns_list_contents(std::ostream &out) const;
52 
53  void resolve_filename(Filename &new_filename, const Filename &orig_filename);
54 
55  static ShaderPool *get_ptr();
56  static ShaderPool *_global_ptr;
57 
58  LightMutex _lock;
59  typedef pmap<Filename, CPT(Shader) > Shaders;
60  Shaders _shaders;
61 };
62 
63 #include "shaderPool.I"
64 
65 #endif
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is our own Panda specialization on the default STL map.
Definition: pmap.h:49
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Definition: shader.h:49
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is the preferred interface for loading shaders for the TextNode system.
Definition: shaderPool.h:28
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
The name of a file, such as a texture file or an Egg file.
Definition: filename.h:39
This is a standard, non-reentrant mutex, similar to the Mutex class.
Definition: lightMutex.h:39
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.