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