14#ifndef TEXTUREATTRIB_H
15#define TEXTUREATTRIB_H
31class EXPCL_PANDA_PGRAPH TextureAttrib :
public RenderAttrib {
33 INLINE TextureAttrib();
34 INLINE TextureAttrib(
const TextureAttrib ©);
43 INLINE
bool is_off()
const;
50 static CPT(RenderAttrib)
make();
98 CPT(TextureAttrib)
filter_to_max(
int max_texture_stages)
const;
101 virtual void output(std::ostream &out)
const;
107 virtual int compare_to_impl(
const RenderAttrib *other)
const;
108 virtual size_t get_hash_impl()
const;
109 virtual CPT(RenderAttrib) compose_impl(
const RenderAttrib *other)
const;
110 virtual CPT(RenderAttrib) invert_compose_impl(
const RenderAttrib *other)
const;
113 INLINE
void check_sorted()
const;
114 void sort_on_stages();
120 unsigned int implicit_sort = 0,
128 unsigned int _implicit_sort;
132 class CompareTextureStagePriorities {
134 INLINE
bool operator () (
const TextureAttrib::StageNode *a,
const TextureAttrib::StageNode *b)
const;
137 class CompareTextureStageSort {
139 INLINE
bool operator () (
const TextureAttrib::StageNode *a,
const TextureAttrib::StageNode *b)
const;
142 class CompareTextureStagePointer {
144 INLINE
bool operator () (
const TextureAttrib::StageNode &a,
const TextureAttrib::StageNode &b)
const;
147 typedef ov_set<StageNode, CompareTextureStagePointer, epvector<StageNode> > Stages;
150 typedef pvector<StageNode *> RenderStages;
151 RenderStages _render_stages;
152 RenderStages _render_ff_stages;
153 unsigned int _next_implicit_sort;
156 bool _off_all_stages;
158 typedef pmap< int, CPT(TextureAttrib) > Filtered;
162 UpdateSeq _filtered_seq;
164 static CPT(RenderAttrib) _empty_attrib;
165 static CPT(RenderAttrib) _all_off_attrib;
168 static int get_class_slot() {
171 virtual int get_slot()
const {
172 return get_class_slot();
174 MAKE_PROPERTY(class_slot, get_class_slot);
177 static void register_with_read_factory();
182 static TypedWritable *make_from_bam(
const FactoryParams ¶ms);
183 void fillin(DatagramIterator &scan, BamReader *manager);
186 static TypeHandle get_class_type() {
189 static void init_type() {
190 RenderAttrib::init_type();
192 RenderAttrib::get_class_type());
193 _attrib_slot =
register_slot(_type_handle, 30,
new TextureAttrib);
195 virtual TypeHandle get_type()
const {
196 return get_class_type();
198 virtual TypeHandle force_init_type() {init_type();
return get_class_type();}
201 static TypeHandle _type_handle;
202 static int _attrib_slot;
This collects together the pieces of data that are accumulated for each node while walking the scene ...
This object performs a depth-first traversal of the scene graph, with optional view-frustum culling,...
virtual bool cull_callback(CullTraverser *trav, const CullTraverserData &data) const
If has_cull_callback() returns true, this function will be called during the cull traversal to perfor...
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
virtual bool has_cull_callback() const
Should be overridden by derived classes to return true if cull_callback() has been defined.
virtual bool lower_attrib_can_override() const
Intended to be overridden by derived RenderAttrib types to specify how two consecutive RenderAttrib o...
static int register_slot(TypeHandle type_handle, int sort, RenderAttrib *default_attrib)
Adds the indicated TypeHandle to the registry, if it is not there already, and returns a unique slot ...
Represents a set of settings that indicate how a texture is sampled.
static ConstPointerTo< RenderAttrib > make(Texture *tex)
Constructs a new TextureAttrib object suitable for rendering the indicated texture onto geometry,...
get_num_on_ff_stages
Returns the number of on-stages that are relevant to the classic fixed function pipeline.
ConstPointerTo< TextureAttrib > filter_to_max(int max_texture_stages) const
Returns a new TextureAttrib, very much like this one, but with the number of on_stages reduced to be ...
ConstPointerTo< RenderAttrib > unify_texture_stages(TextureStage *stage) const
Returns a new TextureAttrib, just like this one, but with any included TextureAttribs that happen to ...
get_num_on_stages
Returns the number of stages that are turned on by the attribute.
bool is_identity() const
Returns true if this is an identity attrib: it does not change the set of stages in use.
ConstPointerTo< RenderAttrib > remove_off_stage(TextureStage *stage) const
Returns a new TextureAttrib, just like this one, but with the indicated stage removed from the list o...
has_on_stage
Returns true if the indicated stage is turned on by the attrib, false otherwise.
bool has_off_stage(TextureStage *stage) const
Returns true if the indicated stage is turned off by the attrib, false otherwise.
Texture * get_texture() const
If the TextureAttrib is not an 'off' TextureAttrib, returns the base-level texture that is associated...
get_on_texture
Returns the texture associated with the indicated stage, or NULL if no texture is associated.
int find_on_stage(const TextureStage *stage) const
Returns the index number of the indicated TextureStage within the list of on_stages,...
get_off_stage
Returns the nth stage turned off by the attribute, sorted in arbitrary (pointer) order.
ConstPointerTo< RenderAttrib > add_off_stage(TextureStage *stage, int override=0) const
Returns a new TextureAttrib, just like this one, but with the indicated stage added to the list of st...
bool is_off() const
Returns true if the TextureAttrib is an 'off' TextureAttrib, indicating that it should disable textur...
get_on_stage
Returns the nth stage turned on by the attribute, sorted in render order.
get_on_sampler
Returns the sampler associated with the indicated stage, or the one associated with its texture if no...
static ConstPointerTo< RenderAttrib > make_all_off()
Constructs a new TextureAttrib object that turns off all stages (and hence disables texturing).
static ConstPointerTo< RenderAttrib > make_default()
Returns a RenderAttrib that corresponds to whatever the standard default properties for render attrib...
get_on_ff_stage
Returns the nth stage turned on by the attribute, sorted in render order, including only those releva...
int get_ff_tc_index(int n) const
For each TextureStage listed in get_on_ff_stage(), this returns a unique index number for the texture...
ConstPointerTo< RenderAttrib > replace_texture(Texture *tex, Texture *new_tex) const
Returns a new TextureAttrib, just like this one, but with all references to the given texture replace...
ConstPointerTo< RenderAttrib > add_on_stage(TextureStage *stage, Texture *tex, int override=0) const
Returns a new TextureAttrib, just like this one, but with the indicated stage added to the list of st...
bool has_all_off() const
Returns true if this attrib turns off all stages (although it may also turn some on).
static ConstPointerTo< RenderAttrib > make_off()
Constructs a new TextureAttrib object suitable for rendering untextured geometry.
ConstPointerTo< RenderAttrib > remove_on_stage(TextureStage *stage) const
Returns a new TextureAttrib, just like this one, but with the indicated stage removed from the list o...
get_num_off_stages
Returns the number of stages that are turned off by the attribute.
int get_on_stage_override(TextureStage *stage) const
Returns the override value associated with the indicated stage.
Defines the properties of a named stage of the multitexture pipeline.
Represents a texture object, which is typically a single 2-d image but may also represent a 1-d or 3-...
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().
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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(),...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.