Panda3D
|
00001 // Filename: txaFileFilter.h 00002 // Created by: drose (27Jul06) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef TXAFILEFILTER_H 00016 #define TXAFILEFILTER_H 00017 00018 #include "pandatoolbase.h" 00019 #include "texturePoolFilter.h" 00020 #include "pt_EggTexture.h" 00021 00022 class TxaFile; 00023 00024 //////////////////////////////////////////////////////////////////// 00025 // Class : TxaFileFilter 00026 // Description : This is an abstract base class, a placeholder for any 00027 // number of different classes that may wish to 00028 // implement an effect on every texture loaded from disk 00029 // via the TexturePool. 00030 // 00031 // In practice, as of the time of this writing, only the 00032 // TxaFileFilter (in pandatool) actually implements 00033 // this. But other kinds of filters are possible. 00034 // 00035 // This filter, once registered, will get a callback and 00036 // a chance to modify each texture as it is loaded from 00037 // disk the first time. If more than one filter is 00038 // registered, each will be called in sequence, in the 00039 // order in which they were registered. 00040 // 00041 // The filter does not get called again if the texture 00042 // is subsequently reloaded from disk. It is suggested 00043 // that filters for which this might be a problem should 00044 // call tex->set_keep_ram_image(true). 00045 //////////////////////////////////////////////////////////////////// 00046 class EXPCL_MISC TxaFileFilter : public TexturePoolFilter { 00047 public: 00048 virtual PT(Texture) post_load(Texture *tex); 00049 00050 private: 00051 static void read_txa_file(); 00052 00053 private: 00054 static TxaFile *_txa_file; 00055 static bool _got_txa_file; 00056 00057 public: 00058 static TypeHandle get_class_type() { 00059 return _type_handle; 00060 } 00061 static void init_type() { 00062 TexturePoolFilter::init_type(); 00063 register_type(_type_handle, "TxaFileFilter", 00064 TexturePoolFilter::get_class_type()); 00065 } 00066 virtual TypeHandle get_type() const { 00067 return get_class_type(); 00068 } 00069 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00070 00071 private: 00072 static TypeHandle _type_handle; 00073 }; 00074 00075 #include "txaFileFilter.I" 00076 00077 #endif