Panda3D

Loading...
Searching...
No Matches
paramTexture.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 paramTexture.h
10 * @author rdb
11 * @date 2014-12-11
12 */
13
14#ifndef PARAMTEXTURE_H
15#define PARAMTEXTURE_H
16
17#include "pandabase.h"
18#include "paramValue.h"
19#include "samplerState.h"
20#include "texture.h"
21
22/**
23 * A class object for storing a pointer to a Texture along with a sampler
24 * state that indicates how to to sample the given texture.
25 */
26 class EXPCL_PANDA_GOBJ ParamTextureSampler : public ParamValueBase {
27 protected:
28 INLINE ParamTextureSampler() {};
29
30PUBLISHED:
31 INLINE ParamTextureSampler(Texture *tex, const SamplerState &sampler);
32
33 INLINE virtual TypeHandle get_value_type() const;
34 INLINE Texture *get_texture() const;
35 INLINE const SamplerState &get_sampler() const;
36
37 MAKE_PROPERTY(texture, get_texture);
38 MAKE_PROPERTY(sampler, get_sampler);
39
40 virtual void output(std::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);
49 virtual int complete_pointers(TypedWritable **plist,
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 * A class object for storing a pointer to a Texture along with a set of
76 * properties that indicates which image to bind to a shader input.
77 *
78 * This class is useful for binding texture images to a shader, which is a
79 * fairly esoteric feature.
80 */
81 class EXPCL_PANDA_GOBJ ParamTextureImage : public ParamValueBase {
82 protected:
83 INLINE ParamTextureImage() {};
84
85 enum AccessFlags {
86 A_read = 0x01,
87 A_write = 0x02,
88 A_layered = 0x04,
89 };
90
91PUBLISHED:
92 INLINE ParamTextureImage(Texture *tex, bool read, bool write, int z=-1, int n=0);
93
94 INLINE virtual TypeHandle get_value_type() const;
95
96 INLINE Texture *get_texture() const;
97 INLINE bool has_read_access() const;
98 INLINE bool has_write_access() const;
99 INLINE bool get_bind_layered() const;
100 INLINE int get_bind_level() const;
101 INLINE int get_bind_layer() const;
102
103 MAKE_PROPERTY(texture, get_texture);
104 MAKE_PROPERTY(read_access, has_read_access);
105 MAKE_PROPERTY(write_access, has_write_access);
106 MAKE_PROPERTY(bind_level, get_bind_level);
107 MAKE_PROPERTY2(bind_layer, get_bind_layered, get_bind_layer);
108
109 virtual void output(std::ostream &out) const;
110
111 private:
112 PT(Texture) _texture;
113 int _access : 4;
114 int _bind_level : 8;
115 int _bind_layer : 20;
116
117 public:
118 static void register_with_read_factory();
119 virtual void write_datagram(BamWriter *manager, Datagram &dg);
120 virtual int complete_pointers(TypedWritable **plist,
121 BamReader *manager);
122
123 protected:
124 static TypedWritable *make_from_bam(const FactoryParams &params);
125 void fillin(DatagramIterator &scan, BamReader *manager);
126
127 public:
128 virtual TypeHandle get_type() const {
129 return get_class_type();
130 }
131 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
132 static TypeHandle get_class_type() {
133 return _type_handle;
134 }
135 static void init_type() {
136 ParamValueBase::init_type();
137 register_type(_type_handle, "ParamTextureImage",
138 ParamValueBase::get_class_type());
139 }
140
141 private:
142 static TypeHandle _type_handle;
143};
144
145#include "paramTexture.I"
146
147#endif
BamReader
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition bamReader.h:110
DatagramIterator
A class to retrieve the individual data elements previously stored in a Datagram.
Definition datagramIterator.h:30
Datagram
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition datagram.h:38
FactoryParams
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition factoryParams.h:36
ParamTextureImage::get_texture
get_texture
Retrieves the texture stored in the parameter.
Definition paramTexture.h:103
ParamTextureImage::has_write_access
has_write_access
Returns true if this image should be bound with write access enabled.
Definition paramTexture.h:105
ParamTextureImage::register_with_read_factory
static void register_with_read_factory()
Tells the BamReader how to create objects of type ParamValue.
Definition paramTexture.cxx:131
ParamTextureImage::has_read_access
has_read_access
Returns true if this image should be bound with read access enabled.
Definition paramTexture.h:104
ParamTextureImage::get_bind_level
get_bind_level
Returns the image level that should be bound.
Definition paramTexture.h:106
ParamTextureImage::get_bind_layered
get_bind_layered
Returns true if all layers of this image should be bound simultaneously.
Definition paramTexture.h:107
ParamTextureImage::get_bind_layer
get_bind_layer
Returns the image layer that should be bound.
Definition paramTexture.h:107
ParamTextureSampler::register_with_read_factory
static void register_with_read_factory()
Tells the BamReader how to create objects of type ParamValue.
Definition paramTexture.cxx:41
ParamTextureSampler::get_texture
get_texture
Retrieves the texture stored in the parameter.
Definition paramTexture.h:37
ParamTextureSampler::get_sampler
get_sampler
Retrieves the sampler state stored in the parameter.
Definition paramTexture.h:38
ParamValueBase::get_value_type
virtual TypeHandle get_value_type() const
Returns the type of the underlying value.
Definition paramValue.I:28
SamplerState
Represents a set of settings that indicate how a texture is sampled.
Definition samplerState.h:36
Texture
Represents a texture object, which is typically a single 2-d image but may also represent a 1-d or 3-...
Definition texture.h:72
TypeHandle
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
TypedWritable::fillin
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...
Definition typedWritable.cxx:103
TypedWritable::write_datagram
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
Definition typedWritable.cxx:54
TypedWritable::complete_pointers
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().
Definition typedWritable.cxx:81
plist
This is our own Panda specialization on the default STL list.
Definition plist.h:35
pandabase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
paramTexture.I
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
paramValue.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
register_type
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
samplerState.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
texture.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.