00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef TEXTUREPOOL_H
00020 #define TEXTUREPOOL_H
00021
00022 #include "pandabase.h"
00023 #include "texture.h"
00024 #include "filename.h"
00025
00026 #include "pmap.h"
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 class EXPCL_PANDA TexturePool {
00037 PUBLISHED:
00038
00039
00040
00041 INLINE static bool has_texture(const string &filename);
00042 INLINE static bool verify_texture(const string &filename);
00043 INLINE static Texture *load_texture(const string &filename,
00044 int primary_file_num_channels = 0);
00045 INLINE static Texture *load_texture(const string &filename,
00046 const string &alpha_filename,
00047 int primary_file_num_channels = 0,
00048 int alpha_file_channel = 0);
00049 INLINE static void add_texture(Texture *texture);
00050 INLINE static void release_texture(Texture *texture);
00051 INLINE static void release_all_textures();
00052
00053 INLINE static int garbage_collect();
00054
00055 INLINE static void list_contents(ostream &out);
00056
00057 private:
00058 INLINE TexturePool();
00059
00060 bool ns_has_texture(const Filename &orig_filename);
00061 Texture *ns_load_texture(const Filename &orig_filename, int primary_file_num_channels);
00062 Texture *ns_load_texture(const Filename &orig_filename,
00063 const Filename &orig_alpha_filename,
00064 int primary_file_num_channels,
00065 int alpha_file_channel);
00066 void ns_add_texture(Texture *texture);
00067 void ns_release_texture(Texture *texture);
00068 void ns_release_all_textures();
00069 int ns_garbage_collect();
00070 void ns_list_contents(ostream &out);
00071
00072 static TexturePool *get_ptr();
00073
00074 static TexturePool *_global_ptr;
00075 typedef pmap<string, PT(Texture) > Textures;
00076 Textures _textures;
00077 };
00078
00079 #include "texturePool.I"
00080
00081 #endif
00082
00083