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