Panda3D
samplerContext.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 samplerContext.h
10  * @author rdb
11  * @date 2014-12-11
12  */
13 
14 #ifndef SAMPLERCONTEXT_H
15 #define SAMPLERCONTEXT_H
16 
17 #include "pandabase.h"
18 
19 #include "adaptiveLru.h"
20 #include "simpleLru.h"
21 #include "samplerState.h"
22 #include "savedContext.h"
23 
24 /**
25  * This is a special class object that holds a handle to the sampler state
26  * object given by the graphics back-end for a particular combination of
27  * texture sampling settings.
28  *
29  * Some graphics back-ends (like OpenGL) use mutable sampler objects, whereas
30  * others (Direct3D 10+) use immutable ones. In Panda3D, each unique sampler
31  * state has its own SamplerContext, which simplifies the implementation and
32  * makes redundant sampler objects impossible.
33  */
34 class EXPCL_PANDA_GOBJ SamplerContext : public SavedContext, public SimpleLruPage {
35 public:
36  INLINE SamplerContext(const SamplerState &sampler);
37 
38  virtual void output(std::ostream &out) const;
39  virtual void write(std::ostream &out, int indent_level) const;
40 
41 public:
42  static TypeHandle get_class_type() {
43  return _type_handle;
44  }
45  static void init_type() {
46  SavedContext::init_type();
47  register_type(_type_handle, "SamplerContext",
48  SavedContext::get_class_type());
49  }
50  virtual TypeHandle get_type() const {
51  return get_class_type();
52  }
53  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
54 
55 private:
56  static TypeHandle _type_handle;
57 
58  friend class PreparedGraphicsObjects;
59 };
60 
61 inline std::ostream &operator << (std::ostream &out, const SamplerContext &context) {
62  context.output(out);
63  return out;
64 }
65 
66 #include "samplerContext.I"
67 
68 #endif
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A table of objects that are saved within the graphics context for reference by handle later.
One atomic piece that may be managed by a SimpleLru chain.
Definition: simpleLru.h:65
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Represents a set of settings that indicate how a texture is sampled.
Definition: samplerState.h:36
This is a special class object that holds a handle to the sampler state object given by the graphics ...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
This is the base class for all GSG-specific context objects, such as TextureContext and GeomContext.
Definition: savedContext.h:26
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.