Panda3D
samplerContext.h
1 // Filename: samplerContext.h
2 // Created by: rdb (11Dec14)
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 SAMPLERCONTEXT_H
16 #define SAMPLERCONTEXT_H
17 
18 #include "pandabase.h"
19 
20 #include "adaptiveLru.h"
21 #include "simpleLru.h"
22 #include "samplerState.h"
23 #include "savedContext.h"
24 
25 ////////////////////////////////////////////////////////////////////
26 // Class : SamplerContext
27 // Description : This is a special class object that holds a handle
28 // to the sampler state object given by the graphics
29 // back-end for a particular combination of texture
30 // sampling settings.
31 //
32 // Some graphics back-ends (like OpenGL) use mutable
33 // sampler objects, whereas others (Direct3D 10+) use
34 // immutable ones. In Panda3D, each unique sampler
35 // state has its own SamplerContext, which simplifies
36 // the implementation and makes redundant sampler
37 // objects impossible.
38 ////////////////////////////////////////////////////////////////////
39 class EXPCL_PANDA_GOBJ SamplerContext : public SavedContext, public SimpleLruPage {
40 public:
41  INLINE SamplerContext(const SamplerState &sampler);
42 
43  virtual void output(ostream &out) const;
44  virtual void write(ostream &out, int indent_level) const;
45 
46 public:
47  static TypeHandle get_class_type() {
48  return _type_handle;
49  }
50  static void init_type() {
51  SavedContext::init_type();
52  register_type(_type_handle, "SamplerContext",
53  SavedContext::get_class_type());
54  }
55  virtual TypeHandle get_type() const {
56  return get_class_type();
57  }
58  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
59 
60 private:
61  static TypeHandle _type_handle;
62 
63  friend class PreparedGraphicsObjects;
64 };
65 
66 inline ostream &operator << (ostream &out, const SamplerContext &context) {
67  context.output(out);
68  return out;
69 }
70 
71 #include "samplerContext.I"
72 
73 #endif
74 
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:70
Represents a set of settings that indicate how a texture is sampled.
Definition: samplerState.h:39
This is a special class object that holds a handle to the sampler state object given by the graphics ...
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
This is the base class for all GSG-specific context objects, such as TextureContext and GeomContext...
Definition: savedContext.h:29