Panda3D
 All Classes Functions Variables Enumerations
texturePoolFilter.h
1 // Filename: texturePoolFilter.h
2 // Created by: drose (27Jul06)
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 TEXTUREPOOLFILTER_H
16 #define TEXTUREPOOLFILTER_H
17 
18 #include "pandabase.h"
19 #include "texture.h"
20 #include "pointerTo.h"
21 #include "typedObject.h"
22 
23 class LoaderOptions;
24 
25 ////////////////////////////////////////////////////////////////////
26 // Class : TexturePoolFilter
27 // Description : This is an abstract base class, a placeholder for any
28 // number of different classes that may wish to
29 // implement an effect on every texture loaded from disk
30 // via the TexturePool.
31 //
32 // In practice, as of the time of this writing, only the
33 // TxaFileFilter (in pandatool) actually implements
34 // this. But other kinds of filters are possible.
35 //
36 // This filter, once registered, will get a callback and
37 // a chance to modify each texture as it is loaded from
38 // disk the first time. If more than one filter is
39 // registered, each will be called in sequence, in the
40 // order in which they were registered.
41 //
42 // The filter does not get called again if the texture
43 // is subsequently reloaded from disk. It is suggested
44 // that filters for which this might be a problem should
45 // call tex->set_keep_ram_image(true).
46 ////////////////////////////////////////////////////////////////////
47 class EXPCL_PANDA_GOBJ TexturePoolFilter : public TypedObject {
48 public:
49  virtual ~TexturePoolFilter();
50 
51  virtual PT(Texture) pre_load(const Filename &orig_filename,
52  const Filename &orig_alpha_filename,
53  int primary_file_num_channels,
54  int alpha_file_channel,
55  bool read_mipmaps,
56  const LoaderOptions &options);
57  virtual PT(Texture) post_load(Texture *tex);
58 
59  virtual void output(ostream &out) const;
60 
61 public:
62  static TypeHandle get_class_type() {
63  return _type_handle;
64  }
65  static void init_type() {
67  register_type(_type_handle, "TexturePoolFilter",
68  TypedObject::get_class_type());
69  }
70  virtual TypeHandle get_type() const {
71  return get_class_type();
72  }
73  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
74 
75 private:
76  static TypeHandle _type_handle;
77 };
78 
79 INLINE ostream &operator << (ostream &out, const TexturePoolFilter &filter) {
80  filter.output(out);
81  return out;
82 }
83 
84 #include "texturePoolFilter.I"
85 
86 #endif
static void init_type()
This function is declared non-inline to work around a compiler bug in g++ 2.96.
Definition: typedObject.cxx:52
Specifies parameters that may be passed to the loader.
Definition: loaderOptions.h:26
Represents a texture object, which is typically a single 2-d image but may also represent a 1-d or 3-...
Definition: texture.h:75
This is an abstract class that all classes which use TypeHandle, and also provide virtual functions t...
Definition: typedObject.h:98
The name of a file, such as a texture file or an Egg file.
Definition: filename.h:44
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:85