00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef SHADERPOOL_H
00016 #define SHADERPOOL_H
00017
00018 #include "pandabase.h"
00019 #include "shader.h"
00020 #include "filename.h"
00021 #include "lightMutex.h"
00022 #include "pmap.h"
00023
00024
00025
00026
00027
00028
00029
00030
00031 class EXPCL_PANDA_PGRAPH ShaderPool {
00032 PUBLISHED:
00033 INLINE static bool has_shader(const Filename &filename);
00034 INLINE static bool verify_shader(const Filename &filename);
00035 BLOCKING INLINE static CPT(Shader) load_shader(const Filename &filename);
00036 INLINE static void add_shader(const Filename &filename, Shader *shader);
00037 INLINE static void release_shader(const Filename &filename);
00038 INLINE static void release_all_shaders();
00039
00040 INLINE static int garbage_collect();
00041
00042 INLINE static void list_contents(ostream &out);
00043 static void write(ostream &out);
00044
00045 private:
00046 INLINE ShaderPool();
00047
00048 bool ns_has_shader(const Filename &orig_filename);
00049 CPT(Shader) ns_load_shader(const Filename &orig_filename);
00050 void ns_add_shader(const Filename &orig_filename, Shader *shader);
00051 void ns_release_shader(const Filename &orig_filename);
00052 void ns_release_all_shaders();
00053 int ns_garbage_collect();
00054 void ns_list_contents(ostream &out) const;
00055
00056 void resolve_filename(Filename &new_filename, const Filename &orig_filename);
00057
00058 static ShaderPool *get_ptr();
00059 static ShaderPool *_global_ptr;
00060
00061 LightMutex _lock;
00062 typedef pmap<Filename, CPT(Shader) > Shaders;
00063 Shaders _shaders;
00064 };
00065
00066 #include "shaderPool.I"
00067
00068 #endif