Panda3D
paramTexture.h
1 // Filename: paramTexture.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 PARAMTEXTURE_H
16 #define PARAMTEXTURE_H
17 
18 #include "pandabase.h"
19 #include "paramValue.h"
20 #include "samplerState.h"
21 #include "texture.h"
22 
23 ////////////////////////////////////////////////////////////////////
24 // Class : ParamTextureSampler
25 // Description : A class object for storing a pointer to a Texture
26 // along with a sampler state that indicates how to
27 // to sample the given texture.
28 ////////////////////////////////////////////////////////////////////
29 class EXPCL_PANDA_GOBJ ParamTextureSampler : public ParamValueBase {
30 protected:
31  INLINE ParamTextureSampler() {};
32 
33 PUBLISHED:
34  INLINE ParamTextureSampler(Texture *tex, const SamplerState &sampler);
35 
36  INLINE virtual TypeHandle get_value_type() const;
37  INLINE Texture *get_texture() const;
38  INLINE const SamplerState &get_sampler() const;
39 
40  virtual void output(ostream &out) const;
41 
42 private:
43  PT(Texture) _texture;
44  SamplerState _sampler;
45 
46 public:
47  static void register_with_read_factory();
48  virtual void write_datagram(BamWriter *manager, Datagram &dg);
50  BamReader *manager);
51 
52 protected:
53  static TypedWritable *make_from_bam(const FactoryParams &params);
54  void fillin(DatagramIterator &scan, BamReader *manager);
55 
56 public:
57  virtual TypeHandle get_type() const {
58  return get_class_type();
59  }
60  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
61  static TypeHandle get_class_type() {
62  return _type_handle;
63  }
64  static void init_type() {
65  ParamValueBase::init_type();
66  register_type(_type_handle, "ParamTextureSampler",
67  ParamValueBase::get_class_type());
68  }
69 
70 private:
71  static TypeHandle _type_handle;
72 };
73 
74 ////////////////////////////////////////////////////////////////////
75 // Class : ParamTextureImage
76 // Description : A class object for storing a pointer to a Texture
77 // along with a set of properties that indicates which
78 // image to bind to a shader input.
79 //
80 // This class is useful for binding texture images
81 // to a shader, which is a fairly esoteric feature.
82 ////////////////////////////////////////////////////////////////////
83 class EXPCL_PANDA_GOBJ ParamTextureImage : public ParamValueBase {
84 protected:
85  INLINE ParamTextureImage() {};
86 
87  enum AccessFlags {
88  A_read = 0x01,
89  A_write = 0x02,
90  A_layered = 0x04,
91  };
92 
93 PUBLISHED:
94  INLINE ParamTextureImage(Texture *tex, bool read, bool write, int z=-1, int n=0);
95 
96  INLINE virtual TypeHandle get_value_type() const;
97 
98  INLINE Texture *get_texture() const;
99  INLINE bool has_read_access() const;
100  INLINE bool has_write_access() const;
101  INLINE bool get_bind_layered() const;
102  INLINE int get_bind_level() const;
103  INLINE int get_bind_layer() const;
104 
105  virtual void output(ostream &out) const;
106 
107 private:
108  PT(Texture) _texture;
109  int _access : 4;
110  int _bind_level : 8;
111  int _bind_layer : 20;
112 
113 public:
114  static void register_with_read_factory();
115  virtual void write_datagram(BamWriter *manager, Datagram &dg);
116  virtual int complete_pointers(TypedWritable **plist,
117  BamReader *manager);
118 
119 protected:
120  static TypedWritable *make_from_bam(const FactoryParams &params);
121  void fillin(DatagramIterator &scan, BamReader *manager);
122 
123 public:
124  virtual TypeHandle get_type() const {
125  return get_class_type();
126  }
127  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
128  static TypeHandle get_class_type() {
129  return _type_handle;
130  }
131  static void init_type() {
132  ParamValueBase::init_type();
133  register_type(_type_handle, "ParamTextureImage",
134  ParamValueBase::get_class_type());
135  }
136 
137 private:
138  static TypeHandle _type_handle;
139 };
140 
141 #include "paramTexture.I"
142 
143 #endif
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:122
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
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:37
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:73
This is our own Panda specialization on the default STL list.
Definition: plist.h:38
virtual void fillin(DatagramIterator &scan, BamReader *manager)
This internal function is intended to be called by each class's make_from_bam() method to read in all...
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
A non-template base class of ParamValue (below), which serves mainly to define the placeholder for th...
Definition: paramValue.h:34
A class object for storing a pointer to a Texture along with a set of properties that indicates which...
Definition: paramTexture.h:83
virtual int complete_pointers(TypedWritable **p_list, BamReader *manager)
Receives an array of pointers, one for each time manager->read_pointer() was called in fillin()...
virtual TypeHandle get_value_type() const
Returns the type of the underlying value.
Definition: paramValue.I:34
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition: factoryParams.h:40
Represents a set of settings that indicate how a texture is sampled.
Definition: samplerState.h:39
A class object for storing a pointer to a Texture along with a sampler state that indicates how to to...
Definition: paramTexture.h:29
A class to retrieve the individual data elements previously stored in a Datagram. ...
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:43