Panda3D
txaFileFilter.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 txaFileFilter.h
10  * @author drose
11  * @date 2006-07-27
12  */
13 
14 #ifndef TXAFILEFILTER_H
15 #define TXAFILEFILTER_H
16 
17 #include "pandatoolbase.h"
18 #include "texturePoolFilter.h"
19 #include "pt_EggTexture.h"
20 
21 class TxaFile;
22 
23 /**
24  * This is an abstract base class, a placeholder for any number of different
25  * classes that may wish to implement an effect on every texture loaded from
26  * disk via the TexturePool.
27  *
28  * In practice, as of the time of this writing, only the TxaFileFilter (in
29  * pandatool) actually implements this. But other kinds of filters are
30  * possible.
31  *
32  * This filter, once registered, will get a callback and a chance to modify
33  * each texture as it is loaded from disk the first time. If more than one
34  * filter is registered, each will be called in sequence, in the order in
35  * which they were registered.
36  *
37  * The filter does not get called again if the texture is subsequently
38  * reloaded from disk. It is suggested that filters for which this might be a
39  * problem should call tex->set_keep_ram_image(true).
40  */
41 class EXPCL_MISC TxaFileFilter : public TexturePoolFilter {
42 public:
43  virtual PT(Texture) post_load(Texture *tex);
44 
45 private:
46  static void read_txa_file();
47 
48 private:
49  static TxaFile *_txa_file;
50  static bool _got_txa_file;
51 
52 public:
53  static TypeHandle get_class_type() {
54  return _type_handle;
55  }
56  static void init_type() {
57  TexturePoolFilter::init_type();
58  register_type(_type_handle, "TxaFileFilter",
59  TexturePoolFilter::get_class_type());
60  }
61  virtual TypeHandle get_type() const {
62  return get_class_type();
63  }
64  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
65 
66 private:
67  static TypeHandle _type_handle;
68 };
69 
70 #include "txaFileFilter.I"
71 
72 #endif
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Represents a texture object, which is typically a single 2-d image but may also represent a 1-d or 3-...
Definition: texture.h:71
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
Definition: register_type.I:22
This is an abstract base class, a placeholder for any number of different classes that may wish to im...
Definition: txaFileFilter.h:41
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is an abstract base class, a placeholder for any number of different classes that may wish to im...
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
This represents the .txa file (usually textures.txa) that contains the user instructions for resizing...
Definition: txaFile.h:30